babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539
  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/internalTextureLoader" {
  8386. import { Nullable } from "babylonjs/types";
  8387. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8388. /**
  8389. * This represents the required contract to create a new type of texture loader.
  8390. */
  8391. export interface IInternalTextureLoader {
  8392. /**
  8393. * Defines wether the loader supports cascade loading the different faces.
  8394. */
  8395. supportCascades: boolean;
  8396. /**
  8397. * This returns if the loader support the current file information.
  8398. * @param extension defines the file extension of the file being loaded
  8399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8400. * @param fallback defines the fallback internal texture if any
  8401. * @param isBase64 defines whether the texture is encoded as a base64
  8402. * @param isBuffer defines whether the texture data are stored as a buffer
  8403. * @returns true if the loader can load the specified file
  8404. */
  8405. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8406. /**
  8407. * Transform the url before loading if required.
  8408. * @param rootUrl the url of the texture
  8409. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8410. * @returns the transformed texture
  8411. */
  8412. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8413. /**
  8414. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8415. * @param rootUrl the url of the texture
  8416. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8417. * @returns the fallback texture
  8418. */
  8419. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8420. /**
  8421. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8422. * @param data contains the texture data
  8423. * @param texture defines the BabylonJS internal texture
  8424. * @param createPolynomials will be true if polynomials have been requested
  8425. * @param onLoad defines the callback to trigger once the texture is ready
  8426. * @param onError defines the callback to trigger in case of error
  8427. */
  8428. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8429. /**
  8430. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8431. * @param data contains the texture data
  8432. * @param texture defines the BabylonJS internal texture
  8433. * @param callback defines the method to call once ready to upload
  8434. */
  8435. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8436. }
  8437. }
  8438. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8439. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8440. import { Nullable } from "babylonjs/types";
  8441. import { Scene } from "babylonjs/scene";
  8442. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8443. module "babylonjs/Engines/engine" {
  8444. interface Engine {
  8445. /**
  8446. * Creates a depth stencil cube texture.
  8447. * This is only available in WebGL 2.
  8448. * @param size The size of face edge in the cube texture.
  8449. * @param options The options defining the cube texture.
  8450. * @returns The cube texture
  8451. */
  8452. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8453. /**
  8454. * Creates a cube texture
  8455. * @param rootUrl defines the url where the files to load is located
  8456. * @param scene defines the current scene
  8457. * @param files defines the list of files to load (1 per face)
  8458. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8459. * @param onLoad defines an optional callback raised when the texture is loaded
  8460. * @param onError defines an optional callback raised if there is an issue to load the texture
  8461. * @param format defines the format of the data
  8462. * @param forcedExtension defines the extension to use to pick the right loader
  8463. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8464. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8465. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8466. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8467. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8468. * @returns the cube texture as an InternalTexture
  8469. */
  8470. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8471. /**
  8472. * Creates a cube texture
  8473. * @param rootUrl defines the url where the files to load is located
  8474. * @param scene defines the current scene
  8475. * @param files defines the list of files to load (1 per face)
  8476. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8477. * @param onLoad defines an optional callback raised when the texture is loaded
  8478. * @param onError defines an optional callback raised if there is an issue to load the texture
  8479. * @param format defines the format of the data
  8480. * @param forcedExtension defines the extension to use to pick the right loader
  8481. * @returns the cube texture as an InternalTexture
  8482. */
  8483. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  8484. /**
  8485. * Creates a cube texture
  8486. * @param rootUrl defines the url where the files to load is located
  8487. * @param scene defines the current scene
  8488. * @param files defines the list of files to load (1 per face)
  8489. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8490. * @param onLoad defines an optional callback raised when the texture is loaded
  8491. * @param onError defines an optional callback raised if there is an issue to load the texture
  8492. * @param format defines the format of the data
  8493. * @param forcedExtension defines the extension to use to pick the right loader
  8494. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8495. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8496. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8497. * @returns the cube texture as an InternalTexture
  8498. */
  8499. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8500. /** @hidden */
  8501. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8502. /** @hidden */
  8503. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8504. /** @hidden */
  8505. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8506. /** @hidden */
  8507. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8508. }
  8509. }
  8510. }
  8511. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8512. import { Nullable } from "babylonjs/types";
  8513. import { Scene } from "babylonjs/scene";
  8514. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8515. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8516. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8517. /**
  8518. * Class for creating a cube texture
  8519. */
  8520. export class CubeTexture extends BaseTexture {
  8521. private _delayedOnLoad;
  8522. /**
  8523. * The url of the texture
  8524. */
  8525. url: string;
  8526. /**
  8527. * Gets or sets the center of the bounding box associated with the cube texture.
  8528. * It must define where the camera used to render the texture was set
  8529. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8530. */
  8531. boundingBoxPosition: Vector3;
  8532. private _boundingBoxSize;
  8533. /**
  8534. * Gets or sets the size of the bounding box associated with the cube texture
  8535. * When defined, the cubemap will switch to local mode
  8536. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8537. * @example https://www.babylonjs-playground.com/#RNASML
  8538. */
  8539. /**
  8540. * Returns the bounding box size
  8541. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8542. */
  8543. boundingBoxSize: Vector3;
  8544. protected _rotationY: number;
  8545. /**
  8546. * Sets texture matrix rotation angle around Y axis in radians.
  8547. */
  8548. /**
  8549. * Gets texture matrix rotation angle around Y axis radians.
  8550. */
  8551. rotationY: number;
  8552. /**
  8553. * Are mip maps generated for this texture or not.
  8554. */
  8555. readonly noMipmap: boolean;
  8556. private _noMipmap;
  8557. private _files;
  8558. private _extensions;
  8559. private _textureMatrix;
  8560. private _format;
  8561. private _createPolynomials;
  8562. /** @hidden */
  8563. _prefiltered: boolean;
  8564. /**
  8565. * Creates a cube texture from an array of image urls
  8566. * @param files defines an array of image urls
  8567. * @param scene defines the hosting scene
  8568. * @param noMipmap specifies if mip maps are not used
  8569. * @returns a cube texture
  8570. */
  8571. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8572. /**
  8573. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8574. * @param url defines the url of the prefiltered texture
  8575. * @param scene defines the scene the texture is attached to
  8576. * @param forcedExtension defines the extension of the file if different from the url
  8577. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8578. * @return the prefiltered texture
  8579. */
  8580. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8581. /**
  8582. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8583. * as prefiltered data.
  8584. * @param rootUrl defines the url of the texture or the root name of the six images
  8585. * @param scene defines the scene the texture is attached to
  8586. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8587. * @param noMipmap defines if mipmaps should be created or not
  8588. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8589. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8590. * @param onError defines a callback triggered in case of error during load
  8591. * @param format defines the internal format to use for the texture once loaded
  8592. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8593. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8594. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8595. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8596. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8597. * @return the cube texture
  8598. */
  8599. 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);
  8600. /**
  8601. * Get the current class name of the texture useful for serialization or dynamic coding.
  8602. * @returns "CubeTexture"
  8603. */
  8604. getClassName(): string;
  8605. /**
  8606. * Update the url (and optional buffer) of this texture if url was null during construction.
  8607. * @param url the url of the texture
  8608. * @param forcedExtension defines the extension to use
  8609. * @param onLoad callback called when the texture is loaded (defaults to null)
  8610. */
  8611. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8612. /**
  8613. * Delays loading of the cube texture
  8614. * @param forcedExtension defines the extension to use
  8615. */
  8616. delayLoad(forcedExtension?: string): void;
  8617. /**
  8618. * Returns the reflection texture matrix
  8619. * @returns the reflection texture matrix
  8620. */
  8621. getReflectionTextureMatrix(): Matrix;
  8622. /**
  8623. * Sets the reflection texture matrix
  8624. * @param value Reflection texture matrix
  8625. */
  8626. setReflectionTextureMatrix(value: Matrix): void;
  8627. /**
  8628. * Parses text to create a cube texture
  8629. * @param parsedTexture define the serialized text to read from
  8630. * @param scene defines the hosting scene
  8631. * @param rootUrl defines the root url of the cube texture
  8632. * @returns a cube texture
  8633. */
  8634. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8635. /**
  8636. * Makes a clone, or deep copy, of the cube texture
  8637. * @returns a new cube texture
  8638. */
  8639. clone(): CubeTexture;
  8640. }
  8641. }
  8642. declare module "babylonjs/Shaders/postprocess.vertex" {
  8643. /** @hidden */
  8644. export var postprocessVertexShader: {
  8645. name: string;
  8646. shader: string;
  8647. };
  8648. }
  8649. declare module "babylonjs/Cameras/targetCamera" {
  8650. import { Nullable } from "babylonjs/types";
  8651. import { Camera } from "babylonjs/Cameras/camera";
  8652. import { Scene } from "babylonjs/scene";
  8653. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8654. /**
  8655. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8656. * This is the base of the follow, arc rotate cameras and Free camera
  8657. * @see http://doc.babylonjs.com/features/cameras
  8658. */
  8659. export class TargetCamera extends Camera {
  8660. private static _RigCamTransformMatrix;
  8661. private static _TargetTransformMatrix;
  8662. private static _TargetFocalPoint;
  8663. /**
  8664. * Define the current direction the camera is moving to
  8665. */
  8666. cameraDirection: Vector3;
  8667. /**
  8668. * Define the current rotation the camera is rotating to
  8669. */
  8670. cameraRotation: Vector2;
  8671. /**
  8672. * When set, the up vector of the camera will be updated by the rotation of the camera
  8673. */
  8674. updateUpVectorFromRotation: boolean;
  8675. private _tmpQuaternion;
  8676. /**
  8677. * Define the current rotation of the camera
  8678. */
  8679. rotation: Vector3;
  8680. /**
  8681. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8682. */
  8683. rotationQuaternion: Quaternion;
  8684. /**
  8685. * Define the current speed of the camera
  8686. */
  8687. speed: number;
  8688. /**
  8689. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8690. * around all axis.
  8691. */
  8692. noRotationConstraint: boolean;
  8693. /**
  8694. * Define the current target of the camera as an object or a position.
  8695. */
  8696. lockedTarget: any;
  8697. /** @hidden */
  8698. _currentTarget: Vector3;
  8699. /** @hidden */
  8700. _initialFocalDistance: number;
  8701. /** @hidden */
  8702. _viewMatrix: Matrix;
  8703. /** @hidden */
  8704. _camMatrix: Matrix;
  8705. /** @hidden */
  8706. _cameraTransformMatrix: Matrix;
  8707. /** @hidden */
  8708. _cameraRotationMatrix: Matrix;
  8709. /** @hidden */
  8710. _referencePoint: Vector3;
  8711. /** @hidden */
  8712. _transformedReferencePoint: Vector3;
  8713. protected _globalCurrentTarget: Vector3;
  8714. protected _globalCurrentUpVector: Vector3;
  8715. /** @hidden */
  8716. _reset: () => void;
  8717. private _defaultUp;
  8718. /**
  8719. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8720. * This is the base of the follow, arc rotate cameras and Free camera
  8721. * @see http://doc.babylonjs.com/features/cameras
  8722. * @param name Defines the name of the camera in the scene
  8723. * @param position Defines the start position of the camera in the scene
  8724. * @param scene Defines the scene the camera belongs to
  8725. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8726. */
  8727. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8728. /**
  8729. * Gets the position in front of the camera at a given distance.
  8730. * @param distance The distance from the camera we want the position to be
  8731. * @returns the position
  8732. */
  8733. getFrontPosition(distance: number): Vector3;
  8734. /** @hidden */
  8735. _getLockedTargetPosition(): Nullable<Vector3>;
  8736. private _storedPosition;
  8737. private _storedRotation;
  8738. private _storedRotationQuaternion;
  8739. /**
  8740. * Store current camera state of the camera (fov, position, rotation, etc..)
  8741. * @returns the camera
  8742. */
  8743. storeState(): Camera;
  8744. /**
  8745. * Restored camera state. You must call storeState() first
  8746. * @returns whether it was successful or not
  8747. * @hidden
  8748. */
  8749. _restoreStateValues(): boolean;
  8750. /** @hidden */
  8751. _initCache(): void;
  8752. /** @hidden */
  8753. _updateCache(ignoreParentClass?: boolean): void;
  8754. /** @hidden */
  8755. _isSynchronizedViewMatrix(): boolean;
  8756. /** @hidden */
  8757. _computeLocalCameraSpeed(): number;
  8758. /**
  8759. * Defines the target the camera should look at.
  8760. * This will automatically adapt alpha beta and radius to fit within the new target.
  8761. * @param target Defines the new target as a Vector or a mesh
  8762. */
  8763. setTarget(target: Vector3): void;
  8764. /**
  8765. * Return the current target position of the camera. This value is expressed in local space.
  8766. * @returns the target position
  8767. */
  8768. getTarget(): Vector3;
  8769. /** @hidden */
  8770. _decideIfNeedsToMove(): boolean;
  8771. /** @hidden */
  8772. _updatePosition(): void;
  8773. /** @hidden */
  8774. _checkInputs(): void;
  8775. protected _updateCameraRotationMatrix(): void;
  8776. /**
  8777. * 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)
  8778. * @returns the current camera
  8779. */
  8780. private _rotateUpVectorWithCameraRotationMatrix;
  8781. private _cachedRotationZ;
  8782. private _cachedQuaternionRotationZ;
  8783. /** @hidden */
  8784. _getViewMatrix(): Matrix;
  8785. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8786. /**
  8787. * @hidden
  8788. */
  8789. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8790. /**
  8791. * @hidden
  8792. */
  8793. _updateRigCameras(): void;
  8794. private _getRigCamPositionAndTarget;
  8795. /**
  8796. * Gets the current object class name.
  8797. * @return the class name
  8798. */
  8799. getClassName(): string;
  8800. }
  8801. }
  8802. declare module "babylonjs/Cameras/cameraInputsManager" {
  8803. import { Nullable } from "babylonjs/types";
  8804. import { Camera } from "babylonjs/Cameras/camera";
  8805. /**
  8806. * @ignore
  8807. * This is a list of all the different input types that are available in the application.
  8808. * Fo instance: ArcRotateCameraGamepadInput...
  8809. */
  8810. export var CameraInputTypes: {};
  8811. /**
  8812. * This is the contract to implement in order to create a new input class.
  8813. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8814. */
  8815. export interface ICameraInput<TCamera extends Camera> {
  8816. /**
  8817. * Defines the camera the input is attached to.
  8818. */
  8819. camera: Nullable<TCamera>;
  8820. /**
  8821. * Gets the class name of the current intput.
  8822. * @returns the class name
  8823. */
  8824. getClassName(): string;
  8825. /**
  8826. * Get the friendly name associated with the input class.
  8827. * @returns the input friendly name
  8828. */
  8829. getSimpleName(): string;
  8830. /**
  8831. * Attach the input controls to a specific dom element to get the input from.
  8832. * @param element Defines the element the controls should be listened from
  8833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8834. */
  8835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8836. /**
  8837. * Detach the current controls from the specified dom element.
  8838. * @param element Defines the element to stop listening the inputs from
  8839. */
  8840. detachControl(element: Nullable<HTMLElement>): void;
  8841. /**
  8842. * Update the current camera state depending on the inputs that have been used this frame.
  8843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8844. */
  8845. checkInputs?: () => void;
  8846. }
  8847. /**
  8848. * Represents a map of input types to input instance or input index to input instance.
  8849. */
  8850. export interface CameraInputsMap<TCamera extends Camera> {
  8851. /**
  8852. * Accessor to the input by input type.
  8853. */
  8854. [name: string]: ICameraInput<TCamera>;
  8855. /**
  8856. * Accessor to the input by input index.
  8857. */
  8858. [idx: number]: ICameraInput<TCamera>;
  8859. }
  8860. /**
  8861. * This represents the input manager used within a camera.
  8862. * It helps dealing with all the different kind of input attached to a camera.
  8863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8864. */
  8865. export class CameraInputsManager<TCamera extends Camera> {
  8866. /**
  8867. * Defines the list of inputs attahed to the camera.
  8868. */
  8869. attached: CameraInputsMap<TCamera>;
  8870. /**
  8871. * Defines the dom element the camera is collecting inputs from.
  8872. * This is null if the controls have not been attached.
  8873. */
  8874. attachedElement: Nullable<HTMLElement>;
  8875. /**
  8876. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8877. */
  8878. noPreventDefault: boolean;
  8879. /**
  8880. * Defined the camera the input manager belongs to.
  8881. */
  8882. camera: TCamera;
  8883. /**
  8884. * Update the current camera state depending on the inputs that have been used this frame.
  8885. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8886. */
  8887. checkInputs: () => void;
  8888. /**
  8889. * Instantiate a new Camera Input Manager.
  8890. * @param camera Defines the camera the input manager blongs to
  8891. */
  8892. constructor(camera: TCamera);
  8893. /**
  8894. * Add an input method to a camera
  8895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8896. * @param input camera input method
  8897. */
  8898. add(input: ICameraInput<TCamera>): void;
  8899. /**
  8900. * Remove a specific input method from a camera
  8901. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8902. * @param inputToRemove camera input method
  8903. */
  8904. remove(inputToRemove: ICameraInput<TCamera>): void;
  8905. /**
  8906. * Remove a specific input type from a camera
  8907. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8908. * @param inputType the type of the input to remove
  8909. */
  8910. removeByType(inputType: string): void;
  8911. private _addCheckInputs;
  8912. /**
  8913. * Attach the input controls to the currently attached dom element to listen the events from.
  8914. * @param input Defines the input to attach
  8915. */
  8916. attachInput(input: ICameraInput<TCamera>): void;
  8917. /**
  8918. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8919. * @param element Defines the dom element to collect the events from
  8920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8921. */
  8922. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8923. /**
  8924. * Detach the current manager inputs controls from a specific dom element.
  8925. * @param element Defines the dom element to collect the events from
  8926. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8927. */
  8928. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8929. /**
  8930. * Rebuild the dynamic inputCheck function from the current list of
  8931. * defined inputs in the manager.
  8932. */
  8933. rebuildInputCheck(): void;
  8934. /**
  8935. * Remove all attached input methods from a camera
  8936. */
  8937. clear(): void;
  8938. /**
  8939. * Serialize the current input manager attached to a camera.
  8940. * This ensures than once parsed,
  8941. * the input associated to the camera will be identical to the current ones
  8942. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8943. */
  8944. serialize(serializedCamera: any): void;
  8945. /**
  8946. * Parses an input manager serialized JSON to restore the previous list of inputs
  8947. * and states associated to a camera.
  8948. * @param parsedCamera Defines the JSON to parse
  8949. */
  8950. parse(parsedCamera: any): void;
  8951. }
  8952. }
  8953. declare module "babylonjs/Events/keyboardEvents" {
  8954. /**
  8955. * Gather the list of keyboard event types as constants.
  8956. */
  8957. export class KeyboardEventTypes {
  8958. /**
  8959. * The keydown event is fired when a key becomes active (pressed).
  8960. */
  8961. static readonly KEYDOWN: number;
  8962. /**
  8963. * The keyup event is fired when a key has been released.
  8964. */
  8965. static readonly KEYUP: number;
  8966. }
  8967. /**
  8968. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8969. */
  8970. export class KeyboardInfo {
  8971. /**
  8972. * Defines the type of event (KeyboardEventTypes)
  8973. */
  8974. type: number;
  8975. /**
  8976. * Defines the related dom event
  8977. */
  8978. event: KeyboardEvent;
  8979. /**
  8980. * Instantiates a new keyboard info.
  8981. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8982. * @param type Defines the type of event (KeyboardEventTypes)
  8983. * @param event Defines the related dom event
  8984. */
  8985. constructor(
  8986. /**
  8987. * Defines the type of event (KeyboardEventTypes)
  8988. */
  8989. type: number,
  8990. /**
  8991. * Defines the related dom event
  8992. */
  8993. event: KeyboardEvent);
  8994. }
  8995. /**
  8996. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8997. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8998. */
  8999. export class KeyboardInfoPre extends KeyboardInfo {
  9000. /**
  9001. * Defines the type of event (KeyboardEventTypes)
  9002. */
  9003. type: number;
  9004. /**
  9005. * Defines the related dom event
  9006. */
  9007. event: KeyboardEvent;
  9008. /**
  9009. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9010. */
  9011. skipOnPointerObservable: boolean;
  9012. /**
  9013. * Instantiates a new keyboard pre info.
  9014. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9015. * @param type Defines the type of event (KeyboardEventTypes)
  9016. * @param event Defines the related dom event
  9017. */
  9018. constructor(
  9019. /**
  9020. * Defines the type of event (KeyboardEventTypes)
  9021. */
  9022. type: number,
  9023. /**
  9024. * Defines the related dom event
  9025. */
  9026. event: KeyboardEvent);
  9027. }
  9028. }
  9029. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9030. import { Nullable } from "babylonjs/types";
  9031. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9032. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9033. /**
  9034. * Manage the keyboard inputs to control the movement of a free camera.
  9035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9036. */
  9037. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9038. /**
  9039. * Defines the camera the input is attached to.
  9040. */
  9041. camera: FreeCamera;
  9042. /**
  9043. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9044. */
  9045. keysUp: number[];
  9046. /**
  9047. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9048. */
  9049. keysDown: number[];
  9050. /**
  9051. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9052. */
  9053. keysLeft: number[];
  9054. /**
  9055. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9056. */
  9057. keysRight: number[];
  9058. private _keys;
  9059. private _onCanvasBlurObserver;
  9060. private _onKeyboardObserver;
  9061. private _engine;
  9062. private _scene;
  9063. /**
  9064. * Attach the input controls to a specific dom element to get the input from.
  9065. * @param element Defines the element the controls should be listened from
  9066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9067. */
  9068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9069. /**
  9070. * Detach the current controls from the specified dom element.
  9071. * @param element Defines the element to stop listening the inputs from
  9072. */
  9073. detachControl(element: Nullable<HTMLElement>): void;
  9074. /**
  9075. * Update the current camera state depending on the inputs that have been used this frame.
  9076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9077. */
  9078. checkInputs(): void;
  9079. /**
  9080. * Gets the class name of the current intput.
  9081. * @returns the class name
  9082. */
  9083. getClassName(): string;
  9084. /** @hidden */
  9085. _onLostFocus(): void;
  9086. /**
  9087. * Get the friendly name associated with the input class.
  9088. * @returns the input friendly name
  9089. */
  9090. getSimpleName(): string;
  9091. }
  9092. }
  9093. declare module "babylonjs/Lights/shadowLight" {
  9094. import { Camera } from "babylonjs/Cameras/camera";
  9095. import { Scene } from "babylonjs/scene";
  9096. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9098. import { Light } from "babylonjs/Lights/light";
  9099. /**
  9100. * Interface describing all the common properties and methods a shadow light needs to implement.
  9101. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9102. * as well as binding the different shadow properties to the effects.
  9103. */
  9104. export interface IShadowLight extends Light {
  9105. /**
  9106. * The light id in the scene (used in scene.findLighById for instance)
  9107. */
  9108. id: string;
  9109. /**
  9110. * The position the shdow will be casted from.
  9111. */
  9112. position: Vector3;
  9113. /**
  9114. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9115. */
  9116. direction: Vector3;
  9117. /**
  9118. * The transformed position. Position of the light in world space taking parenting in account.
  9119. */
  9120. transformedPosition: Vector3;
  9121. /**
  9122. * The transformed direction. Direction of the light in world space taking parenting in account.
  9123. */
  9124. transformedDirection: Vector3;
  9125. /**
  9126. * The friendly name of the light in the scene.
  9127. */
  9128. name: string;
  9129. /**
  9130. * Defines the shadow projection clipping minimum z value.
  9131. */
  9132. shadowMinZ: number;
  9133. /**
  9134. * Defines the shadow projection clipping maximum z value.
  9135. */
  9136. shadowMaxZ: number;
  9137. /**
  9138. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9139. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9140. */
  9141. computeTransformedInformation(): boolean;
  9142. /**
  9143. * Gets the scene the light belongs to.
  9144. * @returns The scene
  9145. */
  9146. getScene(): Scene;
  9147. /**
  9148. * Callback defining a custom Projection Matrix Builder.
  9149. * This can be used to override the default projection matrix computation.
  9150. */
  9151. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9152. /**
  9153. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9154. * @param matrix The materix to updated with the projection information
  9155. * @param viewMatrix The transform matrix of the light
  9156. * @param renderList The list of mesh to render in the map
  9157. * @returns The current light
  9158. */
  9159. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9160. /**
  9161. * Gets the current depth scale used in ESM.
  9162. * @returns The scale
  9163. */
  9164. getDepthScale(): number;
  9165. /**
  9166. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9167. * @returns true if a cube texture needs to be use
  9168. */
  9169. needCube(): boolean;
  9170. /**
  9171. * Detects if the projection matrix requires to be recomputed this frame.
  9172. * @returns true if it requires to be recomputed otherwise, false.
  9173. */
  9174. needProjectionMatrixCompute(): boolean;
  9175. /**
  9176. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9177. */
  9178. forceProjectionMatrixCompute(): void;
  9179. /**
  9180. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9181. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9182. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9183. */
  9184. getShadowDirection(faceIndex?: number): Vector3;
  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. /**
  9199. * Base implementation IShadowLight
  9200. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9201. */
  9202. export abstract class ShadowLight extends Light implements IShadowLight {
  9203. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9204. protected _position: Vector3;
  9205. protected _setPosition(value: Vector3): void;
  9206. /**
  9207. * Sets the position the shadow will be casted from. Also use as the light position for both
  9208. * point and spot lights.
  9209. */
  9210. /**
  9211. * Sets the position the shadow will be casted from. Also use as the light position for both
  9212. * point and spot lights.
  9213. */
  9214. position: Vector3;
  9215. protected _direction: Vector3;
  9216. protected _setDirection(value: Vector3): void;
  9217. /**
  9218. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9219. * Also use as the light direction on spot and directional lights.
  9220. */
  9221. /**
  9222. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9223. * Also use as the light direction on spot and directional lights.
  9224. */
  9225. direction: Vector3;
  9226. private _shadowMinZ;
  9227. /**
  9228. * Gets the shadow projection clipping minimum z value.
  9229. */
  9230. /**
  9231. * Sets the shadow projection clipping minimum z value.
  9232. */
  9233. shadowMinZ: number;
  9234. private _shadowMaxZ;
  9235. /**
  9236. * Sets the shadow projection clipping maximum z value.
  9237. */
  9238. /**
  9239. * Gets the shadow projection clipping maximum z value.
  9240. */
  9241. shadowMaxZ: number;
  9242. /**
  9243. * Callback defining a custom Projection Matrix Builder.
  9244. * This can be used to override the default projection matrix computation.
  9245. */
  9246. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9247. /**
  9248. * The transformed position. Position of the light in world space taking parenting in account.
  9249. */
  9250. transformedPosition: Vector3;
  9251. /**
  9252. * The transformed direction. Direction of the light in world space taking parenting in account.
  9253. */
  9254. transformedDirection: Vector3;
  9255. private _needProjectionMatrixCompute;
  9256. /**
  9257. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9258. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9259. */
  9260. computeTransformedInformation(): boolean;
  9261. /**
  9262. * Return the depth scale used for the shadow map.
  9263. * @returns the depth scale.
  9264. */
  9265. getDepthScale(): number;
  9266. /**
  9267. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9268. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9269. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9270. */
  9271. getShadowDirection(faceIndex?: number): Vector3;
  9272. /**
  9273. * Returns the ShadowLight absolute position in the World.
  9274. * @returns the position vector in world space
  9275. */
  9276. getAbsolutePosition(): Vector3;
  9277. /**
  9278. * Sets the ShadowLight direction toward the passed target.
  9279. * @param target The point to target in local space
  9280. * @returns the updated ShadowLight direction
  9281. */
  9282. setDirectionToTarget(target: Vector3): Vector3;
  9283. /**
  9284. * Returns the light rotation in euler definition.
  9285. * @returns the x y z rotation in local space.
  9286. */
  9287. getRotation(): Vector3;
  9288. /**
  9289. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9290. * @returns true if a cube texture needs to be use
  9291. */
  9292. needCube(): boolean;
  9293. /**
  9294. * Detects if the projection matrix requires to be recomputed this frame.
  9295. * @returns true if it requires to be recomputed otherwise, false.
  9296. */
  9297. needProjectionMatrixCompute(): boolean;
  9298. /**
  9299. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9300. */
  9301. forceProjectionMatrixCompute(): void;
  9302. /** @hidden */
  9303. _initCache(): void;
  9304. /** @hidden */
  9305. _isSynchronized(): boolean;
  9306. /**
  9307. * Computes the world matrix of the node
  9308. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9309. * @returns the world matrix
  9310. */
  9311. computeWorldMatrix(force?: boolean): Matrix;
  9312. /**
  9313. * Gets the minZ used for shadow according to both the scene and the light.
  9314. * @param activeCamera The camera we are returning the min for
  9315. * @returns the depth min z
  9316. */
  9317. getDepthMinZ(activeCamera: Camera): number;
  9318. /**
  9319. * Gets the maxZ used for shadow according to both the scene and the light.
  9320. * @param activeCamera The camera we are returning the max for
  9321. * @returns the depth max z
  9322. */
  9323. getDepthMaxZ(activeCamera: Camera): number;
  9324. /**
  9325. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9326. * @param matrix The materix to updated with the projection information
  9327. * @param viewMatrix The transform matrix of the light
  9328. * @param renderList The list of mesh to render in the map
  9329. * @returns The current light
  9330. */
  9331. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9332. }
  9333. }
  9334. declare module "babylonjs/Materials/materialHelper" {
  9335. import { Nullable } from "babylonjs/types";
  9336. import { Scene } from "babylonjs/scene";
  9337. import { Engine } from "babylonjs/Engines/engine";
  9338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9339. import { Light } from "babylonjs/Lights/light";
  9340. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9341. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9342. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9343. /**
  9344. * "Static Class" containing the most commonly used helper while dealing with material for
  9345. * rendering purpose.
  9346. *
  9347. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9348. *
  9349. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9350. */
  9351. export class MaterialHelper {
  9352. /**
  9353. * Bind the current view position to an effect.
  9354. * @param effect The effect to be bound
  9355. * @param scene The scene the eyes position is used from
  9356. */
  9357. static BindEyePosition(effect: Effect, scene: Scene): void;
  9358. /**
  9359. * Helps preparing the defines values about the UVs in used in the effect.
  9360. * UVs are shared as much as we can accross channels in the shaders.
  9361. * @param texture The texture we are preparing the UVs for
  9362. * @param defines The defines to update
  9363. * @param key The channel key "diffuse", "specular"... used in the shader
  9364. */
  9365. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9366. /**
  9367. * Binds a texture matrix value to its corrsponding uniform
  9368. * @param texture The texture to bind the matrix for
  9369. * @param uniformBuffer The uniform buffer receivin the data
  9370. * @param key The channel key "diffuse", "specular"... used in the shader
  9371. */
  9372. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9373. /**
  9374. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9375. * @param mesh defines the current mesh
  9376. * @param scene defines the current scene
  9377. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9378. * @param pointsCloud defines if point cloud rendering has to be turned on
  9379. * @param fogEnabled defines if fog has to be turned on
  9380. * @param alphaTest defines if alpha testing has to be turned on
  9381. * @param defines defines the current list of defines
  9382. */
  9383. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9384. /**
  9385. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9386. * @param scene defines the current scene
  9387. * @param engine defines the current engine
  9388. * @param defines specifies the list of active defines
  9389. * @param useInstances defines if instances have to be turned on
  9390. * @param useClipPlane defines if clip plane have to be turned on
  9391. */
  9392. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9393. /**
  9394. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9395. * @param mesh The mesh containing the geometry data we will draw
  9396. * @param defines The defines to update
  9397. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9398. * @param useBones Precise whether bones should be used or not (override mesh info)
  9399. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9400. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9401. * @returns false if defines are considered not dirty and have not been checked
  9402. */
  9403. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9404. /**
  9405. * Prepares the defines related to multiview
  9406. * @param scene The scene we are intending to draw
  9407. * @param defines The defines to update
  9408. */
  9409. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9410. /**
  9411. * Prepares the defines related to the light information passed in parameter
  9412. * @param scene The scene we are intending to draw
  9413. * @param mesh The mesh the effect is compiling for
  9414. * @param defines The defines to update
  9415. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9416. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9417. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9418. * @returns true if normals will be required for the rest of the effect
  9419. */
  9420. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9421. /**
  9422. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9423. * that won t be acctive due to defines being turned off.
  9424. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9425. * @param samplersList The samplers list
  9426. * @param defines The defines helping in the list generation
  9427. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9428. */
  9429. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9430. /**
  9431. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9432. * @param defines The defines to update while falling back
  9433. * @param fallbacks The authorized effect fallbacks
  9434. * @param maxSimultaneousLights The maximum number of lights allowed
  9435. * @param rank the current rank of the Effect
  9436. * @returns The newly affected rank
  9437. */
  9438. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9439. /**
  9440. * Prepares the list of attributes required for morph targets according to the effect defines.
  9441. * @param attribs The current list of supported attribs
  9442. * @param mesh The mesh to prepare the morph targets attributes for
  9443. * @param defines The current Defines of the effect
  9444. */
  9445. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9446. /**
  9447. * Prepares the list of attributes required for bones according to the effect defines.
  9448. * @param attribs The current list of supported attribs
  9449. * @param mesh The mesh to prepare the bones attributes for
  9450. * @param defines The current Defines of the effect
  9451. * @param fallbacks The current efffect fallback strategy
  9452. */
  9453. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9454. /**
  9455. * Prepares the list of attributes required for instances according to the effect defines.
  9456. * @param attribs The current list of supported attribs
  9457. * @param defines The current Defines of the effect
  9458. */
  9459. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9460. /**
  9461. * Binds the light shadow information to the effect for the given mesh.
  9462. * @param light The light containing the generator
  9463. * @param scene The scene the lights belongs to
  9464. * @param mesh The mesh we are binding the information to render
  9465. * @param lightIndex The light index in the effect used to render the mesh
  9466. * @param effect The effect we are binding the data to
  9467. */
  9468. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9469. /**
  9470. * Binds the light information to the effect.
  9471. * @param light The light containing the generator
  9472. * @param effect The effect we are binding the data to
  9473. * @param lightIndex The light index in the effect used to render
  9474. */
  9475. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9476. /**
  9477. * Binds the lights information from the scene to the effect for the given mesh.
  9478. * @param scene The scene the lights belongs to
  9479. * @param mesh The mesh we are binding the information to render
  9480. * @param effect The effect we are binding the data to
  9481. * @param defines The generated defines for the effect
  9482. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9483. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9484. */
  9485. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9486. private static _tempFogColor;
  9487. /**
  9488. * Binds the fog information from the scene to the effect for the given mesh.
  9489. * @param scene The scene the lights belongs to
  9490. * @param mesh The mesh we are binding the information to render
  9491. * @param effect The effect we are binding the data to
  9492. * @param linearSpace Defines if the fog effect is applied in linear space
  9493. */
  9494. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9495. /**
  9496. * Binds the bones information from the mesh to the effect.
  9497. * @param mesh The mesh we are binding the information to render
  9498. * @param effect The effect we are binding the data to
  9499. */
  9500. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9501. /**
  9502. * Binds the morph targets information from the mesh to the effect.
  9503. * @param abstractMesh The mesh we are binding the information to render
  9504. * @param effect The effect we are binding the data to
  9505. */
  9506. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9507. /**
  9508. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9509. * @param defines The generated defines used in the effect
  9510. * @param effect The effect we are binding the data to
  9511. * @param scene The scene we are willing to render with logarithmic scale for
  9512. */
  9513. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9514. /**
  9515. * Binds the clip plane information from the scene to the effect.
  9516. * @param scene The scene the clip plane information are extracted from
  9517. * @param effect The effect we are binding the data to
  9518. */
  9519. static BindClipPlane(effect: Effect, scene: Scene): void;
  9520. }
  9521. }
  9522. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9523. /** @hidden */
  9524. export var kernelBlurVaryingDeclaration: {
  9525. name: string;
  9526. shader: string;
  9527. };
  9528. }
  9529. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9530. /** @hidden */
  9531. export var kernelBlurFragment: {
  9532. name: string;
  9533. shader: string;
  9534. };
  9535. }
  9536. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9537. /** @hidden */
  9538. export var kernelBlurFragment2: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9544. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9545. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9546. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9547. /** @hidden */
  9548. export var kernelBlurPixelShader: {
  9549. name: string;
  9550. shader: string;
  9551. };
  9552. }
  9553. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9554. /** @hidden */
  9555. export var kernelBlurVertex: {
  9556. name: string;
  9557. shader: string;
  9558. };
  9559. }
  9560. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9561. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9562. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9563. /** @hidden */
  9564. export var kernelBlurVertexShader: {
  9565. name: string;
  9566. shader: string;
  9567. };
  9568. }
  9569. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9570. import { Vector2 } from "babylonjs/Maths/math";
  9571. import { Nullable } from "babylonjs/types";
  9572. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9573. import { Camera } from "babylonjs/Cameras/camera";
  9574. import { Effect } from "babylonjs/Materials/effect";
  9575. import { Engine } from "babylonjs/Engines/engine";
  9576. import "babylonjs/Shaders/kernelBlur.fragment";
  9577. import "babylonjs/Shaders/kernelBlur.vertex";
  9578. /**
  9579. * The Blur Post Process which blurs an image based on a kernel and direction.
  9580. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9581. */
  9582. export class BlurPostProcess extends PostProcess {
  9583. /** The direction in which to blur the image. */
  9584. direction: Vector2;
  9585. private blockCompilation;
  9586. protected _kernel: number;
  9587. protected _idealKernel: number;
  9588. protected _packedFloat: boolean;
  9589. private _staticDefines;
  9590. /**
  9591. * Sets the length in pixels of the blur sample region
  9592. */
  9593. /**
  9594. * Gets the length in pixels of the blur sample region
  9595. */
  9596. kernel: number;
  9597. /**
  9598. * Sets wether or not the blur needs to unpack/repack floats
  9599. */
  9600. /**
  9601. * Gets wether or not the blur is unpacking/repacking floats
  9602. */
  9603. packedFloat: boolean;
  9604. /**
  9605. * Creates a new instance BlurPostProcess
  9606. * @param name The name of the effect.
  9607. * @param direction The direction in which to blur the image.
  9608. * @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.
  9609. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9610. * @param camera The camera to apply the render pass to.
  9611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9612. * @param engine The engine which the post process will be applied. (default: current engine)
  9613. * @param reusable If the post process can be reused on the same frame. (default: false)
  9614. * @param textureType Type of textures used when performing the post process. (default: 0)
  9615. * @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)
  9616. */
  9617. constructor(name: string,
  9618. /** The direction in which to blur the image. */
  9619. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9620. /**
  9621. * Updates the effect with the current post process compile time values and recompiles the shader.
  9622. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9623. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9624. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9625. * @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
  9626. * @param onCompiled Called when the shader has been compiled.
  9627. * @param onError Called if there is an error when compiling a shader.
  9628. */
  9629. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9630. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9631. /**
  9632. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9633. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9634. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9635. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9636. * The gaps between physical kernels are compensated for in the weighting of the samples
  9637. * @param idealKernel Ideal blur kernel.
  9638. * @return Nearest best kernel.
  9639. */
  9640. protected _nearestBestKernel(idealKernel: number): number;
  9641. /**
  9642. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9643. * @param x The point on the Gaussian distribution to sample.
  9644. * @return the value of the Gaussian function at x.
  9645. */
  9646. protected _gaussianWeight(x: number): number;
  9647. /**
  9648. * Generates a string that can be used as a floating point number in GLSL.
  9649. * @param x Value to print.
  9650. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9651. * @return GLSL float string.
  9652. */
  9653. protected _glslFloat(x: number, decimalFigures?: number): string;
  9654. }
  9655. }
  9656. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9657. /** @hidden */
  9658. export var shadowMapPixelShader: {
  9659. name: string;
  9660. shader: string;
  9661. };
  9662. }
  9663. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9664. /** @hidden */
  9665. export var bonesDeclaration: {
  9666. name: string;
  9667. shader: string;
  9668. };
  9669. }
  9670. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9671. /** @hidden */
  9672. export var morphTargetsVertexGlobalDeclaration: {
  9673. name: string;
  9674. shader: string;
  9675. };
  9676. }
  9677. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9678. /** @hidden */
  9679. export var morphTargetsVertexDeclaration: {
  9680. name: string;
  9681. shader: string;
  9682. };
  9683. }
  9684. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9685. /** @hidden */
  9686. export var instancesDeclaration: {
  9687. name: string;
  9688. shader: string;
  9689. };
  9690. }
  9691. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9692. /** @hidden */
  9693. export var helperFunctions: {
  9694. name: string;
  9695. shader: string;
  9696. };
  9697. }
  9698. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9699. /** @hidden */
  9700. export var morphTargetsVertex: {
  9701. name: string;
  9702. shader: string;
  9703. };
  9704. }
  9705. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9706. /** @hidden */
  9707. export var instancesVertex: {
  9708. name: string;
  9709. shader: string;
  9710. };
  9711. }
  9712. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9713. /** @hidden */
  9714. export var bonesVertex: {
  9715. name: string;
  9716. shader: string;
  9717. };
  9718. }
  9719. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9720. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9721. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9722. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9723. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9724. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9725. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9726. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9727. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9728. /** @hidden */
  9729. export var shadowMapVertexShader: {
  9730. name: string;
  9731. shader: string;
  9732. };
  9733. }
  9734. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9735. /** @hidden */
  9736. export var depthBoxBlurPixelShader: {
  9737. name: string;
  9738. shader: string;
  9739. };
  9740. }
  9741. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9742. import { Nullable } from "babylonjs/types";
  9743. import { Scene } from "babylonjs/scene";
  9744. import { Matrix } from "babylonjs/Maths/math";
  9745. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9747. import { Mesh } from "babylonjs/Meshes/mesh";
  9748. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9749. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9750. import { Effect } from "babylonjs/Materials/effect";
  9751. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9752. import "babylonjs/Shaders/shadowMap.fragment";
  9753. import "babylonjs/Shaders/shadowMap.vertex";
  9754. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9755. import { Observable } from "babylonjs/Misc/observable";
  9756. /**
  9757. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9758. */
  9759. export interface ICustomShaderOptions {
  9760. /**
  9761. * Gets or sets the custom shader name to use
  9762. */
  9763. shaderName: string;
  9764. /**
  9765. * The list of attribute names used in the shader
  9766. */
  9767. attributes?: string[];
  9768. /**
  9769. * The list of unifrom names used in the shader
  9770. */
  9771. uniforms?: string[];
  9772. /**
  9773. * The list of sampler names used in the shader
  9774. */
  9775. samplers?: string[];
  9776. /**
  9777. * The list of defines used in the shader
  9778. */
  9779. defines?: string[];
  9780. }
  9781. /**
  9782. * Interface to implement to create a shadow generator compatible with BJS.
  9783. */
  9784. export interface IShadowGenerator {
  9785. /**
  9786. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9787. * @returns The render target texture if present otherwise, null
  9788. */
  9789. getShadowMap(): Nullable<RenderTargetTexture>;
  9790. /**
  9791. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9792. * @returns The render target texture if the shadow map is present otherwise, null
  9793. */
  9794. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9795. /**
  9796. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9797. * @param subMesh The submesh we want to render in the shadow map
  9798. * @param useInstances Defines wether will draw in the map using instances
  9799. * @returns true if ready otherwise, false
  9800. */
  9801. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9802. /**
  9803. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9804. * @param defines Defines of the material we want to update
  9805. * @param lightIndex Index of the light in the enabled light list of the material
  9806. */
  9807. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9808. /**
  9809. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9810. * defined in the generator but impacting the effect).
  9811. * It implies the unifroms available on the materials are the standard BJS ones.
  9812. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9813. * @param effect The effect we are binfing the information for
  9814. */
  9815. bindShadowLight(lightIndex: string, effect: Effect): void;
  9816. /**
  9817. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9818. * (eq to shadow prjection matrix * light transform matrix)
  9819. * @returns The transform matrix used to create the shadow map
  9820. */
  9821. getTransformMatrix(): Matrix;
  9822. /**
  9823. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9824. * Cube and 2D textures for instance.
  9825. */
  9826. recreateShadowMap(): void;
  9827. /**
  9828. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9829. * @param onCompiled Callback triggered at the and of the effects compilation
  9830. * @param options Sets of optional options forcing the compilation with different modes
  9831. */
  9832. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9833. useInstances: boolean;
  9834. }>): void;
  9835. /**
  9836. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9837. * @param options Sets of optional options forcing the compilation with different modes
  9838. * @returns A promise that resolves when the compilation completes
  9839. */
  9840. forceCompilationAsync(options?: Partial<{
  9841. useInstances: boolean;
  9842. }>): Promise<void>;
  9843. /**
  9844. * Serializes the shadow generator setup to a json object.
  9845. * @returns The serialized JSON object
  9846. */
  9847. serialize(): any;
  9848. /**
  9849. * Disposes the Shadow map and related Textures and effects.
  9850. */
  9851. dispose(): void;
  9852. }
  9853. /**
  9854. * Default implementation IShadowGenerator.
  9855. * This is the main object responsible of generating shadows in the framework.
  9856. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9857. */
  9858. export class ShadowGenerator implements IShadowGenerator {
  9859. /**
  9860. * Shadow generator mode None: no filtering applied.
  9861. */
  9862. static readonly FILTER_NONE: number;
  9863. /**
  9864. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9865. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9866. */
  9867. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9868. /**
  9869. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9870. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9871. */
  9872. static readonly FILTER_POISSONSAMPLING: number;
  9873. /**
  9874. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9875. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9876. */
  9877. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9878. /**
  9879. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9880. * edge artifacts on steep falloff.
  9881. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9882. */
  9883. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9884. /**
  9885. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9886. * edge artifacts on steep falloff.
  9887. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9888. */
  9889. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9890. /**
  9891. * Shadow generator mode PCF: Percentage Closer Filtering
  9892. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9893. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9894. */
  9895. static readonly FILTER_PCF: number;
  9896. /**
  9897. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9898. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9899. * Contact Hardening
  9900. */
  9901. static readonly FILTER_PCSS: number;
  9902. /**
  9903. * Reserved for PCF and PCSS
  9904. * Highest Quality.
  9905. *
  9906. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9907. *
  9908. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9909. */
  9910. static readonly QUALITY_HIGH: number;
  9911. /**
  9912. * Reserved for PCF and PCSS
  9913. * Good tradeoff for quality/perf cross devices
  9914. *
  9915. * Execute PCF on a 3*3 kernel.
  9916. *
  9917. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9918. */
  9919. static readonly QUALITY_MEDIUM: number;
  9920. /**
  9921. * Reserved for PCF and PCSS
  9922. * The lowest quality but the fastest.
  9923. *
  9924. * Execute PCF on a 1*1 kernel.
  9925. *
  9926. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9927. */
  9928. static readonly QUALITY_LOW: number;
  9929. /** Gets or sets the custom shader name to use */
  9930. customShaderOptions: ICustomShaderOptions;
  9931. /**
  9932. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9933. */
  9934. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9935. /**
  9936. * Observable triggered before a mesh is rendered in the shadow map.
  9937. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9938. */
  9939. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9940. private _bias;
  9941. /**
  9942. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9943. */
  9944. /**
  9945. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9946. */
  9947. bias: number;
  9948. private _normalBias;
  9949. /**
  9950. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9951. */
  9952. /**
  9953. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9954. */
  9955. normalBias: number;
  9956. private _blurBoxOffset;
  9957. /**
  9958. * Gets the blur box offset: offset applied during the blur pass.
  9959. * Only useful if useKernelBlur = false
  9960. */
  9961. /**
  9962. * Sets the blur box offset: offset applied during the blur pass.
  9963. * Only useful if useKernelBlur = false
  9964. */
  9965. blurBoxOffset: number;
  9966. private _blurScale;
  9967. /**
  9968. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9969. * 2 means half of the size.
  9970. */
  9971. /**
  9972. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9973. * 2 means half of the size.
  9974. */
  9975. blurScale: number;
  9976. private _blurKernel;
  9977. /**
  9978. * Gets the blur kernel: kernel size of the blur pass.
  9979. * Only useful if useKernelBlur = true
  9980. */
  9981. /**
  9982. * Sets the blur kernel: kernel size of the blur pass.
  9983. * Only useful if useKernelBlur = true
  9984. */
  9985. blurKernel: number;
  9986. private _useKernelBlur;
  9987. /**
  9988. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9989. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9990. */
  9991. /**
  9992. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9993. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9994. */
  9995. useKernelBlur: boolean;
  9996. private _depthScale;
  9997. /**
  9998. * Gets the depth scale used in ESM mode.
  9999. */
  10000. /**
  10001. * Sets the depth scale used in ESM mode.
  10002. * This can override the scale stored on the light.
  10003. */
  10004. depthScale: number;
  10005. private _filter;
  10006. /**
  10007. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10008. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10009. */
  10010. /**
  10011. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10012. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10013. */
  10014. filter: number;
  10015. /**
  10016. * Gets if the current filter is set to Poisson Sampling.
  10017. */
  10018. /**
  10019. * Sets the current filter to Poisson Sampling.
  10020. */
  10021. usePoissonSampling: boolean;
  10022. /**
  10023. * Gets if the current filter is set to ESM.
  10024. */
  10025. /**
  10026. * Sets the current filter is to ESM.
  10027. */
  10028. useExponentialShadowMap: boolean;
  10029. /**
  10030. * Gets if the current filter is set to filtered ESM.
  10031. */
  10032. /**
  10033. * Gets if the current filter is set to filtered ESM.
  10034. */
  10035. useBlurExponentialShadowMap: boolean;
  10036. /**
  10037. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10038. * exponential to prevent steep falloff artifacts).
  10039. */
  10040. /**
  10041. * Sets the current filter to "close ESM" (using the inverse of the
  10042. * exponential to prevent steep falloff artifacts).
  10043. */
  10044. useCloseExponentialShadowMap: boolean;
  10045. /**
  10046. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10047. * exponential to prevent steep falloff artifacts).
  10048. */
  10049. /**
  10050. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10051. * exponential to prevent steep falloff artifacts).
  10052. */
  10053. useBlurCloseExponentialShadowMap: boolean;
  10054. /**
  10055. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10056. */
  10057. /**
  10058. * Sets the current filter to "PCF" (percentage closer filtering).
  10059. */
  10060. usePercentageCloserFiltering: boolean;
  10061. private _filteringQuality;
  10062. /**
  10063. * Gets the PCF or PCSS Quality.
  10064. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10065. */
  10066. /**
  10067. * Sets the PCF or PCSS Quality.
  10068. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10069. */
  10070. filteringQuality: number;
  10071. /**
  10072. * Gets if the current filter is set to "PCSS" (contact hardening).
  10073. */
  10074. /**
  10075. * Sets the current filter to "PCSS" (contact hardening).
  10076. */
  10077. useContactHardeningShadow: boolean;
  10078. private _contactHardeningLightSizeUVRatio;
  10079. /**
  10080. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10081. * Using a ratio helps keeping shape stability independently of the map size.
  10082. *
  10083. * It does not account for the light projection as it was having too much
  10084. * instability during the light setup or during light position changes.
  10085. *
  10086. * Only valid if useContactHardeningShadow is true.
  10087. */
  10088. /**
  10089. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10090. * Using a ratio helps keeping shape stability independently of the map size.
  10091. *
  10092. * It does not account for the light projection as it was having too much
  10093. * instability during the light setup or during light position changes.
  10094. *
  10095. * Only valid if useContactHardeningShadow is true.
  10096. */
  10097. contactHardeningLightSizeUVRatio: number;
  10098. private _darkness;
  10099. /**
  10100. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10101. * 0 means strongest and 1 would means no shadow.
  10102. * @returns the darkness.
  10103. */
  10104. getDarkness(): number;
  10105. /**
  10106. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10107. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10108. * @returns the shadow generator allowing fluent coding.
  10109. */
  10110. setDarkness(darkness: number): ShadowGenerator;
  10111. private _transparencyShadow;
  10112. /**
  10113. * Sets the ability to have transparent shadow (boolean).
  10114. * @param transparent True if transparent else False
  10115. * @returns the shadow generator allowing fluent coding
  10116. */
  10117. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10118. private _shadowMap;
  10119. private _shadowMap2;
  10120. /**
  10121. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10122. * @returns The render target texture if present otherwise, null
  10123. */
  10124. getShadowMap(): Nullable<RenderTargetTexture>;
  10125. /**
  10126. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10127. * @returns The render target texture if the shadow map is present otherwise, null
  10128. */
  10129. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10130. /**
  10131. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10132. * @param mesh Mesh to add
  10133. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10134. * @returns the Shadow Generator itself
  10135. */
  10136. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10137. /**
  10138. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10139. * @param mesh Mesh to remove
  10140. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10141. * @returns the Shadow Generator itself
  10142. */
  10143. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10144. /**
  10145. * Controls the extent to which the shadows fade out at the edge of the frustum
  10146. * Used only by directionals and spots
  10147. */
  10148. frustumEdgeFalloff: number;
  10149. private _light;
  10150. /**
  10151. * Returns the associated light object.
  10152. * @returns the light generating the shadow
  10153. */
  10154. getLight(): IShadowLight;
  10155. /**
  10156. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10157. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10158. * It might on the other hand introduce peter panning.
  10159. */
  10160. forceBackFacesOnly: boolean;
  10161. private _scene;
  10162. private _lightDirection;
  10163. private _effect;
  10164. private _viewMatrix;
  10165. private _projectionMatrix;
  10166. private _transformMatrix;
  10167. private _cachedPosition;
  10168. private _cachedDirection;
  10169. private _cachedDefines;
  10170. private _currentRenderID;
  10171. private _boxBlurPostprocess;
  10172. private _kernelBlurXPostprocess;
  10173. private _kernelBlurYPostprocess;
  10174. private _blurPostProcesses;
  10175. private _mapSize;
  10176. private _currentFaceIndex;
  10177. private _currentFaceIndexCache;
  10178. private _textureType;
  10179. private _defaultTextureMatrix;
  10180. /** @hidden */
  10181. static _SceneComponentInitialization: (scene: Scene) => void;
  10182. /**
  10183. * Creates a ShadowGenerator object.
  10184. * A ShadowGenerator is the required tool to use the shadows.
  10185. * Each light casting shadows needs to use its own ShadowGenerator.
  10186. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10187. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10188. * @param light The light object generating the shadows.
  10189. * @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.
  10190. */
  10191. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10192. private _initializeGenerator;
  10193. private _initializeShadowMap;
  10194. private _initializeBlurRTTAndPostProcesses;
  10195. private _renderForShadowMap;
  10196. private _renderSubMeshForShadowMap;
  10197. private _applyFilterValues;
  10198. /**
  10199. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10200. * @param onCompiled Callback triggered at the and of the effects compilation
  10201. * @param options Sets of optional options forcing the compilation with different modes
  10202. */
  10203. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10204. useInstances: boolean;
  10205. }>): void;
  10206. /**
  10207. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10208. * @param options Sets of optional options forcing the compilation with different modes
  10209. * @returns A promise that resolves when the compilation completes
  10210. */
  10211. forceCompilationAsync(options?: Partial<{
  10212. useInstances: boolean;
  10213. }>): Promise<void>;
  10214. /**
  10215. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10216. * @param subMesh The submesh we want to render in the shadow map
  10217. * @param useInstances Defines wether will draw in the map using instances
  10218. * @returns true if ready otherwise, false
  10219. */
  10220. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10221. /**
  10222. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10223. * @param defines Defines of the material we want to update
  10224. * @param lightIndex Index of the light in the enabled light list of the material
  10225. */
  10226. prepareDefines(defines: any, lightIndex: number): void;
  10227. /**
  10228. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10229. * defined in the generator but impacting the effect).
  10230. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10231. * @param effect The effect we are binfing the information for
  10232. */
  10233. bindShadowLight(lightIndex: string, effect: Effect): void;
  10234. /**
  10235. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10236. * (eq to shadow prjection matrix * light transform matrix)
  10237. * @returns The transform matrix used to create the shadow map
  10238. */
  10239. getTransformMatrix(): Matrix;
  10240. /**
  10241. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10242. * Cube and 2D textures for instance.
  10243. */
  10244. recreateShadowMap(): void;
  10245. private _disposeBlurPostProcesses;
  10246. private _disposeRTTandPostProcesses;
  10247. /**
  10248. * Disposes the ShadowGenerator.
  10249. * Returns nothing.
  10250. */
  10251. dispose(): void;
  10252. /**
  10253. * Serializes the shadow generator setup to a json object.
  10254. * @returns The serialized JSON object
  10255. */
  10256. serialize(): any;
  10257. /**
  10258. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10259. * @param parsedShadowGenerator The JSON object to parse
  10260. * @param scene The scene to create the shadow map for
  10261. * @returns The parsed shadow generator
  10262. */
  10263. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10264. }
  10265. }
  10266. declare module "babylonjs/Lights/light" {
  10267. import { Nullable } from "babylonjs/types";
  10268. import { Scene } from "babylonjs/scene";
  10269. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10270. import { Node } from "babylonjs/node";
  10271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10272. import { Effect } from "babylonjs/Materials/effect";
  10273. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10274. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10275. /**
  10276. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10277. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10278. * 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.
  10279. */
  10280. export abstract class Light extends Node {
  10281. /**
  10282. * Falloff Default: light is falling off following the material specification:
  10283. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10284. */
  10285. static readonly FALLOFF_DEFAULT: number;
  10286. /**
  10287. * Falloff Physical: light is falling off following the inverse squared distance law.
  10288. */
  10289. static readonly FALLOFF_PHYSICAL: number;
  10290. /**
  10291. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10292. * to enhance interoperability with other engines.
  10293. */
  10294. static readonly FALLOFF_GLTF: number;
  10295. /**
  10296. * Falloff Standard: light is falling off like in the standard material
  10297. * to enhance interoperability with other materials.
  10298. */
  10299. static readonly FALLOFF_STANDARD: number;
  10300. /**
  10301. * If every light affecting the material is in this lightmapMode,
  10302. * material.lightmapTexture adds or multiplies
  10303. * (depends on material.useLightmapAsShadowmap)
  10304. * after every other light calculations.
  10305. */
  10306. static readonly LIGHTMAP_DEFAULT: number;
  10307. /**
  10308. * material.lightmapTexture as only diffuse lighting from this light
  10309. * adds only specular lighting from this light
  10310. * adds dynamic shadows
  10311. */
  10312. static readonly LIGHTMAP_SPECULAR: number;
  10313. /**
  10314. * material.lightmapTexture as only lighting
  10315. * no light calculation from this light
  10316. * only adds dynamic shadows from this light
  10317. */
  10318. static readonly LIGHTMAP_SHADOWSONLY: number;
  10319. /**
  10320. * Each light type uses the default quantity according to its type:
  10321. * point/spot lights use luminous intensity
  10322. * directional lights use illuminance
  10323. */
  10324. static readonly INTENSITYMODE_AUTOMATIC: number;
  10325. /**
  10326. * lumen (lm)
  10327. */
  10328. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10329. /**
  10330. * candela (lm/sr)
  10331. */
  10332. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10333. /**
  10334. * lux (lm/m^2)
  10335. */
  10336. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10337. /**
  10338. * nit (cd/m^2)
  10339. */
  10340. static readonly INTENSITYMODE_LUMINANCE: number;
  10341. /**
  10342. * Light type const id of the point light.
  10343. */
  10344. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10345. /**
  10346. * Light type const id of the directional light.
  10347. */
  10348. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10349. /**
  10350. * Light type const id of the spot light.
  10351. */
  10352. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10353. /**
  10354. * Light type const id of the hemispheric light.
  10355. */
  10356. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10357. /**
  10358. * Diffuse gives the basic color to an object.
  10359. */
  10360. diffuse: Color3;
  10361. /**
  10362. * Specular produces a highlight color on an object.
  10363. * Note: This is note affecting PBR materials.
  10364. */
  10365. specular: Color3;
  10366. /**
  10367. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10368. * falling off base on range or angle.
  10369. * This can be set to any values in Light.FALLOFF_x.
  10370. *
  10371. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10372. * other types of materials.
  10373. */
  10374. falloffType: number;
  10375. /**
  10376. * Strength of the light.
  10377. * Note: By default it is define in the framework own unit.
  10378. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10379. */
  10380. intensity: number;
  10381. private _range;
  10382. protected _inverseSquaredRange: number;
  10383. /**
  10384. * Defines how far from the source the light is impacting in scene units.
  10385. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10386. */
  10387. /**
  10388. * Defines how far from the source the light is impacting in scene units.
  10389. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10390. */
  10391. range: number;
  10392. /**
  10393. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10394. * of light.
  10395. */
  10396. private _photometricScale;
  10397. private _intensityMode;
  10398. /**
  10399. * Gets the photometric scale used to interpret the intensity.
  10400. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10401. */
  10402. /**
  10403. * Sets the photometric scale used to interpret the intensity.
  10404. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10405. */
  10406. intensityMode: number;
  10407. private _radius;
  10408. /**
  10409. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10410. */
  10411. /**
  10412. * sets the light radius used by PBR Materials to simulate soft area lights.
  10413. */
  10414. radius: number;
  10415. private _renderPriority;
  10416. /**
  10417. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10418. * exceeding the number allowed of the materials.
  10419. */
  10420. renderPriority: number;
  10421. private _shadowEnabled;
  10422. /**
  10423. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10424. * the current shadow generator.
  10425. */
  10426. /**
  10427. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10428. * the current shadow generator.
  10429. */
  10430. shadowEnabled: boolean;
  10431. private _includedOnlyMeshes;
  10432. /**
  10433. * Gets the only meshes impacted by this light.
  10434. */
  10435. /**
  10436. * Sets the only meshes impacted by this light.
  10437. */
  10438. includedOnlyMeshes: AbstractMesh[];
  10439. private _excludedMeshes;
  10440. /**
  10441. * Gets the meshes not impacted by this light.
  10442. */
  10443. /**
  10444. * Sets the meshes not impacted by this light.
  10445. */
  10446. excludedMeshes: AbstractMesh[];
  10447. private _excludeWithLayerMask;
  10448. /**
  10449. * Gets the layer id use to find what meshes are not impacted by the light.
  10450. * Inactive if 0
  10451. */
  10452. /**
  10453. * Sets the layer id use to find what meshes are not impacted by the light.
  10454. * Inactive if 0
  10455. */
  10456. excludeWithLayerMask: number;
  10457. private _includeOnlyWithLayerMask;
  10458. /**
  10459. * Gets the layer id use to find what meshes are impacted by the light.
  10460. * Inactive if 0
  10461. */
  10462. /**
  10463. * Sets the layer id use to find what meshes are impacted by the light.
  10464. * Inactive if 0
  10465. */
  10466. includeOnlyWithLayerMask: number;
  10467. private _lightmapMode;
  10468. /**
  10469. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10470. */
  10471. /**
  10472. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10473. */
  10474. lightmapMode: number;
  10475. /**
  10476. * Shadow generator associted to the light.
  10477. * @hidden Internal use only.
  10478. */
  10479. _shadowGenerator: Nullable<IShadowGenerator>;
  10480. /**
  10481. * @hidden Internal use only.
  10482. */
  10483. _excludedMeshesIds: string[];
  10484. /**
  10485. * @hidden Internal use only.
  10486. */
  10487. _includedOnlyMeshesIds: string[];
  10488. /**
  10489. * The current light unifom buffer.
  10490. * @hidden Internal use only.
  10491. */
  10492. _uniformBuffer: UniformBuffer;
  10493. /**
  10494. * Creates a Light object in the scene.
  10495. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10496. * @param name The firendly name of the light
  10497. * @param scene The scene the light belongs too
  10498. */
  10499. constructor(name: string, scene: Scene);
  10500. protected abstract _buildUniformLayout(): void;
  10501. /**
  10502. * Sets the passed Effect "effect" with the Light information.
  10503. * @param effect The effect to update
  10504. * @param lightIndex The index of the light in the effect to update
  10505. * @returns The light
  10506. */
  10507. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10508. /**
  10509. * Returns the string "Light".
  10510. * @returns the class name
  10511. */
  10512. getClassName(): string;
  10513. /** @hidden */
  10514. readonly _isLight: boolean;
  10515. /**
  10516. * Converts the light information to a readable string for debug purpose.
  10517. * @param fullDetails Supports for multiple levels of logging within scene loading
  10518. * @returns the human readable light info
  10519. */
  10520. toString(fullDetails?: boolean): string;
  10521. /** @hidden */
  10522. protected _syncParentEnabledState(): void;
  10523. /**
  10524. * Set the enabled state of this node.
  10525. * @param value - the new enabled state
  10526. */
  10527. setEnabled(value: boolean): void;
  10528. /**
  10529. * Returns the Light associated shadow generator if any.
  10530. * @return the associated shadow generator.
  10531. */
  10532. getShadowGenerator(): Nullable<IShadowGenerator>;
  10533. /**
  10534. * Returns a Vector3, the absolute light position in the World.
  10535. * @returns the world space position of the light
  10536. */
  10537. getAbsolutePosition(): Vector3;
  10538. /**
  10539. * Specifies if the light will affect the passed mesh.
  10540. * @param mesh The mesh to test against the light
  10541. * @return true the mesh is affected otherwise, false.
  10542. */
  10543. canAffectMesh(mesh: AbstractMesh): boolean;
  10544. /**
  10545. * Sort function to order lights for rendering.
  10546. * @param a First Light object to compare to second.
  10547. * @param b Second Light object to compare first.
  10548. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10549. */
  10550. static CompareLightsPriority(a: Light, b: Light): number;
  10551. /**
  10552. * Releases resources associated with this node.
  10553. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10554. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10555. */
  10556. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10557. /**
  10558. * Returns the light type ID (integer).
  10559. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10560. */
  10561. getTypeID(): number;
  10562. /**
  10563. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10564. * @returns the scaled intensity in intensity mode unit
  10565. */
  10566. getScaledIntensity(): number;
  10567. /**
  10568. * Returns a new Light object, named "name", from the current one.
  10569. * @param name The name of the cloned light
  10570. * @returns the new created light
  10571. */
  10572. clone(name: string): Nullable<Light>;
  10573. /**
  10574. * Serializes the current light into a Serialization object.
  10575. * @returns the serialized object.
  10576. */
  10577. serialize(): any;
  10578. /**
  10579. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10580. * This new light is named "name" and added to the passed scene.
  10581. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10582. * @param name The friendly name of the light
  10583. * @param scene The scene the new light will belong to
  10584. * @returns the constructor function
  10585. */
  10586. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10587. /**
  10588. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10589. * @param parsedLight The JSON representation of the light
  10590. * @param scene The scene to create the parsed light in
  10591. * @returns the created light after parsing
  10592. */
  10593. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10594. private _hookArrayForExcluded;
  10595. private _hookArrayForIncludedOnly;
  10596. private _resyncMeshes;
  10597. /**
  10598. * Forces the meshes to update their light related information in their rendering used effects
  10599. * @hidden Internal Use Only
  10600. */
  10601. _markMeshesAsLightDirty(): void;
  10602. /**
  10603. * Recomputes the cached photometric scale if needed.
  10604. */
  10605. private _computePhotometricScale;
  10606. /**
  10607. * Returns the Photometric Scale according to the light type and intensity mode.
  10608. */
  10609. private _getPhotometricScale;
  10610. /**
  10611. * Reorder the light in the scene according to their defined priority.
  10612. * @hidden Internal Use Only
  10613. */
  10614. _reorderLightsInScene(): void;
  10615. /**
  10616. * Prepares the list of defines specific to the light type.
  10617. * @param defines the list of defines
  10618. * @param lightIndex defines the index of the light for the effect
  10619. */
  10620. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10621. }
  10622. }
  10623. declare module "babylonjs/Actions/action" {
  10624. import { Observable } from "babylonjs/Misc/observable";
  10625. import { Condition } from "babylonjs/Actions/condition";
  10626. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10627. import { ActionManager } from "babylonjs/Actions/actionManager";
  10628. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10629. /**
  10630. * Interface used to define Action
  10631. */
  10632. export interface IAction {
  10633. /**
  10634. * Trigger for the action
  10635. */
  10636. trigger: number;
  10637. /** Options of the trigger */
  10638. triggerOptions: any;
  10639. /**
  10640. * Gets the trigger parameters
  10641. * @returns the trigger parameters
  10642. */
  10643. getTriggerParameter(): any;
  10644. /**
  10645. * Internal only - executes current action event
  10646. * @hidden
  10647. */
  10648. _executeCurrent(evt?: ActionEvent): void;
  10649. /**
  10650. * Serialize placeholder for child classes
  10651. * @param parent of child
  10652. * @returns the serialized object
  10653. */
  10654. serialize(parent: any): any;
  10655. /**
  10656. * Internal only
  10657. * @hidden
  10658. */
  10659. _prepare(): void;
  10660. /**
  10661. * Internal only - manager for action
  10662. * @hidden
  10663. */
  10664. _actionManager: AbstractActionManager;
  10665. }
  10666. /**
  10667. * The action to be carried out following a trigger
  10668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10669. */
  10670. export class Action implements IAction {
  10671. /** the trigger, with or without parameters, for the action */
  10672. triggerOptions: any;
  10673. /**
  10674. * Trigger for the action
  10675. */
  10676. trigger: number;
  10677. /**
  10678. * Internal only - manager for action
  10679. * @hidden
  10680. */
  10681. _actionManager: ActionManager;
  10682. private _nextActiveAction;
  10683. private _child;
  10684. private _condition?;
  10685. private _triggerParameter;
  10686. /**
  10687. * An event triggered prior to action being executed.
  10688. */
  10689. onBeforeExecuteObservable: Observable<Action>;
  10690. /**
  10691. * Creates a new Action
  10692. * @param triggerOptions the trigger, with or without parameters, for the action
  10693. * @param condition an optional determinant of action
  10694. */
  10695. constructor(
  10696. /** the trigger, with or without parameters, for the action */
  10697. triggerOptions: any, condition?: Condition);
  10698. /**
  10699. * Internal only
  10700. * @hidden
  10701. */
  10702. _prepare(): void;
  10703. /**
  10704. * Gets the trigger parameters
  10705. * @returns the trigger parameters
  10706. */
  10707. getTriggerParameter(): any;
  10708. /**
  10709. * Internal only - executes current action event
  10710. * @hidden
  10711. */
  10712. _executeCurrent(evt?: ActionEvent): void;
  10713. /**
  10714. * Execute placeholder for child classes
  10715. * @param evt optional action event
  10716. */
  10717. execute(evt?: ActionEvent): void;
  10718. /**
  10719. * Skips to next active action
  10720. */
  10721. skipToNextActiveAction(): void;
  10722. /**
  10723. * Adds action to chain of actions, may be a DoNothingAction
  10724. * @param action defines the next action to execute
  10725. * @returns The action passed in
  10726. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10727. */
  10728. then(action: Action): Action;
  10729. /**
  10730. * Internal only
  10731. * @hidden
  10732. */
  10733. _getProperty(propertyPath: string): string;
  10734. /**
  10735. * Internal only
  10736. * @hidden
  10737. */
  10738. _getEffectiveTarget(target: any, propertyPath: string): any;
  10739. /**
  10740. * Serialize placeholder for child classes
  10741. * @param parent of child
  10742. * @returns the serialized object
  10743. */
  10744. serialize(parent: any): any;
  10745. /**
  10746. * Internal only called by serialize
  10747. * @hidden
  10748. */
  10749. protected _serialize(serializedAction: any, parent?: any): any;
  10750. /**
  10751. * Internal only
  10752. * @hidden
  10753. */
  10754. static _SerializeValueAsString: (value: any) => string;
  10755. /**
  10756. * Internal only
  10757. * @hidden
  10758. */
  10759. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10760. name: string;
  10761. targetType: string;
  10762. value: string;
  10763. };
  10764. }
  10765. }
  10766. declare module "babylonjs/Actions/condition" {
  10767. import { ActionManager } from "babylonjs/Actions/actionManager";
  10768. /**
  10769. * A Condition applied to an Action
  10770. */
  10771. export class Condition {
  10772. /**
  10773. * Internal only - manager for action
  10774. * @hidden
  10775. */
  10776. _actionManager: ActionManager;
  10777. /**
  10778. * Internal only
  10779. * @hidden
  10780. */
  10781. _evaluationId: number;
  10782. /**
  10783. * Internal only
  10784. * @hidden
  10785. */
  10786. _currentResult: boolean;
  10787. /**
  10788. * Creates a new Condition
  10789. * @param actionManager the manager of the action the condition is applied to
  10790. */
  10791. constructor(actionManager: ActionManager);
  10792. /**
  10793. * Check if the current condition is valid
  10794. * @returns a boolean
  10795. */
  10796. isValid(): boolean;
  10797. /**
  10798. * Internal only
  10799. * @hidden
  10800. */
  10801. _getProperty(propertyPath: string): string;
  10802. /**
  10803. * Internal only
  10804. * @hidden
  10805. */
  10806. _getEffectiveTarget(target: any, propertyPath: string): any;
  10807. /**
  10808. * Serialize placeholder for child classes
  10809. * @returns the serialized object
  10810. */
  10811. serialize(): any;
  10812. /**
  10813. * Internal only
  10814. * @hidden
  10815. */
  10816. protected _serialize(serializedCondition: any): any;
  10817. }
  10818. /**
  10819. * Defines specific conditional operators as extensions of Condition
  10820. */
  10821. export class ValueCondition extends Condition {
  10822. /** path to specify the property of the target the conditional operator uses */
  10823. propertyPath: string;
  10824. /** the value compared by the conditional operator against the current value of the property */
  10825. value: any;
  10826. /** the conditional operator, default ValueCondition.IsEqual */
  10827. operator: number;
  10828. /**
  10829. * Internal only
  10830. * @hidden
  10831. */
  10832. private static _IsEqual;
  10833. /**
  10834. * Internal only
  10835. * @hidden
  10836. */
  10837. private static _IsDifferent;
  10838. /**
  10839. * Internal only
  10840. * @hidden
  10841. */
  10842. private static _IsGreater;
  10843. /**
  10844. * Internal only
  10845. * @hidden
  10846. */
  10847. private static _IsLesser;
  10848. /**
  10849. * returns the number for IsEqual
  10850. */
  10851. static readonly IsEqual: number;
  10852. /**
  10853. * Returns the number for IsDifferent
  10854. */
  10855. static readonly IsDifferent: number;
  10856. /**
  10857. * Returns the number for IsGreater
  10858. */
  10859. static readonly IsGreater: number;
  10860. /**
  10861. * Returns the number for IsLesser
  10862. */
  10863. static readonly IsLesser: number;
  10864. /**
  10865. * Internal only The action manager for the condition
  10866. * @hidden
  10867. */
  10868. _actionManager: ActionManager;
  10869. /**
  10870. * Internal only
  10871. * @hidden
  10872. */
  10873. private _target;
  10874. /**
  10875. * Internal only
  10876. * @hidden
  10877. */
  10878. private _effectiveTarget;
  10879. /**
  10880. * Internal only
  10881. * @hidden
  10882. */
  10883. private _property;
  10884. /**
  10885. * Creates a new ValueCondition
  10886. * @param actionManager manager for the action the condition applies to
  10887. * @param target for the action
  10888. * @param propertyPath path to specify the property of the target the conditional operator uses
  10889. * @param value the value compared by the conditional operator against the current value of the property
  10890. * @param operator the conditional operator, default ValueCondition.IsEqual
  10891. */
  10892. constructor(actionManager: ActionManager, target: any,
  10893. /** path to specify the property of the target the conditional operator uses */
  10894. propertyPath: string,
  10895. /** the value compared by the conditional operator against the current value of the property */
  10896. value: any,
  10897. /** the conditional operator, default ValueCondition.IsEqual */
  10898. operator?: number);
  10899. /**
  10900. * Compares the given value with the property value for the specified conditional operator
  10901. * @returns the result of the comparison
  10902. */
  10903. isValid(): boolean;
  10904. /**
  10905. * Serialize the ValueCondition into a JSON compatible object
  10906. * @returns serialization object
  10907. */
  10908. serialize(): any;
  10909. /**
  10910. * Gets the name of the conditional operator for the ValueCondition
  10911. * @param operator the conditional operator
  10912. * @returns the name
  10913. */
  10914. static GetOperatorName(operator: number): string;
  10915. }
  10916. /**
  10917. * Defines a predicate condition as an extension of Condition
  10918. */
  10919. export class PredicateCondition extends Condition {
  10920. /** defines the predicate function used to validate the condition */
  10921. predicate: () => boolean;
  10922. /**
  10923. * Internal only - manager for action
  10924. * @hidden
  10925. */
  10926. _actionManager: ActionManager;
  10927. /**
  10928. * Creates a new PredicateCondition
  10929. * @param actionManager manager for the action the condition applies to
  10930. * @param predicate defines the predicate function used to validate the condition
  10931. */
  10932. constructor(actionManager: ActionManager,
  10933. /** defines the predicate function used to validate the condition */
  10934. predicate: () => boolean);
  10935. /**
  10936. * @returns the validity of the predicate condition
  10937. */
  10938. isValid(): boolean;
  10939. }
  10940. /**
  10941. * Defines a state condition as an extension of Condition
  10942. */
  10943. export class StateCondition extends Condition {
  10944. /** Value to compare with target state */
  10945. value: string;
  10946. /**
  10947. * Internal only - manager for action
  10948. * @hidden
  10949. */
  10950. _actionManager: ActionManager;
  10951. /**
  10952. * Internal only
  10953. * @hidden
  10954. */
  10955. private _target;
  10956. /**
  10957. * Creates a new StateCondition
  10958. * @param actionManager manager for the action the condition applies to
  10959. * @param target of the condition
  10960. * @param value to compare with target state
  10961. */
  10962. constructor(actionManager: ActionManager, target: any,
  10963. /** Value to compare with target state */
  10964. value: string);
  10965. /**
  10966. * Gets a boolean indicating if the current condition is met
  10967. * @returns the validity of the state
  10968. */
  10969. isValid(): boolean;
  10970. /**
  10971. * Serialize the StateCondition into a JSON compatible object
  10972. * @returns serialization object
  10973. */
  10974. serialize(): any;
  10975. }
  10976. }
  10977. declare module "babylonjs/Actions/directActions" {
  10978. import { Action } from "babylonjs/Actions/action";
  10979. import { Condition } from "babylonjs/Actions/condition";
  10980. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10981. /**
  10982. * This defines an action responsible to toggle a boolean once triggered.
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10984. */
  10985. export class SwitchBooleanAction extends Action {
  10986. /**
  10987. * The path to the boolean property in the target object
  10988. */
  10989. propertyPath: string;
  10990. private _target;
  10991. private _effectiveTarget;
  10992. private _property;
  10993. /**
  10994. * Instantiate the action
  10995. * @param triggerOptions defines the trigger options
  10996. * @param target defines the object containing the boolean
  10997. * @param propertyPath defines the path to the boolean property in the target object
  10998. * @param condition defines the trigger related conditions
  10999. */
  11000. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11001. /** @hidden */
  11002. _prepare(): void;
  11003. /**
  11004. * Execute the action toggle the boolean value.
  11005. */
  11006. execute(): void;
  11007. /**
  11008. * Serializes the actions and its related information.
  11009. * @param parent defines the object to serialize in
  11010. * @returns the serialized object
  11011. */
  11012. serialize(parent: any): any;
  11013. }
  11014. /**
  11015. * This defines an action responsible to set a the state field of the target
  11016. * to a desired value once triggered.
  11017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11018. */
  11019. export class SetStateAction extends Action {
  11020. /**
  11021. * The value to store in the state field.
  11022. */
  11023. value: string;
  11024. private _target;
  11025. /**
  11026. * Instantiate the action
  11027. * @param triggerOptions defines the trigger options
  11028. * @param target defines the object containing the state property
  11029. * @param value defines the value to store in the state field
  11030. * @param condition defines the trigger related conditions
  11031. */
  11032. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11033. /**
  11034. * Execute the action and store the value on the target state property.
  11035. */
  11036. execute(): void;
  11037. /**
  11038. * Serializes the actions and its related information.
  11039. * @param parent defines the object to serialize in
  11040. * @returns the serialized object
  11041. */
  11042. serialize(parent: any): any;
  11043. }
  11044. /**
  11045. * This defines an action responsible to set a property of the target
  11046. * to a desired value once triggered.
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11048. */
  11049. export class SetValueAction extends Action {
  11050. /**
  11051. * The path of the property to set in the target.
  11052. */
  11053. propertyPath: string;
  11054. /**
  11055. * The value to set in the property
  11056. */
  11057. value: any;
  11058. private _target;
  11059. private _effectiveTarget;
  11060. private _property;
  11061. /**
  11062. * Instantiate the action
  11063. * @param triggerOptions defines the trigger options
  11064. * @param target defines the object containing the property
  11065. * @param propertyPath defines the path of the property to set in the target
  11066. * @param value defines the value to set in the property
  11067. * @param condition defines the trigger related conditions
  11068. */
  11069. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11070. /** @hidden */
  11071. _prepare(): void;
  11072. /**
  11073. * Execute the action and set the targetted property to the desired value.
  11074. */
  11075. execute(): void;
  11076. /**
  11077. * Serializes the actions and its related information.
  11078. * @param parent defines the object to serialize in
  11079. * @returns the serialized object
  11080. */
  11081. serialize(parent: any): any;
  11082. }
  11083. /**
  11084. * This defines an action responsible to increment the target value
  11085. * to a desired value once triggered.
  11086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11087. */
  11088. export class IncrementValueAction extends Action {
  11089. /**
  11090. * The path of the property to increment in the target.
  11091. */
  11092. propertyPath: string;
  11093. /**
  11094. * The value we should increment the property by.
  11095. */
  11096. value: any;
  11097. private _target;
  11098. private _effectiveTarget;
  11099. private _property;
  11100. /**
  11101. * Instantiate the action
  11102. * @param triggerOptions defines the trigger options
  11103. * @param target defines the object containing the property
  11104. * @param propertyPath defines the path of the property to increment in the target
  11105. * @param value defines the value value we should increment the property by
  11106. * @param condition defines the trigger related conditions
  11107. */
  11108. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11109. /** @hidden */
  11110. _prepare(): void;
  11111. /**
  11112. * Execute the action and increment the target of the value amount.
  11113. */
  11114. execute(): void;
  11115. /**
  11116. * Serializes the actions and its related information.
  11117. * @param parent defines the object to serialize in
  11118. * @returns the serialized object
  11119. */
  11120. serialize(parent: any): any;
  11121. }
  11122. /**
  11123. * This defines an action responsible to start an animation once triggered.
  11124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11125. */
  11126. export class PlayAnimationAction extends Action {
  11127. /**
  11128. * Where the animation should start (animation frame)
  11129. */
  11130. from: number;
  11131. /**
  11132. * Where the animation should stop (animation frame)
  11133. */
  11134. to: number;
  11135. /**
  11136. * Define if the animation should loop or stop after the first play.
  11137. */
  11138. loop?: boolean;
  11139. private _target;
  11140. /**
  11141. * Instantiate the action
  11142. * @param triggerOptions defines the trigger options
  11143. * @param target defines the target animation or animation name
  11144. * @param from defines from where the animation should start (animation frame)
  11145. * @param end defines where the animation should stop (animation frame)
  11146. * @param loop defines if the animation should loop or stop after the first play
  11147. * @param condition defines the trigger related conditions
  11148. */
  11149. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11150. /** @hidden */
  11151. _prepare(): void;
  11152. /**
  11153. * Execute the action and play the animation.
  11154. */
  11155. execute(): void;
  11156. /**
  11157. * Serializes the actions and its related information.
  11158. * @param parent defines the object to serialize in
  11159. * @returns the serialized object
  11160. */
  11161. serialize(parent: any): any;
  11162. }
  11163. /**
  11164. * This defines an action responsible to stop an animation once triggered.
  11165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11166. */
  11167. export class StopAnimationAction extends Action {
  11168. private _target;
  11169. /**
  11170. * Instantiate the action
  11171. * @param triggerOptions defines the trigger options
  11172. * @param target defines the target animation or animation name
  11173. * @param condition defines the trigger related conditions
  11174. */
  11175. constructor(triggerOptions: any, target: any, condition?: Condition);
  11176. /** @hidden */
  11177. _prepare(): void;
  11178. /**
  11179. * Execute the action and stop the animation.
  11180. */
  11181. execute(): void;
  11182. /**
  11183. * Serializes the actions and its related information.
  11184. * @param parent defines the object to serialize in
  11185. * @returns the serialized object
  11186. */
  11187. serialize(parent: any): any;
  11188. }
  11189. /**
  11190. * This defines an action responsible that does nothing once triggered.
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11192. */
  11193. export class DoNothingAction extends Action {
  11194. /**
  11195. * Instantiate the action
  11196. * @param triggerOptions defines the trigger options
  11197. * @param condition defines the trigger related conditions
  11198. */
  11199. constructor(triggerOptions?: any, condition?: Condition);
  11200. /**
  11201. * Execute the action and do nothing.
  11202. */
  11203. execute(): void;
  11204. /**
  11205. * Serializes the actions and its related information.
  11206. * @param parent defines the object to serialize in
  11207. * @returns the serialized object
  11208. */
  11209. serialize(parent: any): any;
  11210. }
  11211. /**
  11212. * This defines an action responsible to trigger several actions once triggered.
  11213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11214. */
  11215. export class CombineAction extends Action {
  11216. /**
  11217. * The list of aggregated animations to run.
  11218. */
  11219. children: Action[];
  11220. /**
  11221. * Instantiate the action
  11222. * @param triggerOptions defines the trigger options
  11223. * @param children defines the list of aggregated animations to run
  11224. * @param condition defines the trigger related conditions
  11225. */
  11226. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11227. /** @hidden */
  11228. _prepare(): void;
  11229. /**
  11230. * Execute the action and executes all the aggregated actions.
  11231. */
  11232. execute(evt: ActionEvent): void;
  11233. /**
  11234. * Serializes the actions and its related information.
  11235. * @param parent defines the object to serialize in
  11236. * @returns the serialized object
  11237. */
  11238. serialize(parent: any): any;
  11239. }
  11240. /**
  11241. * This defines an action responsible to run code (external event) once triggered.
  11242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11243. */
  11244. export class ExecuteCodeAction extends Action {
  11245. /**
  11246. * The callback function to run.
  11247. */
  11248. func: (evt: ActionEvent) => void;
  11249. /**
  11250. * Instantiate the action
  11251. * @param triggerOptions defines the trigger options
  11252. * @param func defines the callback function to run
  11253. * @param condition defines the trigger related conditions
  11254. */
  11255. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11256. /**
  11257. * Execute the action and run the attached code.
  11258. */
  11259. execute(evt: ActionEvent): void;
  11260. }
  11261. /**
  11262. * This defines an action responsible to set the parent property of the target once triggered.
  11263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11264. */
  11265. export class SetParentAction extends Action {
  11266. private _parent;
  11267. private _target;
  11268. /**
  11269. * Instantiate the action
  11270. * @param triggerOptions defines the trigger options
  11271. * @param target defines the target containing the parent property
  11272. * @param parent defines from where the animation should start (animation frame)
  11273. * @param condition defines the trigger related conditions
  11274. */
  11275. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11276. /** @hidden */
  11277. _prepare(): void;
  11278. /**
  11279. * Execute the action and set the parent property.
  11280. */
  11281. execute(): void;
  11282. /**
  11283. * Serializes the actions and its related information.
  11284. * @param parent defines the object to serialize in
  11285. * @returns the serialized object
  11286. */
  11287. serialize(parent: any): any;
  11288. }
  11289. }
  11290. declare module "babylonjs/Actions/actionManager" {
  11291. import { Nullable } from "babylonjs/types";
  11292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11293. import { Scene } from "babylonjs/scene";
  11294. import { IAction } from "babylonjs/Actions/action";
  11295. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11296. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11297. /**
  11298. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11299. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11301. */
  11302. export class ActionManager extends AbstractActionManager {
  11303. /**
  11304. * Nothing
  11305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11306. */
  11307. static readonly NothingTrigger: number;
  11308. /**
  11309. * On pick
  11310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11311. */
  11312. static readonly OnPickTrigger: number;
  11313. /**
  11314. * On left pick
  11315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11316. */
  11317. static readonly OnLeftPickTrigger: number;
  11318. /**
  11319. * On right pick
  11320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11321. */
  11322. static readonly OnRightPickTrigger: number;
  11323. /**
  11324. * On center pick
  11325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11326. */
  11327. static readonly OnCenterPickTrigger: number;
  11328. /**
  11329. * On pick down
  11330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11331. */
  11332. static readonly OnPickDownTrigger: number;
  11333. /**
  11334. * On double pick
  11335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11336. */
  11337. static readonly OnDoublePickTrigger: number;
  11338. /**
  11339. * On pick up
  11340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11341. */
  11342. static readonly OnPickUpTrigger: number;
  11343. /**
  11344. * On pick out.
  11345. * This trigger will only be raised if you also declared a OnPickDown
  11346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11347. */
  11348. static readonly OnPickOutTrigger: number;
  11349. /**
  11350. * On long press
  11351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11352. */
  11353. static readonly OnLongPressTrigger: number;
  11354. /**
  11355. * On pointer over
  11356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11357. */
  11358. static readonly OnPointerOverTrigger: number;
  11359. /**
  11360. * On pointer out
  11361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11362. */
  11363. static readonly OnPointerOutTrigger: number;
  11364. /**
  11365. * On every frame
  11366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11367. */
  11368. static readonly OnEveryFrameTrigger: number;
  11369. /**
  11370. * On intersection enter
  11371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11372. */
  11373. static readonly OnIntersectionEnterTrigger: number;
  11374. /**
  11375. * On intersection exit
  11376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11377. */
  11378. static readonly OnIntersectionExitTrigger: number;
  11379. /**
  11380. * On key down
  11381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11382. */
  11383. static readonly OnKeyDownTrigger: number;
  11384. /**
  11385. * On key up
  11386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11387. */
  11388. static readonly OnKeyUpTrigger: number;
  11389. private _scene;
  11390. /**
  11391. * Creates a new action manager
  11392. * @param scene defines the hosting scene
  11393. */
  11394. constructor(scene: Scene);
  11395. /**
  11396. * Releases all associated resources
  11397. */
  11398. dispose(): void;
  11399. /**
  11400. * Gets hosting scene
  11401. * @returns the hosting scene
  11402. */
  11403. getScene(): Scene;
  11404. /**
  11405. * Does this action manager handles actions of any of the given triggers
  11406. * @param triggers defines the triggers to be tested
  11407. * @return a boolean indicating whether one (or more) of the triggers is handled
  11408. */
  11409. hasSpecificTriggers(triggers: number[]): boolean;
  11410. /**
  11411. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11412. * speed.
  11413. * @param triggerA defines the trigger to be tested
  11414. * @param triggerB defines the trigger to be tested
  11415. * @return a boolean indicating whether one (or more) of the triggers is handled
  11416. */
  11417. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11418. /**
  11419. * Does this action manager handles actions of a given trigger
  11420. * @param trigger defines the trigger to be tested
  11421. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11422. * @return whether the trigger is handled
  11423. */
  11424. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11425. /**
  11426. * Does this action manager has pointer triggers
  11427. */
  11428. readonly hasPointerTriggers: boolean;
  11429. /**
  11430. * Does this action manager has pick triggers
  11431. */
  11432. readonly hasPickTriggers: boolean;
  11433. /**
  11434. * Registers an action to this action manager
  11435. * @param action defines the action to be registered
  11436. * @return the action amended (prepared) after registration
  11437. */
  11438. registerAction(action: IAction): Nullable<IAction>;
  11439. /**
  11440. * Unregisters an action to this action manager
  11441. * @param action defines the action to be unregistered
  11442. * @return a boolean indicating whether the action has been unregistered
  11443. */
  11444. unregisterAction(action: IAction): Boolean;
  11445. /**
  11446. * Process a specific trigger
  11447. * @param trigger defines the trigger to process
  11448. * @param evt defines the event details to be processed
  11449. */
  11450. processTrigger(trigger: number, evt?: IActionEvent): void;
  11451. /** @hidden */
  11452. _getEffectiveTarget(target: any, propertyPath: string): any;
  11453. /** @hidden */
  11454. _getProperty(propertyPath: string): string;
  11455. /**
  11456. * Serialize this manager to a JSON object
  11457. * @param name defines the property name to store this manager
  11458. * @returns a JSON representation of this manager
  11459. */
  11460. serialize(name: string): any;
  11461. /**
  11462. * Creates a new ActionManager from a JSON data
  11463. * @param parsedActions defines the JSON data to read from
  11464. * @param object defines the hosting mesh
  11465. * @param scene defines the hosting scene
  11466. */
  11467. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11468. /**
  11469. * Get a trigger name by index
  11470. * @param trigger defines the trigger index
  11471. * @returns a trigger name
  11472. */
  11473. static GetTriggerName(trigger: number): string;
  11474. }
  11475. }
  11476. declare module "babylonjs/Culling/ray" {
  11477. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11478. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11480. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11481. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11482. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11483. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11484. /**
  11485. * Class representing a ray with position and direction
  11486. */
  11487. export class Ray {
  11488. /** origin point */
  11489. origin: Vector3;
  11490. /** direction */
  11491. direction: Vector3;
  11492. /** length of the ray */
  11493. length: number;
  11494. private static readonly TmpVector3;
  11495. private _tmpRay;
  11496. /**
  11497. * Creates a new ray
  11498. * @param origin origin point
  11499. * @param direction direction
  11500. * @param length length of the ray
  11501. */
  11502. constructor(
  11503. /** origin point */
  11504. origin: Vector3,
  11505. /** direction */
  11506. direction: Vector3,
  11507. /** length of the ray */
  11508. length?: number);
  11509. /**
  11510. * Checks if the ray intersects a box
  11511. * @param minimum bound of the box
  11512. * @param maximum bound of the box
  11513. * @param intersectionTreshold extra extend to be added to the box in all direction
  11514. * @returns if the box was hit
  11515. */
  11516. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11517. /**
  11518. * Checks if the ray intersects a box
  11519. * @param box the bounding box to check
  11520. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11521. * @returns if the box was hit
  11522. */
  11523. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11524. /**
  11525. * If the ray hits a sphere
  11526. * @param sphere the bounding sphere to check
  11527. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11528. * @returns true if it hits the sphere
  11529. */
  11530. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11531. /**
  11532. * If the ray hits a triange
  11533. * @param vertex0 triangle vertex
  11534. * @param vertex1 triangle vertex
  11535. * @param vertex2 triangle vertex
  11536. * @returns intersection information if hit
  11537. */
  11538. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11539. /**
  11540. * Checks if ray intersects a plane
  11541. * @param plane the plane to check
  11542. * @returns the distance away it was hit
  11543. */
  11544. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11545. /**
  11546. * Checks if ray intersects a mesh
  11547. * @param mesh the mesh to check
  11548. * @param fastCheck if only the bounding box should checked
  11549. * @returns picking info of the intersecton
  11550. */
  11551. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11552. /**
  11553. * Checks if ray intersects a mesh
  11554. * @param meshes the meshes to check
  11555. * @param fastCheck if only the bounding box should checked
  11556. * @param results array to store result in
  11557. * @returns Array of picking infos
  11558. */
  11559. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11560. private _comparePickingInfo;
  11561. private static smallnum;
  11562. private static rayl;
  11563. /**
  11564. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11565. * @param sega the first point of the segment to test the intersection against
  11566. * @param segb the second point of the segment to test the intersection against
  11567. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11568. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11569. */
  11570. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11571. /**
  11572. * Update the ray from viewport position
  11573. * @param x position
  11574. * @param y y position
  11575. * @param viewportWidth viewport width
  11576. * @param viewportHeight viewport height
  11577. * @param world world matrix
  11578. * @param view view matrix
  11579. * @param projection projection matrix
  11580. * @returns this ray updated
  11581. */
  11582. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11583. /**
  11584. * Creates a ray with origin and direction of 0,0,0
  11585. * @returns the new ray
  11586. */
  11587. static Zero(): Ray;
  11588. /**
  11589. * Creates a new ray from screen space and viewport
  11590. * @param x position
  11591. * @param y y position
  11592. * @param viewportWidth viewport width
  11593. * @param viewportHeight viewport height
  11594. * @param world world matrix
  11595. * @param view view matrix
  11596. * @param projection projection matrix
  11597. * @returns new ray
  11598. */
  11599. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11600. /**
  11601. * 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
  11602. * transformed to the given world matrix.
  11603. * @param origin The origin point
  11604. * @param end The end point
  11605. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11606. * @returns the new ray
  11607. */
  11608. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11609. /**
  11610. * Transforms a ray by a matrix
  11611. * @param ray ray to transform
  11612. * @param matrix matrix to apply
  11613. * @returns the resulting new ray
  11614. */
  11615. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11616. /**
  11617. * Transforms a ray by a matrix
  11618. * @param ray ray to transform
  11619. * @param matrix matrix to apply
  11620. * @param result ray to store result in
  11621. */
  11622. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11623. /**
  11624. * Unproject a ray from screen space to object space
  11625. * @param sourceX defines the screen space x coordinate to use
  11626. * @param sourceY defines the screen space y coordinate to use
  11627. * @param viewportWidth defines the current width of the viewport
  11628. * @param viewportHeight defines the current height of the viewport
  11629. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11630. * @param view defines the view matrix to use
  11631. * @param projection defines the projection matrix to use
  11632. */
  11633. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11634. }
  11635. /**
  11636. * Type used to define predicate used to select faces when a mesh intersection is detected
  11637. */
  11638. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11639. module "babylonjs/scene" {
  11640. interface Scene {
  11641. /** @hidden */
  11642. _tempPickingRay: Nullable<Ray>;
  11643. /** @hidden */
  11644. _cachedRayForTransform: Ray;
  11645. /** @hidden */
  11646. _pickWithRayInverseMatrix: Matrix;
  11647. /** @hidden */
  11648. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11649. /** @hidden */
  11650. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11651. }
  11652. }
  11653. }
  11654. declare module "babylonjs/sceneComponent" {
  11655. import { Scene } from "babylonjs/scene";
  11656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11657. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11658. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11659. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11660. import { Nullable } from "babylonjs/types";
  11661. import { Camera } from "babylonjs/Cameras/camera";
  11662. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11663. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11664. import { AbstractScene } from "babylonjs/abstractScene";
  11665. /**
  11666. * Groups all the scene component constants in one place to ease maintenance.
  11667. * @hidden
  11668. */
  11669. export class SceneComponentConstants {
  11670. static readonly NAME_EFFECTLAYER: string;
  11671. static readonly NAME_LAYER: string;
  11672. static readonly NAME_LENSFLARESYSTEM: string;
  11673. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11674. static readonly NAME_PARTICLESYSTEM: string;
  11675. static readonly NAME_GAMEPAD: string;
  11676. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11677. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11678. static readonly NAME_DEPTHRENDERER: string;
  11679. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11680. static readonly NAME_SPRITE: string;
  11681. static readonly NAME_OUTLINERENDERER: string;
  11682. static readonly NAME_PROCEDURALTEXTURE: string;
  11683. static readonly NAME_SHADOWGENERATOR: string;
  11684. static readonly NAME_OCTREE: string;
  11685. static readonly NAME_PHYSICSENGINE: string;
  11686. static readonly NAME_AUDIO: string;
  11687. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11688. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11689. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11690. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11691. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11692. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11693. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11694. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11695. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11696. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11697. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11698. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11699. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11700. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11701. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11702. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11703. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11704. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11705. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11706. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11707. static readonly STEP_AFTERRENDER_AUDIO: number;
  11708. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11709. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11710. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11711. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11712. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11713. static readonly STEP_POINTERMOVE_SPRITE: number;
  11714. static readonly STEP_POINTERDOWN_SPRITE: number;
  11715. static readonly STEP_POINTERUP_SPRITE: number;
  11716. }
  11717. /**
  11718. * This represents a scene component.
  11719. *
  11720. * This is used to decouple the dependency the scene is having on the different workloads like
  11721. * layers, post processes...
  11722. */
  11723. export interface ISceneComponent {
  11724. /**
  11725. * The name of the component. Each component must have a unique name.
  11726. */
  11727. name: string;
  11728. /**
  11729. * The scene the component belongs to.
  11730. */
  11731. scene: Scene;
  11732. /**
  11733. * Register the component to one instance of a scene.
  11734. */
  11735. register(): void;
  11736. /**
  11737. * Rebuilds the elements related to this component in case of
  11738. * context lost for instance.
  11739. */
  11740. rebuild(): void;
  11741. /**
  11742. * Disposes the component and the associated ressources.
  11743. */
  11744. dispose(): void;
  11745. }
  11746. /**
  11747. * This represents a SERIALIZABLE scene component.
  11748. *
  11749. * This extends Scene Component to add Serialization methods on top.
  11750. */
  11751. export interface ISceneSerializableComponent extends ISceneComponent {
  11752. /**
  11753. * Adds all the element from the container to the scene
  11754. * @param container the container holding the elements
  11755. */
  11756. addFromContainer(container: AbstractScene): void;
  11757. /**
  11758. * Removes all the elements in the container from the scene
  11759. * @param container contains the elements to remove
  11760. * @param dispose if the removed element should be disposed (default: false)
  11761. */
  11762. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11763. /**
  11764. * Serializes the component data to the specified json object
  11765. * @param serializationObject The object to serialize to
  11766. */
  11767. serialize(serializationObject: any): void;
  11768. }
  11769. /**
  11770. * Strong typing of a Mesh related stage step action
  11771. */
  11772. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11773. /**
  11774. * Strong typing of a Evaluate Sub Mesh related stage step action
  11775. */
  11776. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11777. /**
  11778. * Strong typing of a Active Mesh related stage step action
  11779. */
  11780. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11781. /**
  11782. * Strong typing of a Camera related stage step action
  11783. */
  11784. export type CameraStageAction = (camera: Camera) => void;
  11785. /**
  11786. * Strong typing of a Camera Frame buffer related stage step action
  11787. */
  11788. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11789. /**
  11790. * Strong typing of a Render Target related stage step action
  11791. */
  11792. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11793. /**
  11794. * Strong typing of a RenderingGroup related stage step action
  11795. */
  11796. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11797. /**
  11798. * Strong typing of a Mesh Render related stage step action
  11799. */
  11800. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11801. /**
  11802. * Strong typing of a simple stage step action
  11803. */
  11804. export type SimpleStageAction = () => void;
  11805. /**
  11806. * Strong typing of a render target action.
  11807. */
  11808. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11809. /**
  11810. * Strong typing of a pointer move action.
  11811. */
  11812. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11813. /**
  11814. * Strong typing of a pointer up/down action.
  11815. */
  11816. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11817. /**
  11818. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11819. * @hidden
  11820. */
  11821. export class Stage<T extends Function> extends Array<{
  11822. index: number;
  11823. component: ISceneComponent;
  11824. action: T;
  11825. }> {
  11826. /**
  11827. * Hide ctor from the rest of the world.
  11828. * @param items The items to add.
  11829. */
  11830. private constructor();
  11831. /**
  11832. * Creates a new Stage.
  11833. * @returns A new instance of a Stage
  11834. */
  11835. static Create<T extends Function>(): Stage<T>;
  11836. /**
  11837. * Registers a step in an ordered way in the targeted stage.
  11838. * @param index Defines the position to register the step in
  11839. * @param component Defines the component attached to the step
  11840. * @param action Defines the action to launch during the step
  11841. */
  11842. registerStep(index: number, component: ISceneComponent, action: T): void;
  11843. /**
  11844. * Clears all the steps from the stage.
  11845. */
  11846. clear(): void;
  11847. }
  11848. }
  11849. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11850. import { Nullable } from "babylonjs/types";
  11851. import { Observable } from "babylonjs/Misc/observable";
  11852. import { Scene } from "babylonjs/scene";
  11853. import { Sprite } from "babylonjs/Sprites/sprite";
  11854. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11855. import { Ray } from "babylonjs/Culling/ray";
  11856. import { Camera } from "babylonjs/Cameras/camera";
  11857. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11858. import { ISceneComponent } from "babylonjs/sceneComponent";
  11859. module "babylonjs/scene" {
  11860. interface Scene {
  11861. /** @hidden */
  11862. _pointerOverSprite: Nullable<Sprite>;
  11863. /** @hidden */
  11864. _pickedDownSprite: Nullable<Sprite>;
  11865. /** @hidden */
  11866. _tempSpritePickingRay: Nullable<Ray>;
  11867. /**
  11868. * All of the sprite managers added to this scene
  11869. * @see http://doc.babylonjs.com/babylon101/sprites
  11870. */
  11871. spriteManagers: Array<ISpriteManager>;
  11872. /**
  11873. * An event triggered when sprites rendering is about to start
  11874. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11875. */
  11876. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11877. /**
  11878. * An event triggered when sprites rendering is done
  11879. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11880. */
  11881. onAfterSpritesRenderingObservable: Observable<Scene>;
  11882. /** @hidden */
  11883. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11884. /** Launch a ray to try to pick a sprite in the scene
  11885. * @param x position on screen
  11886. * @param y position on screen
  11887. * @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
  11888. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11889. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11890. * @returns a PickingInfo
  11891. */
  11892. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11893. /** Use the given ray to pick a sprite in the scene
  11894. * @param ray The ray (in world space) to use to pick meshes
  11895. * @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
  11896. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11897. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11898. * @returns a PickingInfo
  11899. */
  11900. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11901. /**
  11902. * Force the sprite under the pointer
  11903. * @param sprite defines the sprite to use
  11904. */
  11905. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11906. /**
  11907. * Gets the sprite under the pointer
  11908. * @returns a Sprite or null if no sprite is under the pointer
  11909. */
  11910. getPointerOverSprite(): Nullable<Sprite>;
  11911. }
  11912. }
  11913. /**
  11914. * Defines the sprite scene component responsible to manage sprites
  11915. * in a given scene.
  11916. */
  11917. export class SpriteSceneComponent implements ISceneComponent {
  11918. /**
  11919. * The component name helpfull to identify the component in the list of scene components.
  11920. */
  11921. readonly name: string;
  11922. /**
  11923. * The scene the component belongs to.
  11924. */
  11925. scene: Scene;
  11926. /** @hidden */
  11927. private _spritePredicate;
  11928. /**
  11929. * Creates a new instance of the component for the given scene
  11930. * @param scene Defines the scene to register the component in
  11931. */
  11932. constructor(scene: Scene);
  11933. /**
  11934. * Registers the component in a given scene
  11935. */
  11936. register(): void;
  11937. /**
  11938. * Rebuilds the elements related to this component in case of
  11939. * context lost for instance.
  11940. */
  11941. rebuild(): void;
  11942. /**
  11943. * Disposes the component and the associated ressources.
  11944. */
  11945. dispose(): void;
  11946. private _pickSpriteButKeepRay;
  11947. private _pointerMove;
  11948. private _pointerDown;
  11949. private _pointerUp;
  11950. }
  11951. }
  11952. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11953. /** @hidden */
  11954. export var fogFragmentDeclaration: {
  11955. name: string;
  11956. shader: string;
  11957. };
  11958. }
  11959. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11960. /** @hidden */
  11961. export var fogFragment: {
  11962. name: string;
  11963. shader: string;
  11964. };
  11965. }
  11966. declare module "babylonjs/Shaders/sprites.fragment" {
  11967. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11968. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11969. /** @hidden */
  11970. export var spritesPixelShader: {
  11971. name: string;
  11972. shader: string;
  11973. };
  11974. }
  11975. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11976. /** @hidden */
  11977. export var fogVertexDeclaration: {
  11978. name: string;
  11979. shader: string;
  11980. };
  11981. }
  11982. declare module "babylonjs/Shaders/sprites.vertex" {
  11983. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11984. /** @hidden */
  11985. export var spritesVertexShader: {
  11986. name: string;
  11987. shader: string;
  11988. };
  11989. }
  11990. declare module "babylonjs/Sprites/spriteManager" {
  11991. import { IDisposable, Scene } from "babylonjs/scene";
  11992. import { Nullable } from "babylonjs/types";
  11993. import { Observable } from "babylonjs/Misc/observable";
  11994. import { Sprite } from "babylonjs/Sprites/sprite";
  11995. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11996. import { Camera } from "babylonjs/Cameras/camera";
  11997. import { Texture } from "babylonjs/Materials/Textures/texture";
  11998. import "babylonjs/Shaders/sprites.fragment";
  11999. import "babylonjs/Shaders/sprites.vertex";
  12000. import { Ray } from "babylonjs/Culling/ray";
  12001. /**
  12002. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12003. */
  12004. export interface ISpriteManager extends IDisposable {
  12005. /**
  12006. * Restricts the camera to viewing objects with the same layerMask.
  12007. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12008. */
  12009. layerMask: number;
  12010. /**
  12011. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12012. */
  12013. isPickable: boolean;
  12014. /**
  12015. * Specifies the rendering group id for this mesh (0 by default)
  12016. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12017. */
  12018. renderingGroupId: number;
  12019. /**
  12020. * Defines the list of sprites managed by the manager.
  12021. */
  12022. sprites: Array<Sprite>;
  12023. /**
  12024. * Tests the intersection of a sprite with a specific ray.
  12025. * @param ray The ray we are sending to test the collision
  12026. * @param camera The camera space we are sending rays in
  12027. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12028. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12029. * @returns picking info or null.
  12030. */
  12031. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12032. /**
  12033. * Renders the list of sprites on screen.
  12034. */
  12035. render(): void;
  12036. }
  12037. /**
  12038. * Class used to manage multiple sprites on the same spritesheet
  12039. * @see http://doc.babylonjs.com/babylon101/sprites
  12040. */
  12041. export class SpriteManager implements ISpriteManager {
  12042. /** defines the manager's name */
  12043. name: string;
  12044. /** Gets the list of sprites */
  12045. sprites: Sprite[];
  12046. /** Gets or sets the rendering group id (0 by default) */
  12047. renderingGroupId: number;
  12048. /** Gets or sets camera layer mask */
  12049. layerMask: number;
  12050. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12051. fogEnabled: boolean;
  12052. /** Gets or sets a boolean indicating if the sprites are pickable */
  12053. isPickable: boolean;
  12054. /** Defines the default width of a cell in the spritesheet */
  12055. cellWidth: number;
  12056. /** Defines the default height of a cell in the spritesheet */
  12057. cellHeight: number;
  12058. /**
  12059. * An event triggered when the manager is disposed.
  12060. */
  12061. onDisposeObservable: Observable<SpriteManager>;
  12062. private _onDisposeObserver;
  12063. /**
  12064. * Callback called when the manager is disposed
  12065. */
  12066. onDispose: () => void;
  12067. private _capacity;
  12068. private _spriteTexture;
  12069. private _epsilon;
  12070. private _scene;
  12071. private _vertexData;
  12072. private _buffer;
  12073. private _vertexBuffers;
  12074. private _indexBuffer;
  12075. private _effectBase;
  12076. private _effectFog;
  12077. /**
  12078. * Gets or sets the spritesheet texture
  12079. */
  12080. texture: Texture;
  12081. /**
  12082. * Creates a new sprite manager
  12083. * @param name defines the manager's name
  12084. * @param imgUrl defines the sprite sheet url
  12085. * @param capacity defines the maximum allowed number of sprites
  12086. * @param cellSize defines the size of a sprite cell
  12087. * @param scene defines the hosting scene
  12088. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12089. * @param samplingMode defines the smapling mode to use with spritesheet
  12090. */
  12091. constructor(
  12092. /** defines the manager's name */
  12093. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12094. private _appendSpriteVertex;
  12095. /**
  12096. * Intersects the sprites with a ray
  12097. * @param ray defines the ray to intersect with
  12098. * @param camera defines the current active camera
  12099. * @param predicate defines a predicate used to select candidate sprites
  12100. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12101. * @returns null if no hit or a PickingInfo
  12102. */
  12103. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12104. /**
  12105. * Render all child sprites
  12106. */
  12107. render(): void;
  12108. /**
  12109. * Release associated resources
  12110. */
  12111. dispose(): void;
  12112. }
  12113. }
  12114. declare module "babylonjs/Sprites/sprite" {
  12115. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12116. import { Nullable } from "babylonjs/types";
  12117. import { ActionManager } from "babylonjs/Actions/actionManager";
  12118. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12119. /**
  12120. * Class used to represent a sprite
  12121. * @see http://doc.babylonjs.com/babylon101/sprites
  12122. */
  12123. export class Sprite {
  12124. /** defines the name */
  12125. name: string;
  12126. /** Gets or sets the current world position */
  12127. position: Vector3;
  12128. /** Gets or sets the main color */
  12129. color: Color4;
  12130. /** Gets or sets the width */
  12131. width: number;
  12132. /** Gets or sets the height */
  12133. height: number;
  12134. /** Gets or sets rotation angle */
  12135. angle: number;
  12136. /** Gets or sets the cell index in the sprite sheet */
  12137. cellIndex: number;
  12138. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12139. invertU: number;
  12140. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12141. invertV: number;
  12142. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12143. disposeWhenFinishedAnimating: boolean;
  12144. /** Gets the list of attached animations */
  12145. animations: Animation[];
  12146. /** Gets or sets a boolean indicating if the sprite can be picked */
  12147. isPickable: boolean;
  12148. /**
  12149. * Gets or sets the associated action manager
  12150. */
  12151. actionManager: Nullable<ActionManager>;
  12152. private _animationStarted;
  12153. private _loopAnimation;
  12154. private _fromIndex;
  12155. private _toIndex;
  12156. private _delay;
  12157. private _direction;
  12158. private _manager;
  12159. private _time;
  12160. private _onAnimationEnd;
  12161. /**
  12162. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12163. */
  12164. isVisible: boolean;
  12165. /**
  12166. * Gets or sets the sprite size
  12167. */
  12168. size: number;
  12169. /**
  12170. * Creates a new Sprite
  12171. * @param name defines the name
  12172. * @param manager defines the manager
  12173. */
  12174. constructor(
  12175. /** defines the name */
  12176. name: string, manager: ISpriteManager);
  12177. /**
  12178. * Starts an animation
  12179. * @param from defines the initial key
  12180. * @param to defines the end key
  12181. * @param loop defines if the animation must loop
  12182. * @param delay defines the start delay (in ms)
  12183. * @param onAnimationEnd defines a callback to call when animation ends
  12184. */
  12185. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12186. /** Stops current animation (if any) */
  12187. stopAnimation(): void;
  12188. /** @hidden */
  12189. _animate(deltaTime: number): void;
  12190. /** Release associated resources */
  12191. dispose(): void;
  12192. }
  12193. }
  12194. declare module "babylonjs/Collisions/pickingInfo" {
  12195. import { Nullable } from "babylonjs/types";
  12196. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12198. import { Sprite } from "babylonjs/Sprites/sprite";
  12199. import { Ray } from "babylonjs/Culling/ray";
  12200. /**
  12201. * Information about the result of picking within a scene
  12202. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12203. */
  12204. export class PickingInfo {
  12205. /** @hidden */
  12206. _pickingUnavailable: boolean;
  12207. /**
  12208. * If the pick collided with an object
  12209. */
  12210. hit: boolean;
  12211. /**
  12212. * Distance away where the pick collided
  12213. */
  12214. distance: number;
  12215. /**
  12216. * The location of pick collision
  12217. */
  12218. pickedPoint: Nullable<Vector3>;
  12219. /**
  12220. * The mesh corresponding the the pick collision
  12221. */
  12222. pickedMesh: Nullable<AbstractMesh>;
  12223. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12224. bu: number;
  12225. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12226. bv: number;
  12227. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12228. faceId: number;
  12229. /** Id of the the submesh that was picked */
  12230. subMeshId: number;
  12231. /** If a sprite was picked, this will be the sprite the pick collided with */
  12232. pickedSprite: Nullable<Sprite>;
  12233. /**
  12234. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12235. */
  12236. originMesh: Nullable<AbstractMesh>;
  12237. /**
  12238. * The ray that was used to perform the picking.
  12239. */
  12240. ray: Nullable<Ray>;
  12241. /**
  12242. * Gets the normal correspodning to the face the pick collided with
  12243. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12244. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12245. * @returns The normal correspodning to the face the pick collided with
  12246. */
  12247. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12248. /**
  12249. * Gets the texture coordinates of where the pick occured
  12250. * @returns the vector containing the coordnates of the texture
  12251. */
  12252. getTextureCoordinates(): Nullable<Vector2>;
  12253. }
  12254. }
  12255. declare module "babylonjs/Events/pointerEvents" {
  12256. import { Nullable } from "babylonjs/types";
  12257. import { Vector2 } from "babylonjs/Maths/math";
  12258. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12259. import { Ray } from "babylonjs/Culling/ray";
  12260. /**
  12261. * Gather the list of pointer event types as constants.
  12262. */
  12263. export class PointerEventTypes {
  12264. /**
  12265. * 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.
  12266. */
  12267. static readonly POINTERDOWN: number;
  12268. /**
  12269. * The pointerup event is fired when a pointer is no longer active.
  12270. */
  12271. static readonly POINTERUP: number;
  12272. /**
  12273. * The pointermove event is fired when a pointer changes coordinates.
  12274. */
  12275. static readonly POINTERMOVE: number;
  12276. /**
  12277. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12278. */
  12279. static readonly POINTERWHEEL: number;
  12280. /**
  12281. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12282. */
  12283. static readonly POINTERPICK: number;
  12284. /**
  12285. * The pointertap event is fired when a the object has been touched and released without drag.
  12286. */
  12287. static readonly POINTERTAP: number;
  12288. /**
  12289. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12290. */
  12291. static readonly POINTERDOUBLETAP: number;
  12292. }
  12293. /**
  12294. * Base class of pointer info types.
  12295. */
  12296. export class PointerInfoBase {
  12297. /**
  12298. * Defines the type of event (PointerEventTypes)
  12299. */
  12300. type: number;
  12301. /**
  12302. * Defines the related dom event
  12303. */
  12304. event: PointerEvent | MouseWheelEvent;
  12305. /**
  12306. * Instantiates the base class of pointers info.
  12307. * @param type Defines the type of event (PointerEventTypes)
  12308. * @param event Defines the related dom event
  12309. */
  12310. constructor(
  12311. /**
  12312. * Defines the type of event (PointerEventTypes)
  12313. */
  12314. type: number,
  12315. /**
  12316. * Defines the related dom event
  12317. */
  12318. event: PointerEvent | MouseWheelEvent);
  12319. }
  12320. /**
  12321. * This class is used to store pointer related info for the onPrePointerObservable event.
  12322. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12323. */
  12324. export class PointerInfoPre extends PointerInfoBase {
  12325. /**
  12326. * Ray from a pointer if availible (eg. 6dof controller)
  12327. */
  12328. ray: Nullable<Ray>;
  12329. /**
  12330. * Defines the local position of the pointer on the canvas.
  12331. */
  12332. localPosition: Vector2;
  12333. /**
  12334. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12335. */
  12336. skipOnPointerObservable: boolean;
  12337. /**
  12338. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12339. * @param type Defines the type of event (PointerEventTypes)
  12340. * @param event Defines the related dom event
  12341. * @param localX Defines the local x coordinates of the pointer when the event occured
  12342. * @param localY Defines the local y coordinates of the pointer when the event occured
  12343. */
  12344. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12345. }
  12346. /**
  12347. * This type contains all the data related to a pointer event in Babylon.js.
  12348. * 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.
  12349. */
  12350. export class PointerInfo extends PointerInfoBase {
  12351. /**
  12352. * Defines the picking info associated to the info (if any)\
  12353. */
  12354. pickInfo: Nullable<PickingInfo>;
  12355. /**
  12356. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12357. * @param type Defines the type of event (PointerEventTypes)
  12358. * @param event Defines the related dom event
  12359. * @param pickInfo Defines the picking info associated to the info (if any)\
  12360. */
  12361. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12362. /**
  12363. * Defines the picking info associated to the info (if any)\
  12364. */
  12365. pickInfo: Nullable<PickingInfo>);
  12366. }
  12367. /**
  12368. * Data relating to a touch event on the screen.
  12369. */
  12370. export interface PointerTouch {
  12371. /**
  12372. * X coordinate of touch.
  12373. */
  12374. x: number;
  12375. /**
  12376. * Y coordinate of touch.
  12377. */
  12378. y: number;
  12379. /**
  12380. * Id of touch. Unique for each finger.
  12381. */
  12382. pointerId: number;
  12383. /**
  12384. * Event type passed from DOM.
  12385. */
  12386. type: any;
  12387. }
  12388. }
  12389. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12390. import { Observable } from "babylonjs/Misc/observable";
  12391. import { Nullable } from "babylonjs/types";
  12392. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12393. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12394. /**
  12395. * Manage the mouse inputs to control the movement of a free camera.
  12396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12397. */
  12398. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12399. /**
  12400. * Define if touch is enabled in the mouse input
  12401. */
  12402. touchEnabled: boolean;
  12403. /**
  12404. * Defines the camera the input is attached to.
  12405. */
  12406. camera: FreeCamera;
  12407. /**
  12408. * Defines the buttons associated with the input to handle camera move.
  12409. */
  12410. buttons: number[];
  12411. /**
  12412. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12413. */
  12414. angularSensibility: number;
  12415. private _pointerInput;
  12416. private _onMouseMove;
  12417. private _observer;
  12418. private previousPosition;
  12419. /**
  12420. * Observable for when a pointer move event occurs containing the move offset
  12421. */
  12422. onPointerMovedObservable: Observable<{
  12423. offsetX: number;
  12424. offsetY: number;
  12425. }>;
  12426. /**
  12427. * @hidden
  12428. * If the camera should be rotated automatically based on pointer movement
  12429. */
  12430. _allowCameraRotation: boolean;
  12431. /**
  12432. * Manage the mouse inputs to control the movement of a free camera.
  12433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12434. * @param touchEnabled Defines if touch is enabled or not
  12435. */
  12436. constructor(
  12437. /**
  12438. * Define if touch is enabled in the mouse input
  12439. */
  12440. touchEnabled?: boolean);
  12441. /**
  12442. * Attach the input controls to a specific dom element to get the input from.
  12443. * @param element Defines the element the controls should be listened from
  12444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12445. */
  12446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12447. /**
  12448. * Called on JS contextmenu event.
  12449. * Override this method to provide functionality.
  12450. */
  12451. protected onContextMenu(evt: PointerEvent): void;
  12452. /**
  12453. * Detach the current controls from the specified dom element.
  12454. * @param element Defines the element to stop listening the inputs from
  12455. */
  12456. detachControl(element: Nullable<HTMLElement>): void;
  12457. /**
  12458. * Gets the class name of the current intput.
  12459. * @returns the class name
  12460. */
  12461. getClassName(): string;
  12462. /**
  12463. * Get the friendly name associated with the input class.
  12464. * @returns the input friendly name
  12465. */
  12466. getSimpleName(): string;
  12467. }
  12468. }
  12469. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12470. import { Nullable } from "babylonjs/types";
  12471. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12472. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12473. /**
  12474. * Manage the touch inputs to control the movement of a free camera.
  12475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12476. */
  12477. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12478. /**
  12479. * Defines the camera the input is attached to.
  12480. */
  12481. camera: FreeCamera;
  12482. /**
  12483. * Defines the touch sensibility for rotation.
  12484. * The higher the faster.
  12485. */
  12486. touchAngularSensibility: number;
  12487. /**
  12488. * Defines the touch sensibility for move.
  12489. * The higher the faster.
  12490. */
  12491. touchMoveSensibility: number;
  12492. private _offsetX;
  12493. private _offsetY;
  12494. private _pointerPressed;
  12495. private _pointerInput;
  12496. private _observer;
  12497. private _onLostFocus;
  12498. /**
  12499. * Attach the input controls to a specific dom element to get the input from.
  12500. * @param element Defines the element the controls should be listened from
  12501. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12502. */
  12503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12504. /**
  12505. * Detach the current controls from the specified dom element.
  12506. * @param element Defines the element to stop listening the inputs from
  12507. */
  12508. detachControl(element: Nullable<HTMLElement>): void;
  12509. /**
  12510. * Update the current camera state depending on the inputs that have been used this frame.
  12511. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12512. */
  12513. checkInputs(): void;
  12514. /**
  12515. * Gets the class name of the current intput.
  12516. * @returns the class name
  12517. */
  12518. getClassName(): string;
  12519. /**
  12520. * Get the friendly name associated with the input class.
  12521. * @returns the input friendly name
  12522. */
  12523. getSimpleName(): string;
  12524. }
  12525. }
  12526. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12527. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12528. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12529. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12530. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12531. import { Nullable } from "babylonjs/types";
  12532. /**
  12533. * Default Inputs manager for the FreeCamera.
  12534. * It groups all the default supported inputs for ease of use.
  12535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12536. */
  12537. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12538. /**
  12539. * @hidden
  12540. */
  12541. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12542. /**
  12543. * @hidden
  12544. */
  12545. _mouseInput: Nullable<FreeCameraMouseInput>;
  12546. /**
  12547. * Instantiates a new FreeCameraInputsManager.
  12548. * @param camera Defines the camera the inputs belong to
  12549. */
  12550. constructor(camera: FreeCamera);
  12551. /**
  12552. * Add keyboard input support to the input manager.
  12553. * @returns the current input manager
  12554. */
  12555. addKeyboard(): FreeCameraInputsManager;
  12556. /**
  12557. * Add mouse input support to the input manager.
  12558. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12559. * @returns the current input manager
  12560. */
  12561. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12562. /**
  12563. * Removes the mouse input support from the manager
  12564. * @returns the current input manager
  12565. */
  12566. removeMouse(): FreeCameraInputsManager;
  12567. /**
  12568. * Add touch input support to the input manager.
  12569. * @returns the current input manager
  12570. */
  12571. addTouch(): FreeCameraInputsManager;
  12572. }
  12573. }
  12574. declare module "babylonjs/Cameras/freeCamera" {
  12575. import { Vector3 } from "babylonjs/Maths/math";
  12576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12577. import { Scene } from "babylonjs/scene";
  12578. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12579. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12580. /**
  12581. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12582. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12583. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12584. */
  12585. export class FreeCamera extends TargetCamera {
  12586. /**
  12587. * Define the collision ellipsoid of the camera.
  12588. * This is helpful to simulate a camera body like the player body around the camera
  12589. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12590. */
  12591. ellipsoid: Vector3;
  12592. /**
  12593. * Define an offset for the position of the ellipsoid around the camera.
  12594. * This can be helpful to determine the center of the body near the gravity center of the body
  12595. * instead of its head.
  12596. */
  12597. ellipsoidOffset: Vector3;
  12598. /**
  12599. * Enable or disable collisions of the camera with the rest of the scene objects.
  12600. */
  12601. checkCollisions: boolean;
  12602. /**
  12603. * Enable or disable gravity on the camera.
  12604. */
  12605. applyGravity: boolean;
  12606. /**
  12607. * Define the input manager associated to the camera.
  12608. */
  12609. inputs: FreeCameraInputsManager;
  12610. /**
  12611. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12612. * Higher values reduce sensitivity.
  12613. */
  12614. /**
  12615. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12616. * Higher values reduce sensitivity.
  12617. */
  12618. angularSensibility: number;
  12619. /**
  12620. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12621. */
  12622. keysUp: number[];
  12623. /**
  12624. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12625. */
  12626. keysDown: number[];
  12627. /**
  12628. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12629. */
  12630. keysLeft: number[];
  12631. /**
  12632. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12633. */
  12634. keysRight: number[];
  12635. /**
  12636. * Event raised when the camera collide with a mesh in the scene.
  12637. */
  12638. onCollide: (collidedMesh: AbstractMesh) => void;
  12639. private _collider;
  12640. private _needMoveForGravity;
  12641. private _oldPosition;
  12642. private _diffPosition;
  12643. private _newPosition;
  12644. /** @hidden */
  12645. _localDirection: Vector3;
  12646. /** @hidden */
  12647. _transformedDirection: Vector3;
  12648. /**
  12649. * Instantiates a Free Camera.
  12650. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12651. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12652. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12653. * @param name Define the name of the camera in the scene
  12654. * @param position Define the start position of the camera in the scene
  12655. * @param scene Define the scene the camera belongs to
  12656. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12657. */
  12658. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12659. /**
  12660. * Attached controls to the current camera.
  12661. * @param element Defines the element the controls should be listened from
  12662. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12663. */
  12664. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12665. /**
  12666. * Detach the current controls from the camera.
  12667. * The camera will stop reacting to inputs.
  12668. * @param element Defines the element to stop listening the inputs from
  12669. */
  12670. detachControl(element: HTMLElement): void;
  12671. private _collisionMask;
  12672. /**
  12673. * Define a collision mask to limit the list of object the camera can collide with
  12674. */
  12675. collisionMask: number;
  12676. /** @hidden */
  12677. _collideWithWorld(displacement: Vector3): void;
  12678. private _onCollisionPositionChange;
  12679. /** @hidden */
  12680. _checkInputs(): void;
  12681. /** @hidden */
  12682. _decideIfNeedsToMove(): boolean;
  12683. /** @hidden */
  12684. _updatePosition(): void;
  12685. /**
  12686. * Destroy the camera and release the current resources hold by it.
  12687. */
  12688. dispose(): void;
  12689. /**
  12690. * Gets the current object class name.
  12691. * @return the class name
  12692. */
  12693. getClassName(): string;
  12694. }
  12695. }
  12696. declare module "babylonjs/Gamepads/gamepad" {
  12697. import { Observable } from "babylonjs/Misc/observable";
  12698. /**
  12699. * Represents a gamepad control stick position
  12700. */
  12701. export class StickValues {
  12702. /**
  12703. * The x component of the control stick
  12704. */
  12705. x: number;
  12706. /**
  12707. * The y component of the control stick
  12708. */
  12709. y: number;
  12710. /**
  12711. * Initializes the gamepad x and y control stick values
  12712. * @param x The x component of the gamepad control stick value
  12713. * @param y The y component of the gamepad control stick value
  12714. */
  12715. constructor(
  12716. /**
  12717. * The x component of the control stick
  12718. */
  12719. x: number,
  12720. /**
  12721. * The y component of the control stick
  12722. */
  12723. y: number);
  12724. }
  12725. /**
  12726. * An interface which manages callbacks for gamepad button changes
  12727. */
  12728. export interface GamepadButtonChanges {
  12729. /**
  12730. * Called when a gamepad has been changed
  12731. */
  12732. changed: boolean;
  12733. /**
  12734. * Called when a gamepad press event has been triggered
  12735. */
  12736. pressChanged: boolean;
  12737. /**
  12738. * Called when a touch event has been triggered
  12739. */
  12740. touchChanged: boolean;
  12741. /**
  12742. * Called when a value has changed
  12743. */
  12744. valueChanged: boolean;
  12745. }
  12746. /**
  12747. * Represents a gamepad
  12748. */
  12749. export class Gamepad {
  12750. /**
  12751. * The id of the gamepad
  12752. */
  12753. id: string;
  12754. /**
  12755. * The index of the gamepad
  12756. */
  12757. index: number;
  12758. /**
  12759. * The browser gamepad
  12760. */
  12761. browserGamepad: any;
  12762. /**
  12763. * Specifies what type of gamepad this represents
  12764. */
  12765. type: number;
  12766. private _leftStick;
  12767. private _rightStick;
  12768. /** @hidden */
  12769. _isConnected: boolean;
  12770. private _leftStickAxisX;
  12771. private _leftStickAxisY;
  12772. private _rightStickAxisX;
  12773. private _rightStickAxisY;
  12774. /**
  12775. * Triggered when the left control stick has been changed
  12776. */
  12777. private _onleftstickchanged;
  12778. /**
  12779. * Triggered when the right control stick has been changed
  12780. */
  12781. private _onrightstickchanged;
  12782. /**
  12783. * Represents a gamepad controller
  12784. */
  12785. static GAMEPAD: number;
  12786. /**
  12787. * Represents a generic controller
  12788. */
  12789. static GENERIC: number;
  12790. /**
  12791. * Represents an XBox controller
  12792. */
  12793. static XBOX: number;
  12794. /**
  12795. * Represents a pose-enabled controller
  12796. */
  12797. static POSE_ENABLED: number;
  12798. /**
  12799. * Specifies whether the left control stick should be Y-inverted
  12800. */
  12801. protected _invertLeftStickY: boolean;
  12802. /**
  12803. * Specifies if the gamepad has been connected
  12804. */
  12805. readonly isConnected: boolean;
  12806. /**
  12807. * Initializes the gamepad
  12808. * @param id The id of the gamepad
  12809. * @param index The index of the gamepad
  12810. * @param browserGamepad The browser gamepad
  12811. * @param leftStickX The x component of the left joystick
  12812. * @param leftStickY The y component of the left joystick
  12813. * @param rightStickX The x component of the right joystick
  12814. * @param rightStickY The y component of the right joystick
  12815. */
  12816. constructor(
  12817. /**
  12818. * The id of the gamepad
  12819. */
  12820. id: string,
  12821. /**
  12822. * The index of the gamepad
  12823. */
  12824. index: number,
  12825. /**
  12826. * The browser gamepad
  12827. */
  12828. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12829. /**
  12830. * Callback triggered when the left joystick has changed
  12831. * @param callback
  12832. */
  12833. onleftstickchanged(callback: (values: StickValues) => void): void;
  12834. /**
  12835. * Callback triggered when the right joystick has changed
  12836. * @param callback
  12837. */
  12838. onrightstickchanged(callback: (values: StickValues) => void): void;
  12839. /**
  12840. * Gets the left joystick
  12841. */
  12842. /**
  12843. * Sets the left joystick values
  12844. */
  12845. leftStick: StickValues;
  12846. /**
  12847. * Gets the right joystick
  12848. */
  12849. /**
  12850. * Sets the right joystick value
  12851. */
  12852. rightStick: StickValues;
  12853. /**
  12854. * Updates the gamepad joystick positions
  12855. */
  12856. update(): void;
  12857. /**
  12858. * Disposes the gamepad
  12859. */
  12860. dispose(): void;
  12861. }
  12862. /**
  12863. * Represents a generic gamepad
  12864. */
  12865. export class GenericPad extends Gamepad {
  12866. private _buttons;
  12867. private _onbuttondown;
  12868. private _onbuttonup;
  12869. /**
  12870. * Observable triggered when a button has been pressed
  12871. */
  12872. onButtonDownObservable: Observable<number>;
  12873. /**
  12874. * Observable triggered when a button has been released
  12875. */
  12876. onButtonUpObservable: Observable<number>;
  12877. /**
  12878. * Callback triggered when a button has been pressed
  12879. * @param callback Called when a button has been pressed
  12880. */
  12881. onbuttondown(callback: (buttonPressed: number) => void): void;
  12882. /**
  12883. * Callback triggered when a button has been released
  12884. * @param callback Called when a button has been released
  12885. */
  12886. onbuttonup(callback: (buttonReleased: number) => void): void;
  12887. /**
  12888. * Initializes the generic gamepad
  12889. * @param id The id of the generic gamepad
  12890. * @param index The index of the generic gamepad
  12891. * @param browserGamepad The browser gamepad
  12892. */
  12893. constructor(id: string, index: number, browserGamepad: any);
  12894. private _setButtonValue;
  12895. /**
  12896. * Updates the generic gamepad
  12897. */
  12898. update(): void;
  12899. /**
  12900. * Disposes the generic gamepad
  12901. */
  12902. dispose(): void;
  12903. }
  12904. }
  12905. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12906. import { Observable } from "babylonjs/Misc/observable";
  12907. import { Nullable } from "babylonjs/types";
  12908. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12909. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12911. import { Ray } from "babylonjs/Culling/ray";
  12912. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12913. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12914. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12915. /**
  12916. * Defines the types of pose enabled controllers that are supported
  12917. */
  12918. export enum PoseEnabledControllerType {
  12919. /**
  12920. * HTC Vive
  12921. */
  12922. VIVE = 0,
  12923. /**
  12924. * Oculus Rift
  12925. */
  12926. OCULUS = 1,
  12927. /**
  12928. * Windows mixed reality
  12929. */
  12930. WINDOWS = 2,
  12931. /**
  12932. * Samsung gear VR
  12933. */
  12934. GEAR_VR = 3,
  12935. /**
  12936. * Google Daydream
  12937. */
  12938. DAYDREAM = 4,
  12939. /**
  12940. * Generic
  12941. */
  12942. GENERIC = 5
  12943. }
  12944. /**
  12945. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12946. */
  12947. export interface MutableGamepadButton {
  12948. /**
  12949. * Value of the button/trigger
  12950. */
  12951. value: number;
  12952. /**
  12953. * If the button/trigger is currently touched
  12954. */
  12955. touched: boolean;
  12956. /**
  12957. * If the button/trigger is currently pressed
  12958. */
  12959. pressed: boolean;
  12960. }
  12961. /**
  12962. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12963. * @hidden
  12964. */
  12965. export interface ExtendedGamepadButton extends GamepadButton {
  12966. /**
  12967. * If the button/trigger is currently pressed
  12968. */
  12969. readonly pressed: boolean;
  12970. /**
  12971. * If the button/trigger is currently touched
  12972. */
  12973. readonly touched: boolean;
  12974. /**
  12975. * Value of the button/trigger
  12976. */
  12977. readonly value: number;
  12978. }
  12979. /** @hidden */
  12980. export interface _GamePadFactory {
  12981. /**
  12982. * Returns wether or not the current gamepad can be created for this type of controller.
  12983. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12984. * @returns true if it can be created, otherwise false
  12985. */
  12986. canCreate(gamepadInfo: any): boolean;
  12987. /**
  12988. * Creates a new instance of the Gamepad.
  12989. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12990. * @returns the new gamepad instance
  12991. */
  12992. create(gamepadInfo: any): Gamepad;
  12993. }
  12994. /**
  12995. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12996. */
  12997. export class PoseEnabledControllerHelper {
  12998. /** @hidden */
  12999. static _ControllerFactories: _GamePadFactory[];
  13000. /** @hidden */
  13001. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13002. /**
  13003. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13004. * @param vrGamepad the gamepad to initialized
  13005. * @returns a vr controller of the type the gamepad identified as
  13006. */
  13007. static InitiateController(vrGamepad: any): Gamepad;
  13008. }
  13009. /**
  13010. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13011. */
  13012. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13013. private _deviceRoomPosition;
  13014. private _deviceRoomRotationQuaternion;
  13015. /**
  13016. * The device position in babylon space
  13017. */
  13018. devicePosition: Vector3;
  13019. /**
  13020. * The device rotation in babylon space
  13021. */
  13022. deviceRotationQuaternion: Quaternion;
  13023. /**
  13024. * The scale factor of the device in babylon space
  13025. */
  13026. deviceScaleFactor: number;
  13027. /**
  13028. * (Likely devicePosition should be used instead) The device position in its room space
  13029. */
  13030. position: Vector3;
  13031. /**
  13032. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13033. */
  13034. rotationQuaternion: Quaternion;
  13035. /**
  13036. * The type of controller (Eg. Windows mixed reality)
  13037. */
  13038. controllerType: PoseEnabledControllerType;
  13039. protected _calculatedPosition: Vector3;
  13040. private _calculatedRotation;
  13041. /**
  13042. * The raw pose from the device
  13043. */
  13044. rawPose: DevicePose;
  13045. private _trackPosition;
  13046. private _maxRotationDistFromHeadset;
  13047. private _draggedRoomRotation;
  13048. /**
  13049. * @hidden
  13050. */
  13051. _disableTrackPosition(fixedPosition: Vector3): void;
  13052. /**
  13053. * Internal, the mesh attached to the controller
  13054. * @hidden
  13055. */
  13056. _mesh: Nullable<AbstractMesh>;
  13057. private _poseControlledCamera;
  13058. private _leftHandSystemQuaternion;
  13059. /**
  13060. * Internal, matrix used to convert room space to babylon space
  13061. * @hidden
  13062. */
  13063. _deviceToWorld: Matrix;
  13064. /**
  13065. * Node to be used when casting a ray from the controller
  13066. * @hidden
  13067. */
  13068. _pointingPoseNode: Nullable<TransformNode>;
  13069. /**
  13070. * Name of the child mesh that can be used to cast a ray from the controller
  13071. */
  13072. static readonly POINTING_POSE: string;
  13073. /**
  13074. * Creates a new PoseEnabledController from a gamepad
  13075. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13076. */
  13077. constructor(browserGamepad: any);
  13078. private _workingMatrix;
  13079. /**
  13080. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13081. */
  13082. update(): void;
  13083. /**
  13084. * Updates only the pose device and mesh without doing any button event checking
  13085. */
  13086. protected _updatePoseAndMesh(): void;
  13087. /**
  13088. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13089. * @param poseData raw pose fromthe device
  13090. */
  13091. updateFromDevice(poseData: DevicePose): void;
  13092. /**
  13093. * @hidden
  13094. */
  13095. _meshAttachedObservable: Observable<AbstractMesh>;
  13096. /**
  13097. * Attaches a mesh to the controller
  13098. * @param mesh the mesh to be attached
  13099. */
  13100. attachToMesh(mesh: AbstractMesh): void;
  13101. /**
  13102. * Attaches the controllers mesh to a camera
  13103. * @param camera the camera the mesh should be attached to
  13104. */
  13105. attachToPoseControlledCamera(camera: TargetCamera): void;
  13106. /**
  13107. * Disposes of the controller
  13108. */
  13109. dispose(): void;
  13110. /**
  13111. * The mesh that is attached to the controller
  13112. */
  13113. readonly mesh: Nullable<AbstractMesh>;
  13114. /**
  13115. * Gets the ray of the controller in the direction the controller is pointing
  13116. * @param length the length the resulting ray should be
  13117. * @returns a ray in the direction the controller is pointing
  13118. */
  13119. getForwardRay(length?: number): Ray;
  13120. }
  13121. }
  13122. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13123. import { Observable } from "babylonjs/Misc/observable";
  13124. import { Scene } from "babylonjs/scene";
  13125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13126. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13127. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13128. /**
  13129. * Defines the WebVRController object that represents controllers tracked in 3D space
  13130. */
  13131. export abstract class WebVRController extends PoseEnabledController {
  13132. /**
  13133. * Internal, the default controller model for the controller
  13134. */
  13135. protected _defaultModel: AbstractMesh;
  13136. /**
  13137. * Fired when the trigger state has changed
  13138. */
  13139. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13140. /**
  13141. * Fired when the main button state has changed
  13142. */
  13143. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13144. /**
  13145. * Fired when the secondary button state has changed
  13146. */
  13147. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13148. /**
  13149. * Fired when the pad state has changed
  13150. */
  13151. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13152. /**
  13153. * Fired when controllers stick values have changed
  13154. */
  13155. onPadValuesChangedObservable: Observable<StickValues>;
  13156. /**
  13157. * Array of button availible on the controller
  13158. */
  13159. protected _buttons: Array<MutableGamepadButton>;
  13160. private _onButtonStateChange;
  13161. /**
  13162. * Fired when a controller button's state has changed
  13163. * @param callback the callback containing the button that was modified
  13164. */
  13165. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13166. /**
  13167. * X and Y axis corrisponding to the controllers joystick
  13168. */
  13169. pad: StickValues;
  13170. /**
  13171. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13172. */
  13173. hand: string;
  13174. /**
  13175. * The default controller model for the controller
  13176. */
  13177. readonly defaultModel: AbstractMesh;
  13178. /**
  13179. * Creates a new WebVRController from a gamepad
  13180. * @param vrGamepad the gamepad that the WebVRController should be created from
  13181. */
  13182. constructor(vrGamepad: any);
  13183. /**
  13184. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13185. */
  13186. update(): void;
  13187. /**
  13188. * Function to be called when a button is modified
  13189. */
  13190. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13191. /**
  13192. * Loads a mesh and attaches it to the controller
  13193. * @param scene the scene the mesh should be added to
  13194. * @param meshLoaded callback for when the mesh has been loaded
  13195. */
  13196. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13197. private _setButtonValue;
  13198. private _changes;
  13199. private _checkChanges;
  13200. /**
  13201. * Disposes of th webVRCOntroller
  13202. */
  13203. dispose(): void;
  13204. }
  13205. }
  13206. declare module "babylonjs/Lights/hemisphericLight" {
  13207. import { Nullable } from "babylonjs/types";
  13208. import { Scene } from "babylonjs/scene";
  13209. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13210. import { Effect } from "babylonjs/Materials/effect";
  13211. import { Light } from "babylonjs/Lights/light";
  13212. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13213. /**
  13214. * The HemisphericLight simulates the ambient environment light,
  13215. * so the passed direction is the light reflection direction, not the incoming direction.
  13216. */
  13217. export class HemisphericLight extends Light {
  13218. /**
  13219. * The groundColor is the light in the opposite direction to the one specified during creation.
  13220. * 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.
  13221. */
  13222. groundColor: Color3;
  13223. /**
  13224. * The light reflection direction, not the incoming direction.
  13225. */
  13226. direction: Vector3;
  13227. /**
  13228. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13229. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13230. * The HemisphericLight can't cast shadows.
  13231. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13232. * @param name The friendly name of the light
  13233. * @param direction The direction of the light reflection
  13234. * @param scene The scene the light belongs to
  13235. */
  13236. constructor(name: string, direction: Vector3, scene: Scene);
  13237. protected _buildUniformLayout(): void;
  13238. /**
  13239. * Returns the string "HemisphericLight".
  13240. * @return The class name
  13241. */
  13242. getClassName(): string;
  13243. /**
  13244. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13245. * Returns the updated direction.
  13246. * @param target The target the direction should point to
  13247. * @return The computed direction
  13248. */
  13249. setDirectionToTarget(target: Vector3): Vector3;
  13250. /**
  13251. * Returns the shadow generator associated to the light.
  13252. * @returns Always null for hemispheric lights because it does not support shadows.
  13253. */
  13254. getShadowGenerator(): Nullable<IShadowGenerator>;
  13255. /**
  13256. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13257. * @param effect The effect to update
  13258. * @param lightIndex The index of the light in the effect to update
  13259. * @returns The hemispheric light
  13260. */
  13261. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13262. /**
  13263. * Computes the world matrix of the node
  13264. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13265. * @param useWasUpdatedFlag defines a reserved property
  13266. * @returns the world matrix
  13267. */
  13268. computeWorldMatrix(): Matrix;
  13269. /**
  13270. * Returns the integer 3.
  13271. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13272. */
  13273. getTypeID(): number;
  13274. /**
  13275. * Prepares the list of defines specific to the light type.
  13276. * @param defines the list of defines
  13277. * @param lightIndex defines the index of the light for the effect
  13278. */
  13279. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13280. }
  13281. }
  13282. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13283. /** @hidden */
  13284. export var vrMultiviewToSingleviewPixelShader: {
  13285. name: string;
  13286. shader: string;
  13287. };
  13288. }
  13289. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13290. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13291. import { Scene } from "babylonjs/scene";
  13292. /**
  13293. * Renders to multiple views with a single draw call
  13294. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13295. */
  13296. export class MultiviewRenderTarget extends RenderTargetTexture {
  13297. /**
  13298. * Creates a multiview render target
  13299. * @param scene scene used with the render target
  13300. * @param size the size of the render target (used for each view)
  13301. */
  13302. constructor(scene: Scene, size?: number | {
  13303. width: number;
  13304. height: number;
  13305. } | {
  13306. ratio: number;
  13307. });
  13308. /**
  13309. * @hidden
  13310. * @param faceIndex the face index, if its a cube texture
  13311. */
  13312. _bindFrameBuffer(faceIndex?: number): void;
  13313. /**
  13314. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13315. * @returns the view count
  13316. */
  13317. getViewCount(): number;
  13318. }
  13319. }
  13320. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13321. import { Camera } from "babylonjs/Cameras/camera";
  13322. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13323. import { Nullable } from "babylonjs/types";
  13324. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13325. import { Matrix } from "babylonjs/Maths/math";
  13326. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13327. module "babylonjs/Engines/engine" {
  13328. interface Engine {
  13329. /**
  13330. * Creates a new multiview render target
  13331. * @param width defines the width of the texture
  13332. * @param height defines the height of the texture
  13333. * @returns the created multiview texture
  13334. */
  13335. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13336. /**
  13337. * Binds a multiview framebuffer to be drawn to
  13338. * @param multiviewTexture texture to bind
  13339. */
  13340. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13341. }
  13342. }
  13343. module "babylonjs/Cameras/camera" {
  13344. interface Camera {
  13345. /**
  13346. * @hidden
  13347. * 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)
  13348. */
  13349. _useMultiviewToSingleView: boolean;
  13350. /**
  13351. * @hidden
  13352. * 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)
  13353. */
  13354. _multiviewTexture: Nullable<RenderTargetTexture>;
  13355. /**
  13356. * @hidden
  13357. * ensures the multiview texture of the camera exists and has the specified width/height
  13358. * @param width height to set on the multiview texture
  13359. * @param height width to set on the multiview texture
  13360. */
  13361. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13362. }
  13363. }
  13364. module "babylonjs/scene" {
  13365. interface Scene {
  13366. /** @hidden */
  13367. _transformMatrixR: Matrix;
  13368. /** @hidden */
  13369. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13370. /** @hidden */
  13371. _createMultiviewUbo(): void;
  13372. /** @hidden */
  13373. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13374. /** @hidden */
  13375. _renderMultiviewToSingleView(camera: Camera): void;
  13376. }
  13377. }
  13378. }
  13379. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13380. import { Camera } from "babylonjs/Cameras/camera";
  13381. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13382. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13383. import "babylonjs/Engines/Extensions/engine.multiview";
  13384. /**
  13385. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13386. * This will not be used for webXR as it supports displaying texture arrays directly
  13387. */
  13388. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13389. /**
  13390. * Initializes a VRMultiviewToSingleview
  13391. * @param name name of the post process
  13392. * @param camera camera to be applied to
  13393. * @param scaleFactor scaling factor to the size of the output texture
  13394. */
  13395. constructor(name: string, camera: Camera, scaleFactor: number);
  13396. }
  13397. }
  13398. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13399. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13400. import { Nullable } from "babylonjs/types";
  13401. import { Observable } from "babylonjs/Misc/observable";
  13402. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13403. import { Scene } from "babylonjs/scene";
  13404. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13405. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13406. import { Node } from "babylonjs/node";
  13407. import { Ray } from "babylonjs/Culling/ray";
  13408. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13409. /**
  13410. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13411. * IMPORTANT!! The data is right-hand data.
  13412. * @export
  13413. * @interface DevicePose
  13414. */
  13415. export interface DevicePose {
  13416. /**
  13417. * The position of the device, values in array are [x,y,z].
  13418. */
  13419. readonly position: Nullable<Float32Array>;
  13420. /**
  13421. * The linearVelocity of the device, values in array are [x,y,z].
  13422. */
  13423. readonly linearVelocity: Nullable<Float32Array>;
  13424. /**
  13425. * The linearAcceleration of the device, values in array are [x,y,z].
  13426. */
  13427. readonly linearAcceleration: Nullable<Float32Array>;
  13428. /**
  13429. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13430. */
  13431. readonly orientation: Nullable<Float32Array>;
  13432. /**
  13433. * The angularVelocity of the device, values in array are [x,y,z].
  13434. */
  13435. readonly angularVelocity: Nullable<Float32Array>;
  13436. /**
  13437. * The angularAcceleration of the device, values in array are [x,y,z].
  13438. */
  13439. readonly angularAcceleration: Nullable<Float32Array>;
  13440. }
  13441. /**
  13442. * Interface representing a pose controlled object in Babylon.
  13443. * A pose controlled object has both regular pose values as well as pose values
  13444. * from an external device such as a VR head mounted display
  13445. */
  13446. export interface PoseControlled {
  13447. /**
  13448. * The position of the object in babylon space.
  13449. */
  13450. position: Vector3;
  13451. /**
  13452. * The rotation quaternion of the object in babylon space.
  13453. */
  13454. rotationQuaternion: Quaternion;
  13455. /**
  13456. * The position of the device in babylon space.
  13457. */
  13458. devicePosition?: Vector3;
  13459. /**
  13460. * The rotation quaternion of the device in babylon space.
  13461. */
  13462. deviceRotationQuaternion: Quaternion;
  13463. /**
  13464. * The raw pose coming from the device.
  13465. */
  13466. rawPose: Nullable<DevicePose>;
  13467. /**
  13468. * The scale of the device to be used when translating from device space to babylon space.
  13469. */
  13470. deviceScaleFactor: number;
  13471. /**
  13472. * Updates the poseControlled values based on the input device pose.
  13473. * @param poseData the pose data to update the object with
  13474. */
  13475. updateFromDevice(poseData: DevicePose): void;
  13476. }
  13477. /**
  13478. * Set of options to customize the webVRCamera
  13479. */
  13480. export interface WebVROptions {
  13481. /**
  13482. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13483. */
  13484. trackPosition?: boolean;
  13485. /**
  13486. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13487. */
  13488. positionScale?: number;
  13489. /**
  13490. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13491. */
  13492. displayName?: string;
  13493. /**
  13494. * Should the native controller meshes be initialized. (default: true)
  13495. */
  13496. controllerMeshes?: boolean;
  13497. /**
  13498. * Creating a default HemiLight only on controllers. (default: true)
  13499. */
  13500. defaultLightingOnControllers?: boolean;
  13501. /**
  13502. * If you don't want to use the default VR button of the helper. (default: false)
  13503. */
  13504. useCustomVRButton?: boolean;
  13505. /**
  13506. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13507. */
  13508. customVRButton?: HTMLButtonElement;
  13509. /**
  13510. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13511. */
  13512. rayLength?: number;
  13513. /**
  13514. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13515. */
  13516. defaultHeight?: number;
  13517. /**
  13518. * If multiview should be used if availible (default: false)
  13519. */
  13520. useMultiview?: boolean;
  13521. }
  13522. /**
  13523. * This represents a WebVR camera.
  13524. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13525. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13526. */
  13527. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13528. private webVROptions;
  13529. /**
  13530. * @hidden
  13531. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13532. */
  13533. _vrDevice: any;
  13534. /**
  13535. * The rawPose of the vrDevice.
  13536. */
  13537. rawPose: Nullable<DevicePose>;
  13538. private _onVREnabled;
  13539. private _specsVersion;
  13540. private _attached;
  13541. private _frameData;
  13542. protected _descendants: Array<Node>;
  13543. private _deviceRoomPosition;
  13544. /** @hidden */
  13545. _deviceRoomRotationQuaternion: Quaternion;
  13546. private _standingMatrix;
  13547. /**
  13548. * Represents device position in babylon space.
  13549. */
  13550. devicePosition: Vector3;
  13551. /**
  13552. * Represents device rotation in babylon space.
  13553. */
  13554. deviceRotationQuaternion: Quaternion;
  13555. /**
  13556. * The scale of the device to be used when translating from device space to babylon space.
  13557. */
  13558. deviceScaleFactor: number;
  13559. private _deviceToWorld;
  13560. private _worldToDevice;
  13561. /**
  13562. * References to the webVR controllers for the vrDevice.
  13563. */
  13564. controllers: Array<WebVRController>;
  13565. /**
  13566. * Emits an event when a controller is attached.
  13567. */
  13568. onControllersAttachedObservable: Observable<WebVRController[]>;
  13569. /**
  13570. * Emits an event when a controller's mesh has been loaded;
  13571. */
  13572. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13573. /**
  13574. * Emits an event when the HMD's pose has been updated.
  13575. */
  13576. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13577. private _poseSet;
  13578. /**
  13579. * If the rig cameras be used as parent instead of this camera.
  13580. */
  13581. rigParenting: boolean;
  13582. private _lightOnControllers;
  13583. private _defaultHeight?;
  13584. /**
  13585. * Instantiates a WebVRFreeCamera.
  13586. * @param name The name of the WebVRFreeCamera
  13587. * @param position The starting anchor position for the camera
  13588. * @param scene The scene the camera belongs to
  13589. * @param webVROptions a set of customizable options for the webVRCamera
  13590. */
  13591. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13592. /**
  13593. * Gets the device distance from the ground in meters.
  13594. * @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.
  13595. */
  13596. deviceDistanceToRoomGround(): number;
  13597. /**
  13598. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13599. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13600. */
  13601. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13602. /**
  13603. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13604. * @returns A promise with a boolean set to if the standing matrix is supported.
  13605. */
  13606. useStandingMatrixAsync(): Promise<boolean>;
  13607. /**
  13608. * Disposes the camera
  13609. */
  13610. dispose(): void;
  13611. /**
  13612. * Gets a vrController by name.
  13613. * @param name The name of the controller to retreive
  13614. * @returns the controller matching the name specified or null if not found
  13615. */
  13616. getControllerByName(name: string): Nullable<WebVRController>;
  13617. private _leftController;
  13618. /**
  13619. * The controller corrisponding to the users left hand.
  13620. */
  13621. readonly leftController: Nullable<WebVRController>;
  13622. private _rightController;
  13623. /**
  13624. * The controller corrisponding to the users right hand.
  13625. */
  13626. readonly rightController: Nullable<WebVRController>;
  13627. /**
  13628. * Casts a ray forward from the vrCamera's gaze.
  13629. * @param length Length of the ray (default: 100)
  13630. * @returns the ray corrisponding to the gaze
  13631. */
  13632. getForwardRay(length?: number): Ray;
  13633. /**
  13634. * @hidden
  13635. * Updates the camera based on device's frame data
  13636. */
  13637. _checkInputs(): void;
  13638. /**
  13639. * Updates the poseControlled values based on the input device pose.
  13640. * @param poseData Pose coming from the device
  13641. */
  13642. updateFromDevice(poseData: DevicePose): void;
  13643. private _htmlElementAttached;
  13644. private _detachIfAttached;
  13645. /**
  13646. * WebVR's attach control will start broadcasting frames to the device.
  13647. * Note that in certain browsers (chrome for example) this function must be called
  13648. * within a user-interaction callback. Example:
  13649. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13650. *
  13651. * @param element html element to attach the vrDevice to
  13652. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13653. */
  13654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13655. /**
  13656. * Detaches the camera from the html element and disables VR
  13657. *
  13658. * @param element html element to detach from
  13659. */
  13660. detachControl(element: HTMLElement): void;
  13661. /**
  13662. * @returns the name of this class
  13663. */
  13664. getClassName(): string;
  13665. /**
  13666. * Calls resetPose on the vrDisplay
  13667. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13668. */
  13669. resetToCurrentRotation(): void;
  13670. /**
  13671. * @hidden
  13672. * Updates the rig cameras (left and right eye)
  13673. */
  13674. _updateRigCameras(): void;
  13675. private _workingVector;
  13676. private _oneVector;
  13677. private _workingMatrix;
  13678. private updateCacheCalled;
  13679. private _correctPositionIfNotTrackPosition;
  13680. /**
  13681. * @hidden
  13682. * Updates the cached values of the camera
  13683. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13684. */
  13685. _updateCache(ignoreParentClass?: boolean): void;
  13686. /**
  13687. * @hidden
  13688. * Get current device position in babylon world
  13689. */
  13690. _computeDevicePosition(): void;
  13691. /**
  13692. * Updates the current device position and rotation in the babylon world
  13693. */
  13694. update(): void;
  13695. /**
  13696. * @hidden
  13697. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13698. * @returns an identity matrix
  13699. */
  13700. _getViewMatrix(): Matrix;
  13701. private _tmpMatrix;
  13702. /**
  13703. * This function is called by the two RIG cameras.
  13704. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13705. * @hidden
  13706. */
  13707. _getWebVRViewMatrix(): Matrix;
  13708. /** @hidden */
  13709. _getWebVRProjectionMatrix(): Matrix;
  13710. private _onGamepadConnectedObserver;
  13711. private _onGamepadDisconnectedObserver;
  13712. private _updateCacheWhenTrackingDisabledObserver;
  13713. /**
  13714. * Initializes the controllers and their meshes
  13715. */
  13716. initControllers(): void;
  13717. }
  13718. }
  13719. declare module "babylonjs/PostProcesses/postProcess" {
  13720. import { Nullable } from "babylonjs/types";
  13721. import { SmartArray } from "babylonjs/Misc/smartArray";
  13722. import { Observable } from "babylonjs/Misc/observable";
  13723. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13724. import { Camera } from "babylonjs/Cameras/camera";
  13725. import { Effect } from "babylonjs/Materials/effect";
  13726. import "babylonjs/Shaders/postprocess.vertex";
  13727. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13728. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13729. import { Engine } from "babylonjs/Engines/engine";
  13730. /**
  13731. * Size options for a post process
  13732. */
  13733. export type PostProcessOptions = {
  13734. width: number;
  13735. height: number;
  13736. };
  13737. /**
  13738. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13739. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13740. */
  13741. export class PostProcess {
  13742. /** Name of the PostProcess. */
  13743. name: string;
  13744. /**
  13745. * Gets or sets the unique id of the post process
  13746. */
  13747. uniqueId: number;
  13748. /**
  13749. * Width of the texture to apply the post process on
  13750. */
  13751. width: number;
  13752. /**
  13753. * Height of the texture to apply the post process on
  13754. */
  13755. height: number;
  13756. /**
  13757. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13758. * @hidden
  13759. */
  13760. _outputTexture: Nullable<InternalTexture>;
  13761. /**
  13762. * Sampling mode used by the shader
  13763. * See https://doc.babylonjs.com/classes/3.1/texture
  13764. */
  13765. renderTargetSamplingMode: number;
  13766. /**
  13767. * Clear color to use when screen clearing
  13768. */
  13769. clearColor: Color4;
  13770. /**
  13771. * If the buffer needs to be cleared before applying the post process. (default: true)
  13772. * Should be set to false if shader will overwrite all previous pixels.
  13773. */
  13774. autoClear: boolean;
  13775. /**
  13776. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13777. */
  13778. alphaMode: number;
  13779. /**
  13780. * Sets the setAlphaBlendConstants of the babylon engine
  13781. */
  13782. alphaConstants: Color4;
  13783. /**
  13784. * Animations to be used for the post processing
  13785. */
  13786. animations: import("babylonjs/Animations/animation").Animation[];
  13787. /**
  13788. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13789. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13790. */
  13791. enablePixelPerfectMode: boolean;
  13792. /**
  13793. * Force the postprocess to be applied without taking in account viewport
  13794. */
  13795. forceFullscreenViewport: boolean;
  13796. /**
  13797. * List of inspectable custom properties (used by the Inspector)
  13798. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13799. */
  13800. inspectableCustomProperties: IInspectable[];
  13801. /**
  13802. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13803. *
  13804. * | Value | Type | Description |
  13805. * | ----- | ----------------------------------- | ----------- |
  13806. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13807. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13808. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13809. *
  13810. */
  13811. scaleMode: number;
  13812. /**
  13813. * Force textures to be a power of two (default: false)
  13814. */
  13815. alwaysForcePOT: boolean;
  13816. private _samples;
  13817. /**
  13818. * Number of sample textures (default: 1)
  13819. */
  13820. samples: number;
  13821. /**
  13822. * Modify the scale of the post process to be the same as the viewport (default: false)
  13823. */
  13824. adaptScaleToCurrentViewport: boolean;
  13825. private _camera;
  13826. private _scene;
  13827. private _engine;
  13828. private _options;
  13829. private _reusable;
  13830. private _textureType;
  13831. /**
  13832. * Smart array of input and output textures for the post process.
  13833. * @hidden
  13834. */
  13835. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13836. /**
  13837. * The index in _textures that corresponds to the output texture.
  13838. * @hidden
  13839. */
  13840. _currentRenderTextureInd: number;
  13841. private _effect;
  13842. private _samplers;
  13843. private _fragmentUrl;
  13844. private _vertexUrl;
  13845. private _parameters;
  13846. private _scaleRatio;
  13847. protected _indexParameters: any;
  13848. private _shareOutputWithPostProcess;
  13849. private _texelSize;
  13850. private _forcedOutputTexture;
  13851. /**
  13852. * Returns the fragment url or shader name used in the post process.
  13853. * @returns the fragment url or name in the shader store.
  13854. */
  13855. getEffectName(): string;
  13856. /**
  13857. * An event triggered when the postprocess is activated.
  13858. */
  13859. onActivateObservable: Observable<Camera>;
  13860. private _onActivateObserver;
  13861. /**
  13862. * A function that is added to the onActivateObservable
  13863. */
  13864. onActivate: Nullable<(camera: Camera) => void>;
  13865. /**
  13866. * An event triggered when the postprocess changes its size.
  13867. */
  13868. onSizeChangedObservable: Observable<PostProcess>;
  13869. private _onSizeChangedObserver;
  13870. /**
  13871. * A function that is added to the onSizeChangedObservable
  13872. */
  13873. onSizeChanged: (postProcess: PostProcess) => void;
  13874. /**
  13875. * An event triggered when the postprocess applies its effect.
  13876. */
  13877. onApplyObservable: Observable<Effect>;
  13878. private _onApplyObserver;
  13879. /**
  13880. * A function that is added to the onApplyObservable
  13881. */
  13882. onApply: (effect: Effect) => void;
  13883. /**
  13884. * An event triggered before rendering the postprocess
  13885. */
  13886. onBeforeRenderObservable: Observable<Effect>;
  13887. private _onBeforeRenderObserver;
  13888. /**
  13889. * A function that is added to the onBeforeRenderObservable
  13890. */
  13891. onBeforeRender: (effect: Effect) => void;
  13892. /**
  13893. * An event triggered after rendering the postprocess
  13894. */
  13895. onAfterRenderObservable: Observable<Effect>;
  13896. private _onAfterRenderObserver;
  13897. /**
  13898. * A function that is added to the onAfterRenderObservable
  13899. */
  13900. onAfterRender: (efect: Effect) => void;
  13901. /**
  13902. * 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
  13903. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13904. */
  13905. inputTexture: InternalTexture;
  13906. /**
  13907. * Gets the camera which post process is applied to.
  13908. * @returns The camera the post process is applied to.
  13909. */
  13910. getCamera(): Camera;
  13911. /**
  13912. * Gets the texel size of the postprocess.
  13913. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13914. */
  13915. readonly texelSize: Vector2;
  13916. /**
  13917. * Creates a new instance PostProcess
  13918. * @param name The name of the PostProcess.
  13919. * @param fragmentUrl The url of the fragment shader to be used.
  13920. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13921. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13922. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13923. * @param camera The camera to apply the render pass to.
  13924. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13925. * @param engine The engine which the post process will be applied. (default: current engine)
  13926. * @param reusable If the post process can be reused on the same frame. (default: false)
  13927. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13928. * @param textureType Type of textures used when performing the post process. (default: 0)
  13929. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13930. * @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
  13931. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13932. */
  13933. constructor(
  13934. /** Name of the PostProcess. */
  13935. 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);
  13936. /**
  13937. * Gets a string idenfifying the name of the class
  13938. * @returns "PostProcess" string
  13939. */
  13940. getClassName(): string;
  13941. /**
  13942. * Gets the engine which this post process belongs to.
  13943. * @returns The engine the post process was enabled with.
  13944. */
  13945. getEngine(): Engine;
  13946. /**
  13947. * The effect that is created when initializing the post process.
  13948. * @returns The created effect corrisponding the the postprocess.
  13949. */
  13950. getEffect(): Effect;
  13951. /**
  13952. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13953. * @param postProcess The post process to share the output with.
  13954. * @returns This post process.
  13955. */
  13956. shareOutputWith(postProcess: PostProcess): PostProcess;
  13957. /**
  13958. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13959. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13960. */
  13961. useOwnOutput(): void;
  13962. /**
  13963. * Updates the effect with the current post process compile time values and recompiles the shader.
  13964. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13965. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13966. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13967. * @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
  13968. * @param onCompiled Called when the shader has been compiled.
  13969. * @param onError Called if there is an error when compiling a shader.
  13970. */
  13971. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13972. /**
  13973. * The post process is reusable if it can be used multiple times within one frame.
  13974. * @returns If the post process is reusable
  13975. */
  13976. isReusable(): boolean;
  13977. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13978. markTextureDirty(): void;
  13979. /**
  13980. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13981. * 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.
  13982. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13983. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13984. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13985. * @returns The target texture that was bound to be written to.
  13986. */
  13987. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13988. /**
  13989. * If the post process is supported.
  13990. */
  13991. readonly isSupported: boolean;
  13992. /**
  13993. * The aspect ratio of the output texture.
  13994. */
  13995. readonly aspectRatio: number;
  13996. /**
  13997. * Get a value indicating if the post-process is ready to be used
  13998. * @returns true if the post-process is ready (shader is compiled)
  13999. */
  14000. isReady(): boolean;
  14001. /**
  14002. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14003. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14004. */
  14005. apply(): Nullable<Effect>;
  14006. private _disposeTextures;
  14007. /**
  14008. * Disposes the post process.
  14009. * @param camera The camera to dispose the post process on.
  14010. */
  14011. dispose(camera?: Camera): void;
  14012. }
  14013. }
  14014. declare module "babylonjs/PostProcesses/postProcessManager" {
  14015. import { Nullable } from "babylonjs/types";
  14016. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14017. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14018. import { Scene } from "babylonjs/scene";
  14019. /**
  14020. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14021. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14022. */
  14023. export class PostProcessManager {
  14024. private _scene;
  14025. private _indexBuffer;
  14026. private _vertexBuffers;
  14027. /**
  14028. * Creates a new instance PostProcess
  14029. * @param scene The scene that the post process is associated with.
  14030. */
  14031. constructor(scene: Scene);
  14032. private _prepareBuffers;
  14033. private _buildIndexBuffer;
  14034. /**
  14035. * Rebuilds the vertex buffers of the manager.
  14036. * @hidden
  14037. */
  14038. _rebuild(): void;
  14039. /**
  14040. * Prepares a frame to be run through a post process.
  14041. * @param sourceTexture The input texture to the post procesess. (default: null)
  14042. * @param postProcesses An array of post processes to be run. (default: null)
  14043. * @returns True if the post processes were able to be run.
  14044. * @hidden
  14045. */
  14046. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14047. /**
  14048. * Manually render a set of post processes to a texture.
  14049. * @param postProcesses An array of post processes to be run.
  14050. * @param targetTexture The target texture to render to.
  14051. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14052. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14053. * @param lodLevel defines which lod of the texture to render to
  14054. */
  14055. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14056. /**
  14057. * Finalize the result of the output of the postprocesses.
  14058. * @param doNotPresent If true the result will not be displayed to the screen.
  14059. * @param targetTexture The target texture to render to.
  14060. * @param faceIndex The index of the face to bind the target texture to.
  14061. * @param postProcesses The array of post processes to render.
  14062. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14063. * @hidden
  14064. */
  14065. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14066. /**
  14067. * Disposes of the post process manager.
  14068. */
  14069. dispose(): void;
  14070. }
  14071. }
  14072. declare module "babylonjs/Layers/layerSceneComponent" {
  14073. import { Scene } from "babylonjs/scene";
  14074. import { ISceneComponent } from "babylonjs/sceneComponent";
  14075. import { Layer } from "babylonjs/Layers/layer";
  14076. module "babylonjs/abstractScene" {
  14077. interface AbstractScene {
  14078. /**
  14079. * The list of layers (background and foreground) of the scene
  14080. */
  14081. layers: Array<Layer>;
  14082. }
  14083. }
  14084. /**
  14085. * Defines the layer scene component responsible to manage any layers
  14086. * in a given scene.
  14087. */
  14088. export class LayerSceneComponent implements ISceneComponent {
  14089. /**
  14090. * The component name helpfull to identify the component in the list of scene components.
  14091. */
  14092. readonly name: string;
  14093. /**
  14094. * The scene the component belongs to.
  14095. */
  14096. scene: Scene;
  14097. private _engine;
  14098. /**
  14099. * Creates a new instance of the component for the given scene
  14100. * @param scene Defines the scene to register the component in
  14101. */
  14102. constructor(scene: Scene);
  14103. /**
  14104. * Registers the component in a given scene
  14105. */
  14106. register(): void;
  14107. /**
  14108. * Rebuilds the elements related to this component in case of
  14109. * context lost for instance.
  14110. */
  14111. rebuild(): void;
  14112. /**
  14113. * Disposes the component and the associated ressources.
  14114. */
  14115. dispose(): void;
  14116. private _draw;
  14117. private _drawCameraPredicate;
  14118. private _drawCameraBackground;
  14119. private _drawCameraForeground;
  14120. private _drawRenderTargetPredicate;
  14121. private _drawRenderTargetBackground;
  14122. private _drawRenderTargetForeground;
  14123. }
  14124. }
  14125. declare module "babylonjs/Shaders/layer.fragment" {
  14126. /** @hidden */
  14127. export var layerPixelShader: {
  14128. name: string;
  14129. shader: string;
  14130. };
  14131. }
  14132. declare module "babylonjs/Shaders/layer.vertex" {
  14133. /** @hidden */
  14134. export var layerVertexShader: {
  14135. name: string;
  14136. shader: string;
  14137. };
  14138. }
  14139. declare module "babylonjs/Layers/layer" {
  14140. import { Observable } from "babylonjs/Misc/observable";
  14141. import { Nullable } from "babylonjs/types";
  14142. import { Scene } from "babylonjs/scene";
  14143. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14144. import { Texture } from "babylonjs/Materials/Textures/texture";
  14145. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14146. import "babylonjs/Shaders/layer.fragment";
  14147. import "babylonjs/Shaders/layer.vertex";
  14148. /**
  14149. * This represents a full screen 2d layer.
  14150. * This can be useful to display a picture in the background of your scene for instance.
  14151. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14152. */
  14153. export class Layer {
  14154. /**
  14155. * Define the name of the layer.
  14156. */
  14157. name: string;
  14158. /**
  14159. * Define the texture the layer should display.
  14160. */
  14161. texture: Nullable<Texture>;
  14162. /**
  14163. * Is the layer in background or foreground.
  14164. */
  14165. isBackground: boolean;
  14166. /**
  14167. * Define the color of the layer (instead of texture).
  14168. */
  14169. color: Color4;
  14170. /**
  14171. * Define the scale of the layer in order to zoom in out of the texture.
  14172. */
  14173. scale: Vector2;
  14174. /**
  14175. * Define an offset for the layer in order to shift the texture.
  14176. */
  14177. offset: Vector2;
  14178. /**
  14179. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14180. */
  14181. alphaBlendingMode: number;
  14182. /**
  14183. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14184. * Alpha test will not mix with the background color in case of transparency.
  14185. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14186. */
  14187. alphaTest: boolean;
  14188. /**
  14189. * Define a mask to restrict the layer to only some of the scene cameras.
  14190. */
  14191. layerMask: number;
  14192. /**
  14193. * Define the list of render target the layer is visible into.
  14194. */
  14195. renderTargetTextures: RenderTargetTexture[];
  14196. /**
  14197. * Define if the layer is only used in renderTarget or if it also
  14198. * renders in the main frame buffer of the canvas.
  14199. */
  14200. renderOnlyInRenderTargetTextures: boolean;
  14201. private _scene;
  14202. private _vertexBuffers;
  14203. private _indexBuffer;
  14204. private _effect;
  14205. private _alphaTestEffect;
  14206. /**
  14207. * An event triggered when the layer is disposed.
  14208. */
  14209. onDisposeObservable: Observable<Layer>;
  14210. private _onDisposeObserver;
  14211. /**
  14212. * Back compatibility with callback before the onDisposeObservable existed.
  14213. * The set callback will be triggered when the layer has been disposed.
  14214. */
  14215. onDispose: () => void;
  14216. /**
  14217. * An event triggered before rendering the scene
  14218. */
  14219. onBeforeRenderObservable: Observable<Layer>;
  14220. private _onBeforeRenderObserver;
  14221. /**
  14222. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14223. * The set callback will be triggered just before rendering the layer.
  14224. */
  14225. onBeforeRender: () => void;
  14226. /**
  14227. * An event triggered after rendering the scene
  14228. */
  14229. onAfterRenderObservable: Observable<Layer>;
  14230. private _onAfterRenderObserver;
  14231. /**
  14232. * Back compatibility with callback before the onAfterRenderObservable existed.
  14233. * The set callback will be triggered just after rendering the layer.
  14234. */
  14235. onAfterRender: () => void;
  14236. /**
  14237. * Instantiates a new layer.
  14238. * This represents a full screen 2d layer.
  14239. * This can be useful to display a picture in the background of your scene for instance.
  14240. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14241. * @param name Define the name of the layer in the scene
  14242. * @param imgUrl Define the url of the texture to display in the layer
  14243. * @param scene Define the scene the layer belongs to
  14244. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14245. * @param color Defines a color for the layer
  14246. */
  14247. constructor(
  14248. /**
  14249. * Define the name of the layer.
  14250. */
  14251. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14252. private _createIndexBuffer;
  14253. /** @hidden */
  14254. _rebuild(): void;
  14255. /**
  14256. * Renders the layer in the scene.
  14257. */
  14258. render(): void;
  14259. /**
  14260. * Disposes and releases the associated ressources.
  14261. */
  14262. dispose(): void;
  14263. }
  14264. }
  14265. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14266. import { Scene } from "babylonjs/scene";
  14267. import { ISceneComponent } from "babylonjs/sceneComponent";
  14268. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14269. module "babylonjs/abstractScene" {
  14270. interface AbstractScene {
  14271. /**
  14272. * The list of procedural textures added to the scene
  14273. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14274. */
  14275. proceduralTextures: Array<ProceduralTexture>;
  14276. }
  14277. }
  14278. /**
  14279. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14280. * in a given scene.
  14281. */
  14282. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14283. /**
  14284. * The component name helpfull to identify the component in the list of scene components.
  14285. */
  14286. readonly name: string;
  14287. /**
  14288. * The scene the component belongs to.
  14289. */
  14290. scene: Scene;
  14291. /**
  14292. * Creates a new instance of the component for the given scene
  14293. * @param scene Defines the scene to register the component in
  14294. */
  14295. constructor(scene: Scene);
  14296. /**
  14297. * Registers the component in a given scene
  14298. */
  14299. register(): void;
  14300. /**
  14301. * Rebuilds the elements related to this component in case of
  14302. * context lost for instance.
  14303. */
  14304. rebuild(): void;
  14305. /**
  14306. * Disposes the component and the associated ressources.
  14307. */
  14308. dispose(): void;
  14309. private _beforeClear;
  14310. }
  14311. }
  14312. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14313. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14314. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14315. module "babylonjs/Engines/engine" {
  14316. interface Engine {
  14317. /**
  14318. * Creates a new render target cube texture
  14319. * @param size defines the size of the texture
  14320. * @param options defines the options used to create the texture
  14321. * @returns a new render target cube texture stored in an InternalTexture
  14322. */
  14323. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14324. }
  14325. }
  14326. }
  14327. declare module "babylonjs/Shaders/procedural.vertex" {
  14328. /** @hidden */
  14329. export var proceduralVertexShader: {
  14330. name: string;
  14331. shader: string;
  14332. };
  14333. }
  14334. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14335. import { Observable } from "babylonjs/Misc/observable";
  14336. import { Nullable } from "babylonjs/types";
  14337. import { Scene } from "babylonjs/scene";
  14338. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14339. import { Effect } from "babylonjs/Materials/effect";
  14340. import { Texture } from "babylonjs/Materials/Textures/texture";
  14341. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14342. import "babylonjs/Shaders/procedural.vertex";
  14343. /**
  14344. * 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.
  14345. * This is the base class of any Procedural texture and contains most of the shareable code.
  14346. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14347. */
  14348. export class ProceduralTexture extends Texture {
  14349. isCube: boolean;
  14350. /**
  14351. * Define if the texture is enabled or not (disabled texture will not render)
  14352. */
  14353. isEnabled: boolean;
  14354. /**
  14355. * Define if the texture must be cleared before rendering (default is true)
  14356. */
  14357. autoClear: boolean;
  14358. /**
  14359. * Callback called when the texture is generated
  14360. */
  14361. onGenerated: () => void;
  14362. /**
  14363. * Event raised when the texture is generated
  14364. */
  14365. onGeneratedObservable: Observable<ProceduralTexture>;
  14366. /** @hidden */
  14367. _generateMipMaps: boolean;
  14368. /** @hidden **/
  14369. _effect: Effect;
  14370. /** @hidden */
  14371. _textures: {
  14372. [key: string]: Texture;
  14373. };
  14374. private _size;
  14375. private _currentRefreshId;
  14376. private _refreshRate;
  14377. private _vertexBuffers;
  14378. private _indexBuffer;
  14379. private _uniforms;
  14380. private _samplers;
  14381. private _fragment;
  14382. private _floats;
  14383. private _ints;
  14384. private _floatsArrays;
  14385. private _colors3;
  14386. private _colors4;
  14387. private _vectors2;
  14388. private _vectors3;
  14389. private _matrices;
  14390. private _fallbackTexture;
  14391. private _fallbackTextureUsed;
  14392. private _engine;
  14393. private _cachedDefines;
  14394. private _contentUpdateId;
  14395. private _contentData;
  14396. /**
  14397. * Instantiates a new procedural texture.
  14398. * 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.
  14399. * This is the base class of any Procedural texture and contains most of the shareable code.
  14400. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14401. * @param name Define the name of the texture
  14402. * @param size Define the size of the texture to create
  14403. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14404. * @param scene Define the scene the texture belongs to
  14405. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14406. * @param generateMipMaps Define if the texture should creates mip maps or not
  14407. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14408. */
  14409. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14410. /**
  14411. * The effect that is created when initializing the post process.
  14412. * @returns The created effect corrisponding the the postprocess.
  14413. */
  14414. getEffect(): Effect;
  14415. /**
  14416. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14417. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14418. */
  14419. getContent(): Nullable<ArrayBufferView>;
  14420. private _createIndexBuffer;
  14421. /** @hidden */
  14422. _rebuild(): void;
  14423. /**
  14424. * Resets the texture in order to recreate its associated resources.
  14425. * This can be called in case of context loss
  14426. */
  14427. reset(): void;
  14428. protected _getDefines(): string;
  14429. /**
  14430. * Is the texture ready to be used ? (rendered at least once)
  14431. * @returns true if ready, otherwise, false.
  14432. */
  14433. isReady(): boolean;
  14434. /**
  14435. * Resets the refresh counter of the texture and start bak from scratch.
  14436. * Could be useful to regenerate the texture if it is setup to render only once.
  14437. */
  14438. resetRefreshCounter(): void;
  14439. /**
  14440. * Set the fragment shader to use in order to render the texture.
  14441. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14442. */
  14443. setFragment(fragment: any): void;
  14444. /**
  14445. * Define the refresh rate of the texture or the rendering frequency.
  14446. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14447. */
  14448. refreshRate: number;
  14449. /** @hidden */
  14450. _shouldRender(): boolean;
  14451. /**
  14452. * Get the size the texture is rendering at.
  14453. * @returns the size (texture is always squared)
  14454. */
  14455. getRenderSize(): number;
  14456. /**
  14457. * Resize the texture to new value.
  14458. * @param size Define the new size the texture should have
  14459. * @param generateMipMaps Define whether the new texture should create mip maps
  14460. */
  14461. resize(size: number, generateMipMaps: boolean): void;
  14462. private _checkUniform;
  14463. /**
  14464. * Set a texture in the shader program used to render.
  14465. * @param name Define the name of the uniform samplers as defined in the shader
  14466. * @param texture Define the texture to bind to this sampler
  14467. * @return the texture itself allowing "fluent" like uniform updates
  14468. */
  14469. setTexture(name: string, texture: Texture): ProceduralTexture;
  14470. /**
  14471. * Set a float in the shader.
  14472. * @param name Define the name of the uniform as defined in the shader
  14473. * @param value Define the value to give to the uniform
  14474. * @return the texture itself allowing "fluent" like uniform updates
  14475. */
  14476. setFloat(name: string, value: number): ProceduralTexture;
  14477. /**
  14478. * Set a int in the shader.
  14479. * @param name Define the name of the uniform as defined in the shader
  14480. * @param value Define the value to give to the uniform
  14481. * @return the texture itself allowing "fluent" like uniform updates
  14482. */
  14483. setInt(name: string, value: number): ProceduralTexture;
  14484. /**
  14485. * Set an array of floats in the shader.
  14486. * @param name Define the name of the uniform as defined in the shader
  14487. * @param value Define the value to give to the uniform
  14488. * @return the texture itself allowing "fluent" like uniform updates
  14489. */
  14490. setFloats(name: string, value: number[]): ProceduralTexture;
  14491. /**
  14492. * Set a vec3 in the shader from a Color3.
  14493. * @param name Define the name of the uniform as defined in the shader
  14494. * @param value Define the value to give to the uniform
  14495. * @return the texture itself allowing "fluent" like uniform updates
  14496. */
  14497. setColor3(name: string, value: Color3): ProceduralTexture;
  14498. /**
  14499. * Set a vec4 in the shader from a Color4.
  14500. * @param name Define the name of the uniform as defined in the shader
  14501. * @param value Define the value to give to the uniform
  14502. * @return the texture itself allowing "fluent" like uniform updates
  14503. */
  14504. setColor4(name: string, value: Color4): ProceduralTexture;
  14505. /**
  14506. * Set a vec2 in the shader from a Vector2.
  14507. * @param name Define the name of the uniform as defined in the shader
  14508. * @param value Define the value to give to the uniform
  14509. * @return the texture itself allowing "fluent" like uniform updates
  14510. */
  14511. setVector2(name: string, value: Vector2): ProceduralTexture;
  14512. /**
  14513. * Set a vec3 in the shader from a Vector3.
  14514. * @param name Define the name of the uniform as defined in the shader
  14515. * @param value Define the value to give to the uniform
  14516. * @return the texture itself allowing "fluent" like uniform updates
  14517. */
  14518. setVector3(name: string, value: Vector3): ProceduralTexture;
  14519. /**
  14520. * Set a mat4 in the shader from a MAtrix.
  14521. * @param name Define the name of the uniform as defined in the shader
  14522. * @param value Define the value to give to the uniform
  14523. * @return the texture itself allowing "fluent" like uniform updates
  14524. */
  14525. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14526. /**
  14527. * Render the texture to its associated render target.
  14528. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14529. */
  14530. render(useCameraPostProcess?: boolean): void;
  14531. /**
  14532. * Clone the texture.
  14533. * @returns the cloned texture
  14534. */
  14535. clone(): ProceduralTexture;
  14536. /**
  14537. * Dispose the texture and release its asoociated resources.
  14538. */
  14539. dispose(): void;
  14540. }
  14541. }
  14542. declare module "babylonjs/Particles/baseParticleSystem" {
  14543. import { Nullable } from "babylonjs/types";
  14544. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14546. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14547. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14548. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14549. import { Scene } from "babylonjs/scene";
  14550. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14551. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14552. import { Texture } from "babylonjs/Materials/Textures/texture";
  14553. import { Animation } from "babylonjs/Animations/animation";
  14554. /**
  14555. * This represents the base class for particle system in Babylon.
  14556. * 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.
  14557. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14558. * @example https://doc.babylonjs.com/babylon101/particles
  14559. */
  14560. export class BaseParticleSystem {
  14561. /**
  14562. * Source color is added to the destination color without alpha affecting the result
  14563. */
  14564. static BLENDMODE_ONEONE: number;
  14565. /**
  14566. * Blend current color and particle color using particle’s alpha
  14567. */
  14568. static BLENDMODE_STANDARD: number;
  14569. /**
  14570. * Add current color and particle color multiplied by particle’s alpha
  14571. */
  14572. static BLENDMODE_ADD: number;
  14573. /**
  14574. * Multiply current color with particle color
  14575. */
  14576. static BLENDMODE_MULTIPLY: number;
  14577. /**
  14578. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14579. */
  14580. static BLENDMODE_MULTIPLYADD: number;
  14581. /**
  14582. * List of animations used by the particle system.
  14583. */
  14584. animations: Animation[];
  14585. /**
  14586. * The id of the Particle system.
  14587. */
  14588. id: string;
  14589. /**
  14590. * The friendly name of the Particle system.
  14591. */
  14592. name: string;
  14593. /**
  14594. * The rendering group used by the Particle system to chose when to render.
  14595. */
  14596. renderingGroupId: number;
  14597. /**
  14598. * The emitter represents the Mesh or position we are attaching the particle system to.
  14599. */
  14600. emitter: Nullable<AbstractMesh | Vector3>;
  14601. /**
  14602. * The maximum number of particles to emit per frame
  14603. */
  14604. emitRate: number;
  14605. /**
  14606. * If you want to launch only a few particles at once, that can be done, as well.
  14607. */
  14608. manualEmitCount: number;
  14609. /**
  14610. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14611. */
  14612. updateSpeed: number;
  14613. /**
  14614. * The amount of time the particle system is running (depends of the overall update speed).
  14615. */
  14616. targetStopDuration: number;
  14617. /**
  14618. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14619. */
  14620. disposeOnStop: boolean;
  14621. /**
  14622. * Minimum power of emitting particles.
  14623. */
  14624. minEmitPower: number;
  14625. /**
  14626. * Maximum power of emitting particles.
  14627. */
  14628. maxEmitPower: number;
  14629. /**
  14630. * Minimum life time of emitting particles.
  14631. */
  14632. minLifeTime: number;
  14633. /**
  14634. * Maximum life time of emitting particles.
  14635. */
  14636. maxLifeTime: number;
  14637. /**
  14638. * Minimum Size of emitting particles.
  14639. */
  14640. minSize: number;
  14641. /**
  14642. * Maximum Size of emitting particles.
  14643. */
  14644. maxSize: number;
  14645. /**
  14646. * Minimum scale of emitting particles on X axis.
  14647. */
  14648. minScaleX: number;
  14649. /**
  14650. * Maximum scale of emitting particles on X axis.
  14651. */
  14652. maxScaleX: number;
  14653. /**
  14654. * Minimum scale of emitting particles on Y axis.
  14655. */
  14656. minScaleY: number;
  14657. /**
  14658. * Maximum scale of emitting particles on Y axis.
  14659. */
  14660. maxScaleY: number;
  14661. /**
  14662. * Gets or sets the minimal initial rotation in radians.
  14663. */
  14664. minInitialRotation: number;
  14665. /**
  14666. * Gets or sets the maximal initial rotation in radians.
  14667. */
  14668. maxInitialRotation: number;
  14669. /**
  14670. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14671. */
  14672. minAngularSpeed: number;
  14673. /**
  14674. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14675. */
  14676. maxAngularSpeed: number;
  14677. /**
  14678. * The texture used to render each particle. (this can be a spritesheet)
  14679. */
  14680. particleTexture: Nullable<Texture>;
  14681. /**
  14682. * The layer mask we are rendering the particles through.
  14683. */
  14684. layerMask: number;
  14685. /**
  14686. * This can help using your own shader to render the particle system.
  14687. * The according effect will be created
  14688. */
  14689. customShader: any;
  14690. /**
  14691. * By default particle system starts as soon as they are created. This prevents the
  14692. * automatic start to happen and let you decide when to start emitting particles.
  14693. */
  14694. preventAutoStart: boolean;
  14695. private _noiseTexture;
  14696. /**
  14697. * Gets or sets a texture used to add random noise to particle positions
  14698. */
  14699. noiseTexture: Nullable<ProceduralTexture>;
  14700. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14701. noiseStrength: Vector3;
  14702. /**
  14703. * Callback triggered when the particle animation is ending.
  14704. */
  14705. onAnimationEnd: Nullable<() => void>;
  14706. /**
  14707. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14708. */
  14709. blendMode: number;
  14710. /**
  14711. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14712. * to override the particles.
  14713. */
  14714. forceDepthWrite: boolean;
  14715. /** 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 */
  14716. preWarmCycles: number;
  14717. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14718. preWarmStepOffset: number;
  14719. /**
  14720. * 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)
  14721. */
  14722. spriteCellChangeSpeed: number;
  14723. /**
  14724. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14725. */
  14726. startSpriteCellID: number;
  14727. /**
  14728. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14729. */
  14730. endSpriteCellID: number;
  14731. /**
  14732. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14733. */
  14734. spriteCellWidth: number;
  14735. /**
  14736. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14737. */
  14738. spriteCellHeight: number;
  14739. /**
  14740. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14741. */
  14742. spriteRandomStartCell: boolean;
  14743. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14744. translationPivot: Vector2;
  14745. /** @hidden */
  14746. protected _isAnimationSheetEnabled: boolean;
  14747. /**
  14748. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14749. */
  14750. beginAnimationOnStart: boolean;
  14751. /**
  14752. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14753. */
  14754. beginAnimationFrom: number;
  14755. /**
  14756. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14757. */
  14758. beginAnimationTo: number;
  14759. /**
  14760. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14761. */
  14762. beginAnimationLoop: boolean;
  14763. /**
  14764. * Gets or sets a world offset applied to all particles
  14765. */
  14766. worldOffset: Vector3;
  14767. /**
  14768. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14769. */
  14770. isAnimationSheetEnabled: boolean;
  14771. /**
  14772. * Get hosting scene
  14773. * @returns the scene
  14774. */
  14775. getScene(): Scene;
  14776. /**
  14777. * You can use gravity if you want to give an orientation to your particles.
  14778. */
  14779. gravity: Vector3;
  14780. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14781. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14782. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14783. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14784. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14785. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14786. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14787. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14788. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14789. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14790. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14791. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14792. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14793. /**
  14794. * Defines the delay in milliseconds before starting the system (0 by default)
  14795. */
  14796. startDelay: number;
  14797. /**
  14798. * Gets the current list of drag gradients.
  14799. * You must use addDragGradient and removeDragGradient to udpate this list
  14800. * @returns the list of drag gradients
  14801. */
  14802. getDragGradients(): Nullable<Array<FactorGradient>>;
  14803. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14804. limitVelocityDamping: number;
  14805. /**
  14806. * Gets the current list of limit velocity gradients.
  14807. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14808. * @returns the list of limit velocity gradients
  14809. */
  14810. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14811. /**
  14812. * Gets the current list of color gradients.
  14813. * You must use addColorGradient and removeColorGradient to udpate this list
  14814. * @returns the list of color gradients
  14815. */
  14816. getColorGradients(): Nullable<Array<ColorGradient>>;
  14817. /**
  14818. * Gets the current list of size gradients.
  14819. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14820. * @returns the list of size gradients
  14821. */
  14822. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14823. /**
  14824. * Gets the current list of color remap gradients.
  14825. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14826. * @returns the list of color remap gradients
  14827. */
  14828. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14829. /**
  14830. * Gets the current list of alpha remap gradients.
  14831. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14832. * @returns the list of alpha remap gradients
  14833. */
  14834. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14835. /**
  14836. * Gets the current list of life time gradients.
  14837. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14838. * @returns the list of life time gradients
  14839. */
  14840. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14841. /**
  14842. * Gets the current list of angular speed gradients.
  14843. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14844. * @returns the list of angular speed gradients
  14845. */
  14846. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14847. /**
  14848. * Gets the current list of velocity gradients.
  14849. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14850. * @returns the list of velocity gradients
  14851. */
  14852. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14853. /**
  14854. * Gets the current list of start size gradients.
  14855. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14856. * @returns the list of start size gradients
  14857. */
  14858. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14859. /**
  14860. * Gets the current list of emit rate gradients.
  14861. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14862. * @returns the list of emit rate gradients
  14863. */
  14864. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14865. /**
  14866. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14867. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14868. */
  14869. direction1: Vector3;
  14870. /**
  14871. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14872. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14873. */
  14874. direction2: Vector3;
  14875. /**
  14876. * 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.
  14877. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14878. */
  14879. minEmitBox: Vector3;
  14880. /**
  14881. * 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.
  14882. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14883. */
  14884. maxEmitBox: Vector3;
  14885. /**
  14886. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14887. */
  14888. color1: Color4;
  14889. /**
  14890. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14891. */
  14892. color2: Color4;
  14893. /**
  14894. * Color the particle will have at the end of its lifetime
  14895. */
  14896. colorDead: Color4;
  14897. /**
  14898. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14899. */
  14900. textureMask: Color4;
  14901. /**
  14902. * The particle emitter type defines the emitter used by the particle system.
  14903. * It can be for example box, sphere, or cone...
  14904. */
  14905. particleEmitterType: IParticleEmitterType;
  14906. /** @hidden */
  14907. _isSubEmitter: boolean;
  14908. /**
  14909. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14910. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14911. */
  14912. billboardMode: number;
  14913. protected _isBillboardBased: boolean;
  14914. /**
  14915. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14916. */
  14917. isBillboardBased: boolean;
  14918. /**
  14919. * The scene the particle system belongs to.
  14920. */
  14921. protected _scene: Scene;
  14922. /**
  14923. * Local cache of defines for image processing.
  14924. */
  14925. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14926. /**
  14927. * Default configuration related to image processing available in the standard Material.
  14928. */
  14929. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14930. /**
  14931. * Gets the image processing configuration used either in this material.
  14932. */
  14933. /**
  14934. * Sets the Default image processing configuration used either in the this material.
  14935. *
  14936. * If sets to null, the scene one is in use.
  14937. */
  14938. imageProcessingConfiguration: ImageProcessingConfiguration;
  14939. /**
  14940. * Attaches a new image processing configuration to the Standard Material.
  14941. * @param configuration
  14942. */
  14943. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14944. /** @hidden */
  14945. protected _reset(): void;
  14946. /** @hidden */
  14947. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14948. /**
  14949. * Instantiates a particle system.
  14950. * 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.
  14951. * @param name The name of the particle system
  14952. */
  14953. constructor(name: string);
  14954. /**
  14955. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14956. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14957. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14958. * @returns the emitter
  14959. */
  14960. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14961. /**
  14962. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14963. * @param radius The radius of the hemisphere to emit from
  14964. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14965. * @returns the emitter
  14966. */
  14967. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14968. /**
  14969. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14970. * @param radius The radius of the sphere to emit from
  14971. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14972. * @returns the emitter
  14973. */
  14974. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14975. /**
  14976. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14977. * @param radius The radius of the sphere to emit from
  14978. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14979. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14980. * @returns the emitter
  14981. */
  14982. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14983. /**
  14984. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14985. * @param radius The radius of the emission cylinder
  14986. * @param height The height of the emission cylinder
  14987. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14988. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14989. * @returns the emitter
  14990. */
  14991. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14992. /**
  14993. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14994. * @param radius The radius of the cylinder to emit from
  14995. * @param height The height of the emission cylinder
  14996. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14997. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14998. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14999. * @returns the emitter
  15000. */
  15001. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15002. /**
  15003. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15004. * @param radius The radius of the cone to emit from
  15005. * @param angle The base angle of the cone
  15006. * @returns the emitter
  15007. */
  15008. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15009. /**
  15010. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15011. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15012. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15013. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15014. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15015. * @returns the emitter
  15016. */
  15017. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15018. }
  15019. }
  15020. declare module "babylonjs/Particles/subEmitter" {
  15021. import { Scene } from "babylonjs/scene";
  15022. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15023. /**
  15024. * Type of sub emitter
  15025. */
  15026. export enum SubEmitterType {
  15027. /**
  15028. * Attached to the particle over it's lifetime
  15029. */
  15030. ATTACHED = 0,
  15031. /**
  15032. * Created when the particle dies
  15033. */
  15034. END = 1
  15035. }
  15036. /**
  15037. * Sub emitter class used to emit particles from an existing particle
  15038. */
  15039. export class SubEmitter {
  15040. /**
  15041. * the particle system to be used by the sub emitter
  15042. */
  15043. particleSystem: ParticleSystem;
  15044. /**
  15045. * Type of the submitter (Default: END)
  15046. */
  15047. type: SubEmitterType;
  15048. /**
  15049. * 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)
  15050. * Note: This only is supported when using an emitter of type Mesh
  15051. */
  15052. inheritDirection: boolean;
  15053. /**
  15054. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15055. */
  15056. inheritedVelocityAmount: number;
  15057. /**
  15058. * Creates a sub emitter
  15059. * @param particleSystem the particle system to be used by the sub emitter
  15060. */
  15061. constructor(
  15062. /**
  15063. * the particle system to be used by the sub emitter
  15064. */
  15065. particleSystem: ParticleSystem);
  15066. /**
  15067. * Clones the sub emitter
  15068. * @returns the cloned sub emitter
  15069. */
  15070. clone(): SubEmitter;
  15071. /**
  15072. * Serialize current object to a JSON object
  15073. * @returns the serialized object
  15074. */
  15075. serialize(): any;
  15076. /** @hidden */
  15077. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15078. /**
  15079. * Creates a new SubEmitter from a serialized JSON version
  15080. * @param serializationObject defines the JSON object to read from
  15081. * @param scene defines the hosting scene
  15082. * @param rootUrl defines the rootUrl for data loading
  15083. * @returns a new SubEmitter
  15084. */
  15085. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15086. /** Release associated resources */
  15087. dispose(): void;
  15088. }
  15089. }
  15090. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15091. /** @hidden */
  15092. export var clipPlaneFragmentDeclaration: {
  15093. name: string;
  15094. shader: string;
  15095. };
  15096. }
  15097. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15098. /** @hidden */
  15099. export var imageProcessingDeclaration: {
  15100. name: string;
  15101. shader: string;
  15102. };
  15103. }
  15104. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15105. /** @hidden */
  15106. export var imageProcessingFunctions: {
  15107. name: string;
  15108. shader: string;
  15109. };
  15110. }
  15111. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15112. /** @hidden */
  15113. export var clipPlaneFragment: {
  15114. name: string;
  15115. shader: string;
  15116. };
  15117. }
  15118. declare module "babylonjs/Shaders/particles.fragment" {
  15119. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15120. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15121. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15122. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15123. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15124. /** @hidden */
  15125. export var particlesPixelShader: {
  15126. name: string;
  15127. shader: string;
  15128. };
  15129. }
  15130. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15131. /** @hidden */
  15132. export var clipPlaneVertexDeclaration: {
  15133. name: string;
  15134. shader: string;
  15135. };
  15136. }
  15137. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15138. /** @hidden */
  15139. export var clipPlaneVertex: {
  15140. name: string;
  15141. shader: string;
  15142. };
  15143. }
  15144. declare module "babylonjs/Shaders/particles.vertex" {
  15145. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15146. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15147. /** @hidden */
  15148. export var particlesVertexShader: {
  15149. name: string;
  15150. shader: string;
  15151. };
  15152. }
  15153. declare module "babylonjs/Particles/particleSystem" {
  15154. import { Nullable } from "babylonjs/types";
  15155. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15156. import { Observable } from "babylonjs/Misc/observable";
  15157. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15158. import { Effect } from "babylonjs/Materials/effect";
  15159. import { Scene, IDisposable } from "babylonjs/scene";
  15160. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15161. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15162. import { Particle } from "babylonjs/Particles/particle";
  15163. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15164. import "babylonjs/Shaders/particles.fragment";
  15165. import "babylonjs/Shaders/particles.vertex";
  15166. /**
  15167. * This represents a particle system in Babylon.
  15168. * 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.
  15169. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15170. * @example https://doc.babylonjs.com/babylon101/particles
  15171. */
  15172. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15173. /**
  15174. * Billboard mode will only apply to Y axis
  15175. */
  15176. static readonly BILLBOARDMODE_Y: number;
  15177. /**
  15178. * Billboard mode will apply to all axes
  15179. */
  15180. static readonly BILLBOARDMODE_ALL: number;
  15181. /**
  15182. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15183. */
  15184. static readonly BILLBOARDMODE_STRETCHED: number;
  15185. /**
  15186. * This function can be defined to provide custom update for active particles.
  15187. * This function will be called instead of regular update (age, position, color, etc.).
  15188. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15189. */
  15190. updateFunction: (particles: Particle[]) => void;
  15191. private _emitterWorldMatrix;
  15192. /**
  15193. * This function can be defined to specify initial direction for every new particle.
  15194. * It by default use the emitterType defined function
  15195. */
  15196. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15197. /**
  15198. * This function can be defined to specify initial position for every new particle.
  15199. * It by default use the emitterType defined function
  15200. */
  15201. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15202. /**
  15203. * @hidden
  15204. */
  15205. _inheritedVelocityOffset: Vector3;
  15206. /**
  15207. * An event triggered when the system is disposed
  15208. */
  15209. onDisposeObservable: Observable<ParticleSystem>;
  15210. private _onDisposeObserver;
  15211. /**
  15212. * Sets a callback that will be triggered when the system is disposed
  15213. */
  15214. onDispose: () => void;
  15215. private _particles;
  15216. private _epsilon;
  15217. private _capacity;
  15218. private _stockParticles;
  15219. private _newPartsExcess;
  15220. private _vertexData;
  15221. private _vertexBuffer;
  15222. private _vertexBuffers;
  15223. private _spriteBuffer;
  15224. private _indexBuffer;
  15225. private _effect;
  15226. private _customEffect;
  15227. private _cachedDefines;
  15228. private _scaledColorStep;
  15229. private _colorDiff;
  15230. private _scaledDirection;
  15231. private _scaledGravity;
  15232. private _currentRenderId;
  15233. private _alive;
  15234. private _useInstancing;
  15235. private _started;
  15236. private _stopped;
  15237. private _actualFrame;
  15238. private _scaledUpdateSpeed;
  15239. private _vertexBufferSize;
  15240. /** @hidden */
  15241. _currentEmitRateGradient: Nullable<FactorGradient>;
  15242. /** @hidden */
  15243. _currentEmitRate1: number;
  15244. /** @hidden */
  15245. _currentEmitRate2: number;
  15246. /** @hidden */
  15247. _currentStartSizeGradient: Nullable<FactorGradient>;
  15248. /** @hidden */
  15249. _currentStartSize1: number;
  15250. /** @hidden */
  15251. _currentStartSize2: number;
  15252. private readonly _rawTextureWidth;
  15253. private _rampGradientsTexture;
  15254. private _useRampGradients;
  15255. /** Gets or sets a boolean indicating that ramp gradients must be used
  15256. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15257. */
  15258. useRampGradients: boolean;
  15259. /**
  15260. * 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.
  15261. * 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: [])
  15262. */
  15263. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15264. private _subEmitters;
  15265. /**
  15266. * @hidden
  15267. * If the particle systems emitter should be disposed when the particle system is disposed
  15268. */
  15269. _disposeEmitterOnDispose: boolean;
  15270. /**
  15271. * The current active Sub-systems, this property is used by the root particle system only.
  15272. */
  15273. activeSubSystems: Array<ParticleSystem>;
  15274. private _rootParticleSystem;
  15275. /**
  15276. * Gets the current list of active particles
  15277. */
  15278. readonly particles: Particle[];
  15279. /**
  15280. * Returns the string "ParticleSystem"
  15281. * @returns a string containing the class name
  15282. */
  15283. getClassName(): string;
  15284. /**
  15285. * Instantiates a particle system.
  15286. * 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.
  15287. * @param name The name of the particle system
  15288. * @param capacity The max number of particles alive at the same time
  15289. * @param scene The scene the particle system belongs to
  15290. * @param customEffect a custom effect used to change the way particles are rendered by default
  15291. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15292. * @param epsilon Offset used to render the particles
  15293. */
  15294. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15295. private _addFactorGradient;
  15296. private _removeFactorGradient;
  15297. /**
  15298. * Adds a new life time gradient
  15299. * @param gradient defines the gradient to use (between 0 and 1)
  15300. * @param factor defines the life time factor to affect to the specified gradient
  15301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15302. * @returns the current particle system
  15303. */
  15304. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15305. /**
  15306. * Remove a specific life time gradient
  15307. * @param gradient defines the gradient to remove
  15308. * @returns the current particle system
  15309. */
  15310. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15311. /**
  15312. * Adds a new size gradient
  15313. * @param gradient defines the gradient to use (between 0 and 1)
  15314. * @param factor defines the size factor to affect to the specified gradient
  15315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15316. * @returns the current particle system
  15317. */
  15318. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15319. /**
  15320. * Remove a specific size gradient
  15321. * @param gradient defines the gradient to remove
  15322. * @returns the current particle system
  15323. */
  15324. removeSizeGradient(gradient: number): IParticleSystem;
  15325. /**
  15326. * Adds a new color remap gradient
  15327. * @param gradient defines the gradient to use (between 0 and 1)
  15328. * @param min defines the color remap minimal range
  15329. * @param max defines the color remap maximal range
  15330. * @returns the current particle system
  15331. */
  15332. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15333. /**
  15334. * Remove a specific color remap gradient
  15335. * @param gradient defines the gradient to remove
  15336. * @returns the current particle system
  15337. */
  15338. removeColorRemapGradient(gradient: number): IParticleSystem;
  15339. /**
  15340. * Adds a new alpha remap gradient
  15341. * @param gradient defines the gradient to use (between 0 and 1)
  15342. * @param min defines the alpha remap minimal range
  15343. * @param max defines the alpha remap maximal range
  15344. * @returns the current particle system
  15345. */
  15346. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15347. /**
  15348. * Remove a specific alpha remap gradient
  15349. * @param gradient defines the gradient to remove
  15350. * @returns the current particle system
  15351. */
  15352. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15353. /**
  15354. * Adds a new angular speed gradient
  15355. * @param gradient defines the gradient to use (between 0 and 1)
  15356. * @param factor defines the angular speed to affect to the specified gradient
  15357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15358. * @returns the current particle system
  15359. */
  15360. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15361. /**
  15362. * Remove a specific angular speed gradient
  15363. * @param gradient defines the gradient to remove
  15364. * @returns the current particle system
  15365. */
  15366. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15367. /**
  15368. * Adds a new velocity gradient
  15369. * @param gradient defines the gradient to use (between 0 and 1)
  15370. * @param factor defines the velocity to affect to the specified gradient
  15371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15372. * @returns the current particle system
  15373. */
  15374. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15375. /**
  15376. * Remove a specific velocity gradient
  15377. * @param gradient defines the gradient to remove
  15378. * @returns the current particle system
  15379. */
  15380. removeVelocityGradient(gradient: number): IParticleSystem;
  15381. /**
  15382. * Adds a new limit velocity gradient
  15383. * @param gradient defines the gradient to use (between 0 and 1)
  15384. * @param factor defines the limit velocity value to affect to the specified gradient
  15385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15386. * @returns the current particle system
  15387. */
  15388. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15389. /**
  15390. * Remove a specific limit velocity gradient
  15391. * @param gradient defines the gradient to remove
  15392. * @returns the current particle system
  15393. */
  15394. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15395. /**
  15396. * Adds a new drag gradient
  15397. * @param gradient defines the gradient to use (between 0 and 1)
  15398. * @param factor defines the drag value to affect to the specified gradient
  15399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15400. * @returns the current particle system
  15401. */
  15402. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15403. /**
  15404. * Remove a specific drag gradient
  15405. * @param gradient defines the gradient to remove
  15406. * @returns the current particle system
  15407. */
  15408. removeDragGradient(gradient: number): IParticleSystem;
  15409. /**
  15410. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15411. * @param gradient defines the gradient to use (between 0 and 1)
  15412. * @param factor defines the emit rate value to affect to the specified gradient
  15413. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15414. * @returns the current particle system
  15415. */
  15416. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15417. /**
  15418. * Remove a specific emit rate gradient
  15419. * @param gradient defines the gradient to remove
  15420. * @returns the current particle system
  15421. */
  15422. removeEmitRateGradient(gradient: number): IParticleSystem;
  15423. /**
  15424. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15425. * @param gradient defines the gradient to use (between 0 and 1)
  15426. * @param factor defines the start size value to affect to the specified gradient
  15427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15428. * @returns the current particle system
  15429. */
  15430. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15431. /**
  15432. * Remove a specific start size gradient
  15433. * @param gradient defines the gradient to remove
  15434. * @returns the current particle system
  15435. */
  15436. removeStartSizeGradient(gradient: number): IParticleSystem;
  15437. private _createRampGradientTexture;
  15438. /**
  15439. * Gets the current list of ramp gradients.
  15440. * You must use addRampGradient and removeRampGradient to udpate this list
  15441. * @returns the list of ramp gradients
  15442. */
  15443. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15444. /**
  15445. * Adds a new ramp gradient used to remap particle colors
  15446. * @param gradient defines the gradient to use (between 0 and 1)
  15447. * @param color defines the color to affect to the specified gradient
  15448. * @returns the current particle system
  15449. */
  15450. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15451. /**
  15452. * Remove a specific ramp gradient
  15453. * @param gradient defines the gradient to remove
  15454. * @returns the current particle system
  15455. */
  15456. removeRampGradient(gradient: number): ParticleSystem;
  15457. /**
  15458. * Adds a new color gradient
  15459. * @param gradient defines the gradient to use (between 0 and 1)
  15460. * @param color1 defines the color to affect to the specified gradient
  15461. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15462. * @returns this particle system
  15463. */
  15464. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15465. /**
  15466. * Remove a specific color gradient
  15467. * @param gradient defines the gradient to remove
  15468. * @returns this particle system
  15469. */
  15470. removeColorGradient(gradient: number): IParticleSystem;
  15471. private _fetchR;
  15472. protected _reset(): void;
  15473. private _resetEffect;
  15474. private _createVertexBuffers;
  15475. private _createIndexBuffer;
  15476. /**
  15477. * Gets the maximum number of particles active at the same time.
  15478. * @returns The max number of active particles.
  15479. */
  15480. getCapacity(): number;
  15481. /**
  15482. * Gets whether there are still active particles in the system.
  15483. * @returns True if it is alive, otherwise false.
  15484. */
  15485. isAlive(): boolean;
  15486. /**
  15487. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15488. * @returns True if it has been started, otherwise false.
  15489. */
  15490. isStarted(): boolean;
  15491. private _prepareSubEmitterInternalArray;
  15492. /**
  15493. * Starts the particle system and begins to emit
  15494. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15495. */
  15496. start(delay?: number): void;
  15497. /**
  15498. * Stops the particle system.
  15499. * @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.
  15500. */
  15501. stop(stopSubEmitters?: boolean): void;
  15502. /**
  15503. * Remove all active particles
  15504. */
  15505. reset(): void;
  15506. /**
  15507. * @hidden (for internal use only)
  15508. */
  15509. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15510. /**
  15511. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15512. * Its lifetime will start back at 0.
  15513. */
  15514. recycleParticle: (particle: Particle) => void;
  15515. private _stopSubEmitters;
  15516. private _createParticle;
  15517. private _removeFromRoot;
  15518. private _emitFromParticle;
  15519. private _update;
  15520. /** @hidden */
  15521. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15522. /** @hidden */
  15523. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15524. /** @hidden */
  15525. private _getEffect;
  15526. /**
  15527. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15528. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15529. */
  15530. animate(preWarmOnly?: boolean): void;
  15531. private _appendParticleVertices;
  15532. /**
  15533. * Rebuilds the particle system.
  15534. */
  15535. rebuild(): void;
  15536. /**
  15537. * Is this system ready to be used/rendered
  15538. * @return true if the system is ready
  15539. */
  15540. isReady(): boolean;
  15541. private _render;
  15542. /**
  15543. * Renders the particle system in its current state.
  15544. * @returns the current number of particles
  15545. */
  15546. render(): number;
  15547. /**
  15548. * Disposes the particle system and free the associated resources
  15549. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15550. */
  15551. dispose(disposeTexture?: boolean): void;
  15552. /**
  15553. * Clones the particle system.
  15554. * @param name The name of the cloned object
  15555. * @param newEmitter The new emitter to use
  15556. * @returns the cloned particle system
  15557. */
  15558. clone(name: string, newEmitter: any): ParticleSystem;
  15559. /**
  15560. * Serializes the particle system to a JSON object.
  15561. * @returns the JSON object
  15562. */
  15563. serialize(): any;
  15564. /** @hidden */
  15565. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15566. /** @hidden */
  15567. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15568. /**
  15569. * Parses a JSON object to create a particle system.
  15570. * @param parsedParticleSystem The JSON object to parse
  15571. * @param scene The scene to create the particle system in
  15572. * @param rootUrl The root url to use to load external dependencies like texture
  15573. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15574. * @returns the Parsed particle system
  15575. */
  15576. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15577. }
  15578. }
  15579. declare module "babylonjs/Particles/particle" {
  15580. import { Nullable } from "babylonjs/types";
  15581. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15582. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15583. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15584. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15585. /**
  15586. * A particle represents one of the element emitted by a particle system.
  15587. * This is mainly define by its coordinates, direction, velocity and age.
  15588. */
  15589. export class Particle {
  15590. /**
  15591. * The particle system the particle belongs to.
  15592. */
  15593. particleSystem: ParticleSystem;
  15594. private static _Count;
  15595. /**
  15596. * Unique ID of the particle
  15597. */
  15598. id: number;
  15599. /**
  15600. * The world position of the particle in the scene.
  15601. */
  15602. position: Vector3;
  15603. /**
  15604. * The world direction of the particle in the scene.
  15605. */
  15606. direction: Vector3;
  15607. /**
  15608. * The color of the particle.
  15609. */
  15610. color: Color4;
  15611. /**
  15612. * The color change of the particle per step.
  15613. */
  15614. colorStep: Color4;
  15615. /**
  15616. * Defines how long will the life of the particle be.
  15617. */
  15618. lifeTime: number;
  15619. /**
  15620. * The current age of the particle.
  15621. */
  15622. age: number;
  15623. /**
  15624. * The current size of the particle.
  15625. */
  15626. size: number;
  15627. /**
  15628. * The current scale of the particle.
  15629. */
  15630. scale: Vector2;
  15631. /**
  15632. * The current angle of the particle.
  15633. */
  15634. angle: number;
  15635. /**
  15636. * Defines how fast is the angle changing.
  15637. */
  15638. angularSpeed: number;
  15639. /**
  15640. * Defines the cell index used by the particle to be rendered from a sprite.
  15641. */
  15642. cellIndex: number;
  15643. /**
  15644. * The information required to support color remapping
  15645. */
  15646. remapData: Vector4;
  15647. /** @hidden */
  15648. _randomCellOffset?: number;
  15649. /** @hidden */
  15650. _initialDirection: Nullable<Vector3>;
  15651. /** @hidden */
  15652. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15653. /** @hidden */
  15654. _initialStartSpriteCellID: number;
  15655. /** @hidden */
  15656. _initialEndSpriteCellID: number;
  15657. /** @hidden */
  15658. _currentColorGradient: Nullable<ColorGradient>;
  15659. /** @hidden */
  15660. _currentColor1: Color4;
  15661. /** @hidden */
  15662. _currentColor2: Color4;
  15663. /** @hidden */
  15664. _currentSizeGradient: Nullable<FactorGradient>;
  15665. /** @hidden */
  15666. _currentSize1: number;
  15667. /** @hidden */
  15668. _currentSize2: number;
  15669. /** @hidden */
  15670. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15671. /** @hidden */
  15672. _currentAngularSpeed1: number;
  15673. /** @hidden */
  15674. _currentAngularSpeed2: number;
  15675. /** @hidden */
  15676. _currentVelocityGradient: Nullable<FactorGradient>;
  15677. /** @hidden */
  15678. _currentVelocity1: number;
  15679. /** @hidden */
  15680. _currentVelocity2: number;
  15681. /** @hidden */
  15682. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15683. /** @hidden */
  15684. _currentLimitVelocity1: number;
  15685. /** @hidden */
  15686. _currentLimitVelocity2: number;
  15687. /** @hidden */
  15688. _currentDragGradient: Nullable<FactorGradient>;
  15689. /** @hidden */
  15690. _currentDrag1: number;
  15691. /** @hidden */
  15692. _currentDrag2: number;
  15693. /** @hidden */
  15694. _randomNoiseCoordinates1: Vector3;
  15695. /** @hidden */
  15696. _randomNoiseCoordinates2: Vector3;
  15697. /**
  15698. * Creates a new instance Particle
  15699. * @param particleSystem the particle system the particle belongs to
  15700. */
  15701. constructor(
  15702. /**
  15703. * The particle system the particle belongs to.
  15704. */
  15705. particleSystem: ParticleSystem);
  15706. private updateCellInfoFromSystem;
  15707. /**
  15708. * Defines how the sprite cell index is updated for the particle
  15709. */
  15710. updateCellIndex(): void;
  15711. /** @hidden */
  15712. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15713. /** @hidden */
  15714. _inheritParticleInfoToSubEmitters(): void;
  15715. /** @hidden */
  15716. _reset(): void;
  15717. /**
  15718. * Copy the properties of particle to another one.
  15719. * @param other the particle to copy the information to.
  15720. */
  15721. copyTo(other: Particle): void;
  15722. }
  15723. }
  15724. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15725. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15726. import { Effect } from "babylonjs/Materials/effect";
  15727. import { Particle } from "babylonjs/Particles/particle";
  15728. /**
  15729. * Particle emitter represents a volume emitting particles.
  15730. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15731. */
  15732. export interface IParticleEmitterType {
  15733. /**
  15734. * Called by the particle System when the direction is computed for the created particle.
  15735. * @param worldMatrix is the world matrix of the particle system
  15736. * @param directionToUpdate is the direction vector to update with the result
  15737. * @param particle is the particle we are computed the direction for
  15738. */
  15739. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15740. /**
  15741. * Called by the particle System when the position is computed for the created particle.
  15742. * @param worldMatrix is the world matrix of the particle system
  15743. * @param positionToUpdate is the position vector to update with the result
  15744. * @param particle is the particle we are computed the position for
  15745. */
  15746. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15747. /**
  15748. * Clones the current emitter and returns a copy of it
  15749. * @returns the new emitter
  15750. */
  15751. clone(): IParticleEmitterType;
  15752. /**
  15753. * Called by the GPUParticleSystem to setup the update shader
  15754. * @param effect defines the update shader
  15755. */
  15756. applyToShader(effect: Effect): void;
  15757. /**
  15758. * Returns a string to use to update the GPU particles update shader
  15759. * @returns the effect defines string
  15760. */
  15761. getEffectDefines(): string;
  15762. /**
  15763. * Returns a string representing the class name
  15764. * @returns a string containing the class name
  15765. */
  15766. getClassName(): string;
  15767. /**
  15768. * Serializes the particle system to a JSON object.
  15769. * @returns the JSON object
  15770. */
  15771. serialize(): any;
  15772. /**
  15773. * Parse properties from a JSON object
  15774. * @param serializationObject defines the JSON object
  15775. */
  15776. parse(serializationObject: any): void;
  15777. }
  15778. }
  15779. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15780. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15781. import { Effect } from "babylonjs/Materials/effect";
  15782. import { Particle } from "babylonjs/Particles/particle";
  15783. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15784. /**
  15785. * Particle emitter emitting particles from the inside of a box.
  15786. * It emits the particles randomly between 2 given directions.
  15787. */
  15788. export class BoxParticleEmitter implements IParticleEmitterType {
  15789. /**
  15790. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15791. */
  15792. direction1: Vector3;
  15793. /**
  15794. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15795. */
  15796. direction2: Vector3;
  15797. /**
  15798. * 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.
  15799. */
  15800. minEmitBox: Vector3;
  15801. /**
  15802. * 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.
  15803. */
  15804. maxEmitBox: Vector3;
  15805. /**
  15806. * Creates a new instance BoxParticleEmitter
  15807. */
  15808. constructor();
  15809. /**
  15810. * Called by the particle System when the direction is computed for the created particle.
  15811. * @param worldMatrix is the world matrix of the particle system
  15812. * @param directionToUpdate is the direction vector to update with the result
  15813. * @param particle is the particle we are computed the direction for
  15814. */
  15815. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15816. /**
  15817. * Called by the particle System when the position is computed for the created particle.
  15818. * @param worldMatrix is the world matrix of the particle system
  15819. * @param positionToUpdate is the position vector to update with the result
  15820. * @param particle is the particle we are computed the position for
  15821. */
  15822. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15823. /**
  15824. * Clones the current emitter and returns a copy of it
  15825. * @returns the new emitter
  15826. */
  15827. clone(): BoxParticleEmitter;
  15828. /**
  15829. * Called by the GPUParticleSystem to setup the update shader
  15830. * @param effect defines the update shader
  15831. */
  15832. applyToShader(effect: Effect): void;
  15833. /**
  15834. * Returns a string to use to update the GPU particles update shader
  15835. * @returns a string containng the defines string
  15836. */
  15837. getEffectDefines(): string;
  15838. /**
  15839. * Returns the string "BoxParticleEmitter"
  15840. * @returns a string containing the class name
  15841. */
  15842. getClassName(): string;
  15843. /**
  15844. * Serializes the particle system to a JSON object.
  15845. * @returns the JSON object
  15846. */
  15847. serialize(): any;
  15848. /**
  15849. * Parse properties from a JSON object
  15850. * @param serializationObject defines the JSON object
  15851. */
  15852. parse(serializationObject: any): void;
  15853. }
  15854. }
  15855. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15856. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15857. import { Effect } from "babylonjs/Materials/effect";
  15858. import { Particle } from "babylonjs/Particles/particle";
  15859. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15860. /**
  15861. * Particle emitter emitting particles from the inside of a cone.
  15862. * It emits the particles alongside the cone volume from the base to the particle.
  15863. * The emission direction might be randomized.
  15864. */
  15865. export class ConeParticleEmitter implements IParticleEmitterType {
  15866. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15867. directionRandomizer: number;
  15868. private _radius;
  15869. private _angle;
  15870. private _height;
  15871. /**
  15872. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15873. */
  15874. radiusRange: number;
  15875. /**
  15876. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15877. */
  15878. heightRange: number;
  15879. /**
  15880. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15881. */
  15882. emitFromSpawnPointOnly: boolean;
  15883. /**
  15884. * Gets or sets the radius of the emission cone
  15885. */
  15886. radius: number;
  15887. /**
  15888. * Gets or sets the angle of the emission cone
  15889. */
  15890. angle: number;
  15891. private _buildHeight;
  15892. /**
  15893. * Creates a new instance ConeParticleEmitter
  15894. * @param radius the radius of the emission cone (1 by default)
  15895. * @param angle the cone base angle (PI by default)
  15896. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15897. */
  15898. constructor(radius?: number, angle?: number,
  15899. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15900. directionRandomizer?: number);
  15901. /**
  15902. * Called by the particle System when the direction is computed for the created particle.
  15903. * @param worldMatrix is the world matrix of the particle system
  15904. * @param directionToUpdate is the direction vector to update with the result
  15905. * @param particle is the particle we are computed the direction for
  15906. */
  15907. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15908. /**
  15909. * Called by the particle System when the position is computed for the created particle.
  15910. * @param worldMatrix is the world matrix of the particle system
  15911. * @param positionToUpdate is the position vector to update with the result
  15912. * @param particle is the particle we are computed the position for
  15913. */
  15914. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15915. /**
  15916. * Clones the current emitter and returns a copy of it
  15917. * @returns the new emitter
  15918. */
  15919. clone(): ConeParticleEmitter;
  15920. /**
  15921. * Called by the GPUParticleSystem to setup the update shader
  15922. * @param effect defines the update shader
  15923. */
  15924. applyToShader(effect: Effect): void;
  15925. /**
  15926. * Returns a string to use to update the GPU particles update shader
  15927. * @returns a string containng the defines string
  15928. */
  15929. getEffectDefines(): string;
  15930. /**
  15931. * Returns the string "ConeParticleEmitter"
  15932. * @returns a string containing the class name
  15933. */
  15934. getClassName(): string;
  15935. /**
  15936. * Serializes the particle system to a JSON object.
  15937. * @returns the JSON object
  15938. */
  15939. serialize(): any;
  15940. /**
  15941. * Parse properties from a JSON object
  15942. * @param serializationObject defines the JSON object
  15943. */
  15944. parse(serializationObject: any): void;
  15945. }
  15946. }
  15947. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15948. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15949. import { Effect } from "babylonjs/Materials/effect";
  15950. import { Particle } from "babylonjs/Particles/particle";
  15951. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15952. /**
  15953. * Particle emitter emitting particles from the inside of a cylinder.
  15954. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15955. */
  15956. export class CylinderParticleEmitter implements IParticleEmitterType {
  15957. /**
  15958. * The radius of the emission cylinder.
  15959. */
  15960. radius: number;
  15961. /**
  15962. * The height of the emission cylinder.
  15963. */
  15964. height: number;
  15965. /**
  15966. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15967. */
  15968. radiusRange: number;
  15969. /**
  15970. * How much to randomize the particle direction [0-1].
  15971. */
  15972. directionRandomizer: number;
  15973. /**
  15974. * Creates a new instance CylinderParticleEmitter
  15975. * @param radius the radius of the emission cylinder (1 by default)
  15976. * @param height the height of the emission cylinder (1 by default)
  15977. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15978. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15979. */
  15980. constructor(
  15981. /**
  15982. * The radius of the emission cylinder.
  15983. */
  15984. radius?: number,
  15985. /**
  15986. * The height of the emission cylinder.
  15987. */
  15988. height?: number,
  15989. /**
  15990. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15991. */
  15992. radiusRange?: number,
  15993. /**
  15994. * How much to randomize the particle direction [0-1].
  15995. */
  15996. directionRandomizer?: number);
  15997. /**
  15998. * Called by the particle System when the direction is computed for the created particle.
  15999. * @param worldMatrix is the world matrix of the particle system
  16000. * @param directionToUpdate is the direction vector to update with the result
  16001. * @param particle is the particle we are computed the direction for
  16002. */
  16003. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16004. /**
  16005. * Called by the particle System when the position is computed for the created particle.
  16006. * @param worldMatrix is the world matrix of the particle system
  16007. * @param positionToUpdate is the position vector to update with the result
  16008. * @param particle is the particle we are computed the position for
  16009. */
  16010. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16011. /**
  16012. * Clones the current emitter and returns a copy of it
  16013. * @returns the new emitter
  16014. */
  16015. clone(): CylinderParticleEmitter;
  16016. /**
  16017. * Called by the GPUParticleSystem to setup the update shader
  16018. * @param effect defines the update shader
  16019. */
  16020. applyToShader(effect: Effect): void;
  16021. /**
  16022. * Returns a string to use to update the GPU particles update shader
  16023. * @returns a string containng the defines string
  16024. */
  16025. getEffectDefines(): string;
  16026. /**
  16027. * Returns the string "CylinderParticleEmitter"
  16028. * @returns a string containing the class name
  16029. */
  16030. getClassName(): string;
  16031. /**
  16032. * Serializes the particle system to a JSON object.
  16033. * @returns the JSON object
  16034. */
  16035. serialize(): any;
  16036. /**
  16037. * Parse properties from a JSON object
  16038. * @param serializationObject defines the JSON object
  16039. */
  16040. parse(serializationObject: any): void;
  16041. }
  16042. /**
  16043. * Particle emitter emitting particles from the inside of a cylinder.
  16044. * It emits the particles randomly between two vectors.
  16045. */
  16046. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16047. /**
  16048. * The min limit of the emission direction.
  16049. */
  16050. direction1: Vector3;
  16051. /**
  16052. * The max limit of the emission direction.
  16053. */
  16054. direction2: Vector3;
  16055. /**
  16056. * Creates a new instance CylinderDirectedParticleEmitter
  16057. * @param radius the radius of the emission cylinder (1 by default)
  16058. * @param height the height of the emission cylinder (1 by default)
  16059. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16060. * @param direction1 the min limit of the emission direction (up vector by default)
  16061. * @param direction2 the max limit of the emission direction (up vector by default)
  16062. */
  16063. constructor(radius?: number, height?: number, radiusRange?: number,
  16064. /**
  16065. * The min limit of the emission direction.
  16066. */
  16067. direction1?: Vector3,
  16068. /**
  16069. * The max limit of the emission direction.
  16070. */
  16071. direction2?: Vector3);
  16072. /**
  16073. * Called by the particle System when the direction is computed for the created particle.
  16074. * @param worldMatrix is the world matrix of the particle system
  16075. * @param directionToUpdate is the direction vector to update with the result
  16076. * @param particle is the particle we are computed the direction for
  16077. */
  16078. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16079. /**
  16080. * Clones the current emitter and returns a copy of it
  16081. * @returns the new emitter
  16082. */
  16083. clone(): CylinderDirectedParticleEmitter;
  16084. /**
  16085. * Called by the GPUParticleSystem to setup the update shader
  16086. * @param effect defines the update shader
  16087. */
  16088. applyToShader(effect: Effect): void;
  16089. /**
  16090. * Returns a string to use to update the GPU particles update shader
  16091. * @returns a string containng the defines string
  16092. */
  16093. getEffectDefines(): string;
  16094. /**
  16095. * Returns the string "CylinderDirectedParticleEmitter"
  16096. * @returns a string containing the class name
  16097. */
  16098. getClassName(): string;
  16099. /**
  16100. * Serializes the particle system to a JSON object.
  16101. * @returns the JSON object
  16102. */
  16103. serialize(): any;
  16104. /**
  16105. * Parse properties from a JSON object
  16106. * @param serializationObject defines the JSON object
  16107. */
  16108. parse(serializationObject: any): void;
  16109. }
  16110. }
  16111. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16112. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16113. import { Effect } from "babylonjs/Materials/effect";
  16114. import { Particle } from "babylonjs/Particles/particle";
  16115. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16116. /**
  16117. * Particle emitter emitting particles from the inside of a hemisphere.
  16118. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16119. */
  16120. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16121. /**
  16122. * The radius of the emission hemisphere.
  16123. */
  16124. radius: number;
  16125. /**
  16126. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16127. */
  16128. radiusRange: number;
  16129. /**
  16130. * How much to randomize the particle direction [0-1].
  16131. */
  16132. directionRandomizer: number;
  16133. /**
  16134. * Creates a new instance HemisphericParticleEmitter
  16135. * @param radius the radius of the emission hemisphere (1 by default)
  16136. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16137. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16138. */
  16139. constructor(
  16140. /**
  16141. * The radius of the emission hemisphere.
  16142. */
  16143. radius?: number,
  16144. /**
  16145. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16146. */
  16147. radiusRange?: number,
  16148. /**
  16149. * How much to randomize the particle direction [0-1].
  16150. */
  16151. directionRandomizer?: number);
  16152. /**
  16153. * Called by the particle System when the direction is computed for the created particle.
  16154. * @param worldMatrix is the world matrix of the particle system
  16155. * @param directionToUpdate is the direction vector to update with the result
  16156. * @param particle is the particle we are computed the direction for
  16157. */
  16158. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16159. /**
  16160. * Called by the particle System when the position is computed for the created particle.
  16161. * @param worldMatrix is the world matrix of the particle system
  16162. * @param positionToUpdate is the position vector to update with the result
  16163. * @param particle is the particle we are computed the position for
  16164. */
  16165. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16166. /**
  16167. * Clones the current emitter and returns a copy of it
  16168. * @returns the new emitter
  16169. */
  16170. clone(): HemisphericParticleEmitter;
  16171. /**
  16172. * Called by the GPUParticleSystem to setup the update shader
  16173. * @param effect defines the update shader
  16174. */
  16175. applyToShader(effect: Effect): void;
  16176. /**
  16177. * Returns a string to use to update the GPU particles update shader
  16178. * @returns a string containng the defines string
  16179. */
  16180. getEffectDefines(): string;
  16181. /**
  16182. * Returns the string "HemisphericParticleEmitter"
  16183. * @returns a string containing the class name
  16184. */
  16185. getClassName(): string;
  16186. /**
  16187. * Serializes the particle system to a JSON object.
  16188. * @returns the JSON object
  16189. */
  16190. serialize(): any;
  16191. /**
  16192. * Parse properties from a JSON object
  16193. * @param serializationObject defines the JSON object
  16194. */
  16195. parse(serializationObject: any): void;
  16196. }
  16197. }
  16198. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16199. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16200. import { Effect } from "babylonjs/Materials/effect";
  16201. import { Particle } from "babylonjs/Particles/particle";
  16202. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16203. /**
  16204. * Particle emitter emitting particles from a point.
  16205. * It emits the particles randomly between 2 given directions.
  16206. */
  16207. export class PointParticleEmitter implements IParticleEmitterType {
  16208. /**
  16209. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16210. */
  16211. direction1: Vector3;
  16212. /**
  16213. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16214. */
  16215. direction2: Vector3;
  16216. /**
  16217. * Creates a new instance PointParticleEmitter
  16218. */
  16219. constructor();
  16220. /**
  16221. * Called by the particle System when the direction is computed for the created particle.
  16222. * @param worldMatrix is the world matrix of the particle system
  16223. * @param directionToUpdate is the direction vector to update with the result
  16224. * @param particle is the particle we are computed the direction for
  16225. */
  16226. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16227. /**
  16228. * Called by the particle System when the position is computed for the created particle.
  16229. * @param worldMatrix is the world matrix of the particle system
  16230. * @param positionToUpdate is the position vector to update with the result
  16231. * @param particle is the particle we are computed the position for
  16232. */
  16233. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16234. /**
  16235. * Clones the current emitter and returns a copy of it
  16236. * @returns the new emitter
  16237. */
  16238. clone(): PointParticleEmitter;
  16239. /**
  16240. * Called by the GPUParticleSystem to setup the update shader
  16241. * @param effect defines the update shader
  16242. */
  16243. applyToShader(effect: Effect): void;
  16244. /**
  16245. * Returns a string to use to update the GPU particles update shader
  16246. * @returns a string containng the defines string
  16247. */
  16248. getEffectDefines(): string;
  16249. /**
  16250. * Returns the string "PointParticleEmitter"
  16251. * @returns a string containing the class name
  16252. */
  16253. getClassName(): string;
  16254. /**
  16255. * Serializes the particle system to a JSON object.
  16256. * @returns the JSON object
  16257. */
  16258. serialize(): any;
  16259. /**
  16260. * Parse properties from a JSON object
  16261. * @param serializationObject defines the JSON object
  16262. */
  16263. parse(serializationObject: any): void;
  16264. }
  16265. }
  16266. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16267. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16268. import { Effect } from "babylonjs/Materials/effect";
  16269. import { Particle } from "babylonjs/Particles/particle";
  16270. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16271. /**
  16272. * Particle emitter emitting particles from the inside of a sphere.
  16273. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16274. */
  16275. export class SphereParticleEmitter implements IParticleEmitterType {
  16276. /**
  16277. * The radius of the emission sphere.
  16278. */
  16279. radius: number;
  16280. /**
  16281. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16282. */
  16283. radiusRange: number;
  16284. /**
  16285. * How much to randomize the particle direction [0-1].
  16286. */
  16287. directionRandomizer: number;
  16288. /**
  16289. * Creates a new instance SphereParticleEmitter
  16290. * @param radius the radius of the emission sphere (1 by default)
  16291. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16292. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16293. */
  16294. constructor(
  16295. /**
  16296. * The radius of the emission sphere.
  16297. */
  16298. radius?: number,
  16299. /**
  16300. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16301. */
  16302. radiusRange?: number,
  16303. /**
  16304. * How much to randomize the particle direction [0-1].
  16305. */
  16306. directionRandomizer?: number);
  16307. /**
  16308. * Called by the particle System when the direction is computed for the created particle.
  16309. * @param worldMatrix is the world matrix of the particle system
  16310. * @param directionToUpdate is the direction vector to update with the result
  16311. * @param particle is the particle we are computed the direction for
  16312. */
  16313. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16314. /**
  16315. * Called by the particle System when the position is computed for the created particle.
  16316. * @param worldMatrix is the world matrix of the particle system
  16317. * @param positionToUpdate is the position vector to update with the result
  16318. * @param particle is the particle we are computed the position for
  16319. */
  16320. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16321. /**
  16322. * Clones the current emitter and returns a copy of it
  16323. * @returns the new emitter
  16324. */
  16325. clone(): SphereParticleEmitter;
  16326. /**
  16327. * Called by the GPUParticleSystem to setup the update shader
  16328. * @param effect defines the update shader
  16329. */
  16330. applyToShader(effect: Effect): void;
  16331. /**
  16332. * Returns a string to use to update the GPU particles update shader
  16333. * @returns a string containng the defines string
  16334. */
  16335. getEffectDefines(): string;
  16336. /**
  16337. * Returns the string "SphereParticleEmitter"
  16338. * @returns a string containing the class name
  16339. */
  16340. getClassName(): string;
  16341. /**
  16342. * Serializes the particle system to a JSON object.
  16343. * @returns the JSON object
  16344. */
  16345. serialize(): any;
  16346. /**
  16347. * Parse properties from a JSON object
  16348. * @param serializationObject defines the JSON object
  16349. */
  16350. parse(serializationObject: any): void;
  16351. }
  16352. /**
  16353. * Particle emitter emitting particles from the inside of a sphere.
  16354. * It emits the particles randomly between two vectors.
  16355. */
  16356. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16357. /**
  16358. * The min limit of the emission direction.
  16359. */
  16360. direction1: Vector3;
  16361. /**
  16362. * The max limit of the emission direction.
  16363. */
  16364. direction2: Vector3;
  16365. /**
  16366. * Creates a new instance SphereDirectedParticleEmitter
  16367. * @param radius the radius of the emission sphere (1 by default)
  16368. * @param direction1 the min limit of the emission direction (up vector by default)
  16369. * @param direction2 the max limit of the emission direction (up vector by default)
  16370. */
  16371. constructor(radius?: number,
  16372. /**
  16373. * The min limit of the emission direction.
  16374. */
  16375. direction1?: Vector3,
  16376. /**
  16377. * The max limit of the emission direction.
  16378. */
  16379. direction2?: Vector3);
  16380. /**
  16381. * Called by the particle System when the direction is computed for the created particle.
  16382. * @param worldMatrix is the world matrix of the particle system
  16383. * @param directionToUpdate is the direction vector to update with the result
  16384. * @param particle is the particle we are computed the direction for
  16385. */
  16386. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16387. /**
  16388. * Clones the current emitter and returns a copy of it
  16389. * @returns the new emitter
  16390. */
  16391. clone(): SphereDirectedParticleEmitter;
  16392. /**
  16393. * Called by the GPUParticleSystem to setup the update shader
  16394. * @param effect defines the update shader
  16395. */
  16396. applyToShader(effect: Effect): void;
  16397. /**
  16398. * Returns a string to use to update the GPU particles update shader
  16399. * @returns a string containng the defines string
  16400. */
  16401. getEffectDefines(): string;
  16402. /**
  16403. * Returns the string "SphereDirectedParticleEmitter"
  16404. * @returns a string containing the class name
  16405. */
  16406. getClassName(): string;
  16407. /**
  16408. * Serializes the particle system to a JSON object.
  16409. * @returns the JSON object
  16410. */
  16411. serialize(): any;
  16412. /**
  16413. * Parse properties from a JSON object
  16414. * @param serializationObject defines the JSON object
  16415. */
  16416. parse(serializationObject: any): void;
  16417. }
  16418. }
  16419. declare module "babylonjs/Particles/EmitterTypes/index" {
  16420. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16421. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16422. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16423. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16424. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16425. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16426. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16427. }
  16428. declare module "babylonjs/Particles/IParticleSystem" {
  16429. import { Nullable } from "babylonjs/types";
  16430. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16432. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16433. import { Texture } from "babylonjs/Materials/Textures/texture";
  16434. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16435. import { Scene } from "babylonjs/scene";
  16436. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16437. import { Animation } from "babylonjs/Animations/animation";
  16438. /**
  16439. * Interface representing a particle system in Babylon.js.
  16440. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16441. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16442. */
  16443. export interface IParticleSystem {
  16444. /**
  16445. * List of animations used by the particle system.
  16446. */
  16447. animations: Animation[];
  16448. /**
  16449. * The id of the Particle system.
  16450. */
  16451. id: string;
  16452. /**
  16453. * The name of the Particle system.
  16454. */
  16455. name: string;
  16456. /**
  16457. * The emitter represents the Mesh or position we are attaching the particle system to.
  16458. */
  16459. emitter: Nullable<AbstractMesh | Vector3>;
  16460. /**
  16461. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16462. */
  16463. isBillboardBased: boolean;
  16464. /**
  16465. * The rendering group used by the Particle system to chose when to render.
  16466. */
  16467. renderingGroupId: number;
  16468. /**
  16469. * The layer mask we are rendering the particles through.
  16470. */
  16471. layerMask: number;
  16472. /**
  16473. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16474. */
  16475. updateSpeed: number;
  16476. /**
  16477. * The amount of time the particle system is running (depends of the overall update speed).
  16478. */
  16479. targetStopDuration: number;
  16480. /**
  16481. * The texture used to render each particle. (this can be a spritesheet)
  16482. */
  16483. particleTexture: Nullable<Texture>;
  16484. /**
  16485. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16486. */
  16487. blendMode: number;
  16488. /**
  16489. * Minimum life time of emitting particles.
  16490. */
  16491. minLifeTime: number;
  16492. /**
  16493. * Maximum life time of emitting particles.
  16494. */
  16495. maxLifeTime: number;
  16496. /**
  16497. * Minimum Size of emitting particles.
  16498. */
  16499. minSize: number;
  16500. /**
  16501. * Maximum Size of emitting particles.
  16502. */
  16503. maxSize: number;
  16504. /**
  16505. * Minimum scale of emitting particles on X axis.
  16506. */
  16507. minScaleX: number;
  16508. /**
  16509. * Maximum scale of emitting particles on X axis.
  16510. */
  16511. maxScaleX: number;
  16512. /**
  16513. * Minimum scale of emitting particles on Y axis.
  16514. */
  16515. minScaleY: number;
  16516. /**
  16517. * Maximum scale of emitting particles on Y axis.
  16518. */
  16519. maxScaleY: number;
  16520. /**
  16521. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16522. */
  16523. color1: Color4;
  16524. /**
  16525. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16526. */
  16527. color2: Color4;
  16528. /**
  16529. * Color the particle will have at the end of its lifetime.
  16530. */
  16531. colorDead: Color4;
  16532. /**
  16533. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16534. */
  16535. emitRate: number;
  16536. /**
  16537. * You can use gravity if you want to give an orientation to your particles.
  16538. */
  16539. gravity: Vector3;
  16540. /**
  16541. * Minimum power of emitting particles.
  16542. */
  16543. minEmitPower: number;
  16544. /**
  16545. * Maximum power of emitting particles.
  16546. */
  16547. maxEmitPower: number;
  16548. /**
  16549. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16550. */
  16551. minAngularSpeed: number;
  16552. /**
  16553. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16554. */
  16555. maxAngularSpeed: number;
  16556. /**
  16557. * Gets or sets the minimal initial rotation in radians.
  16558. */
  16559. minInitialRotation: number;
  16560. /**
  16561. * Gets or sets the maximal initial rotation in radians.
  16562. */
  16563. maxInitialRotation: number;
  16564. /**
  16565. * The particle emitter type defines the emitter used by the particle system.
  16566. * It can be for example box, sphere, or cone...
  16567. */
  16568. particleEmitterType: Nullable<IParticleEmitterType>;
  16569. /**
  16570. * Defines the delay in milliseconds before starting the system (0 by default)
  16571. */
  16572. startDelay: number;
  16573. /**
  16574. * 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
  16575. */
  16576. preWarmCycles: number;
  16577. /**
  16578. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16579. */
  16580. preWarmStepOffset: number;
  16581. /**
  16582. * 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)
  16583. */
  16584. spriteCellChangeSpeed: number;
  16585. /**
  16586. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16587. */
  16588. startSpriteCellID: number;
  16589. /**
  16590. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16591. */
  16592. endSpriteCellID: number;
  16593. /**
  16594. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16595. */
  16596. spriteCellWidth: number;
  16597. /**
  16598. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16599. */
  16600. spriteCellHeight: number;
  16601. /**
  16602. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16603. */
  16604. spriteRandomStartCell: boolean;
  16605. /**
  16606. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16607. */
  16608. isAnimationSheetEnabled: boolean;
  16609. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16610. translationPivot: Vector2;
  16611. /**
  16612. * Gets or sets a texture used to add random noise to particle positions
  16613. */
  16614. noiseTexture: Nullable<BaseTexture>;
  16615. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16616. noiseStrength: Vector3;
  16617. /**
  16618. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16619. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16620. */
  16621. billboardMode: number;
  16622. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16623. limitVelocityDamping: number;
  16624. /**
  16625. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16626. */
  16627. beginAnimationOnStart: boolean;
  16628. /**
  16629. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16630. */
  16631. beginAnimationFrom: number;
  16632. /**
  16633. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16634. */
  16635. beginAnimationTo: number;
  16636. /**
  16637. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16638. */
  16639. beginAnimationLoop: boolean;
  16640. /**
  16641. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16642. */
  16643. disposeOnStop: boolean;
  16644. /**
  16645. * Gets the maximum number of particles active at the same time.
  16646. * @returns The max number of active particles.
  16647. */
  16648. getCapacity(): number;
  16649. /**
  16650. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16651. * @returns True if it has been started, otherwise false.
  16652. */
  16653. isStarted(): boolean;
  16654. /**
  16655. * Animates the particle system for this frame.
  16656. */
  16657. animate(): void;
  16658. /**
  16659. * Renders the particle system in its current state.
  16660. * @returns the current number of particles
  16661. */
  16662. render(): number;
  16663. /**
  16664. * Dispose the particle system and frees its associated resources.
  16665. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16666. */
  16667. dispose(disposeTexture?: boolean): void;
  16668. /**
  16669. * Clones the particle system.
  16670. * @param name The name of the cloned object
  16671. * @param newEmitter The new emitter to use
  16672. * @returns the cloned particle system
  16673. */
  16674. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16675. /**
  16676. * Serializes the particle system to a JSON object.
  16677. * @returns the JSON object
  16678. */
  16679. serialize(): any;
  16680. /**
  16681. * Rebuild the particle system
  16682. */
  16683. rebuild(): void;
  16684. /**
  16685. * Starts the particle system and begins to emit
  16686. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16687. */
  16688. start(delay?: number): void;
  16689. /**
  16690. * Stops the particle system.
  16691. */
  16692. stop(): void;
  16693. /**
  16694. * Remove all active particles
  16695. */
  16696. reset(): void;
  16697. /**
  16698. * Is this system ready to be used/rendered
  16699. * @return true if the system is ready
  16700. */
  16701. isReady(): boolean;
  16702. /**
  16703. * Adds a new color gradient
  16704. * @param gradient defines the gradient to use (between 0 and 1)
  16705. * @param color1 defines the color to affect to the specified gradient
  16706. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16707. * @returns the current particle system
  16708. */
  16709. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16710. /**
  16711. * Remove a specific color gradient
  16712. * @param gradient defines the gradient to remove
  16713. * @returns the current particle system
  16714. */
  16715. removeColorGradient(gradient: number): IParticleSystem;
  16716. /**
  16717. * Adds a new size gradient
  16718. * @param gradient defines the gradient to use (between 0 and 1)
  16719. * @param factor defines the size factor to affect to the specified gradient
  16720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16721. * @returns the current particle system
  16722. */
  16723. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16724. /**
  16725. * Remove a specific size gradient
  16726. * @param gradient defines the gradient to remove
  16727. * @returns the current particle system
  16728. */
  16729. removeSizeGradient(gradient: number): IParticleSystem;
  16730. /**
  16731. * Gets the current list of color gradients.
  16732. * You must use addColorGradient and removeColorGradient to udpate this list
  16733. * @returns the list of color gradients
  16734. */
  16735. getColorGradients(): Nullable<Array<ColorGradient>>;
  16736. /**
  16737. * Gets the current list of size gradients.
  16738. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16739. * @returns the list of size gradients
  16740. */
  16741. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16742. /**
  16743. * Gets the current list of angular speed gradients.
  16744. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16745. * @returns the list of angular speed gradients
  16746. */
  16747. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16748. /**
  16749. * Adds a new angular speed gradient
  16750. * @param gradient defines the gradient to use (between 0 and 1)
  16751. * @param factor defines the angular speed to affect to the specified gradient
  16752. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16753. * @returns the current particle system
  16754. */
  16755. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16756. /**
  16757. * Remove a specific angular speed gradient
  16758. * @param gradient defines the gradient to remove
  16759. * @returns the current particle system
  16760. */
  16761. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16762. /**
  16763. * Gets the current list of velocity gradients.
  16764. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16765. * @returns the list of velocity gradients
  16766. */
  16767. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16768. /**
  16769. * Adds a new velocity gradient
  16770. * @param gradient defines the gradient to use (between 0 and 1)
  16771. * @param factor defines the velocity to affect to the specified gradient
  16772. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16773. * @returns the current particle system
  16774. */
  16775. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16776. /**
  16777. * Remove a specific velocity gradient
  16778. * @param gradient defines the gradient to remove
  16779. * @returns the current particle system
  16780. */
  16781. removeVelocityGradient(gradient: number): IParticleSystem;
  16782. /**
  16783. * Gets the current list of limit velocity gradients.
  16784. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16785. * @returns the list of limit velocity gradients
  16786. */
  16787. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16788. /**
  16789. * Adds a new limit velocity gradient
  16790. * @param gradient defines the gradient to use (between 0 and 1)
  16791. * @param factor defines the limit velocity to affect to the specified gradient
  16792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16793. * @returns the current particle system
  16794. */
  16795. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16796. /**
  16797. * Remove a specific limit velocity gradient
  16798. * @param gradient defines the gradient to remove
  16799. * @returns the current particle system
  16800. */
  16801. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16802. /**
  16803. * Adds a new drag gradient
  16804. * @param gradient defines the gradient to use (between 0 and 1)
  16805. * @param factor defines the drag to affect to the specified gradient
  16806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16807. * @returns the current particle system
  16808. */
  16809. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16810. /**
  16811. * Remove a specific drag gradient
  16812. * @param gradient defines the gradient to remove
  16813. * @returns the current particle system
  16814. */
  16815. removeDragGradient(gradient: number): IParticleSystem;
  16816. /**
  16817. * Gets the current list of drag gradients.
  16818. * You must use addDragGradient and removeDragGradient to udpate this list
  16819. * @returns the list of drag gradients
  16820. */
  16821. getDragGradients(): Nullable<Array<FactorGradient>>;
  16822. /**
  16823. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16824. * @param gradient defines the gradient to use (between 0 and 1)
  16825. * @param factor defines the emit rate to affect to the specified gradient
  16826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16827. * @returns the current particle system
  16828. */
  16829. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16830. /**
  16831. * Remove a specific emit rate gradient
  16832. * @param gradient defines the gradient to remove
  16833. * @returns the current particle system
  16834. */
  16835. removeEmitRateGradient(gradient: number): IParticleSystem;
  16836. /**
  16837. * Gets the current list of emit rate gradients.
  16838. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16839. * @returns the list of emit rate gradients
  16840. */
  16841. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16842. /**
  16843. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16844. * @param gradient defines the gradient to use (between 0 and 1)
  16845. * @param factor defines the start size to affect to the specified gradient
  16846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16847. * @returns the current particle system
  16848. */
  16849. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16850. /**
  16851. * Remove a specific start size gradient
  16852. * @param gradient defines the gradient to remove
  16853. * @returns the current particle system
  16854. */
  16855. removeStartSizeGradient(gradient: number): IParticleSystem;
  16856. /**
  16857. * Gets the current list of start size gradients.
  16858. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16859. * @returns the list of start size gradients
  16860. */
  16861. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16862. /**
  16863. * Adds a new life time gradient
  16864. * @param gradient defines the gradient to use (between 0 and 1)
  16865. * @param factor defines the life time factor to affect to the specified gradient
  16866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16867. * @returns the current particle system
  16868. */
  16869. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16870. /**
  16871. * Remove a specific life time gradient
  16872. * @param gradient defines the gradient to remove
  16873. * @returns the current particle system
  16874. */
  16875. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16876. /**
  16877. * Gets the current list of life time gradients.
  16878. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16879. * @returns the list of life time gradients
  16880. */
  16881. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16882. /**
  16883. * Gets the current list of color gradients.
  16884. * You must use addColorGradient and removeColorGradient to udpate this list
  16885. * @returns the list of color gradients
  16886. */
  16887. getColorGradients(): Nullable<Array<ColorGradient>>;
  16888. /**
  16889. * Adds a new ramp gradient used to remap particle colors
  16890. * @param gradient defines the gradient to use (between 0 and 1)
  16891. * @param color defines the color to affect to the specified gradient
  16892. * @returns the current particle system
  16893. */
  16894. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16895. /**
  16896. * Gets the current list of ramp gradients.
  16897. * You must use addRampGradient and removeRampGradient to udpate this list
  16898. * @returns the list of ramp gradients
  16899. */
  16900. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16901. /** Gets or sets a boolean indicating that ramp gradients must be used
  16902. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16903. */
  16904. useRampGradients: boolean;
  16905. /**
  16906. * Adds a new color remap gradient
  16907. * @param gradient defines the gradient to use (between 0 and 1)
  16908. * @param min defines the color remap minimal range
  16909. * @param max defines the color remap maximal range
  16910. * @returns the current particle system
  16911. */
  16912. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16913. /**
  16914. * Gets the current list of color remap gradients.
  16915. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16916. * @returns the list of color remap gradients
  16917. */
  16918. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16919. /**
  16920. * Adds a new alpha remap gradient
  16921. * @param gradient defines the gradient to use (between 0 and 1)
  16922. * @param min defines the alpha remap minimal range
  16923. * @param max defines the alpha remap maximal range
  16924. * @returns the current particle system
  16925. */
  16926. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16927. /**
  16928. * Gets the current list of alpha remap gradients.
  16929. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16930. * @returns the list of alpha remap gradients
  16931. */
  16932. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16933. /**
  16934. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16935. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16936. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16937. * @returns the emitter
  16938. */
  16939. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16940. /**
  16941. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16942. * @param radius The radius of the hemisphere to emit from
  16943. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16944. * @returns the emitter
  16945. */
  16946. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16947. /**
  16948. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16949. * @param radius The radius of the sphere to emit from
  16950. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16951. * @returns the emitter
  16952. */
  16953. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16954. /**
  16955. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16956. * @param radius The radius of the sphere to emit from
  16957. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16958. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16959. * @returns the emitter
  16960. */
  16961. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16962. /**
  16963. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16964. * @param radius The radius of the emission cylinder
  16965. * @param height The height of the emission cylinder
  16966. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16967. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16968. * @returns the emitter
  16969. */
  16970. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16971. /**
  16972. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16973. * @param radius The radius of the cylinder to emit from
  16974. * @param height The height of the emission cylinder
  16975. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16976. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16977. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16978. * @returns the emitter
  16979. */
  16980. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16981. /**
  16982. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16983. * @param radius The radius of the cone to emit from
  16984. * @param angle The base angle of the cone
  16985. * @returns the emitter
  16986. */
  16987. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16988. /**
  16989. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16990. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16991. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16992. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16993. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16994. * @returns the emitter
  16995. */
  16996. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16997. /**
  16998. * Get hosting scene
  16999. * @returns the scene
  17000. */
  17001. getScene(): Scene;
  17002. }
  17003. }
  17004. declare module "babylonjs/Meshes/instancedMesh" {
  17005. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17006. import { Vector3 } from "babylonjs/Maths/math";
  17007. import { Camera } from "babylonjs/Cameras/camera";
  17008. import { Node } from "babylonjs/node";
  17009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17010. import { Mesh } from "babylonjs/Meshes/mesh";
  17011. import { Material } from "babylonjs/Materials/material";
  17012. import { Skeleton } from "babylonjs/Bones/skeleton";
  17013. /**
  17014. * Creates an instance based on a source mesh.
  17015. */
  17016. export class InstancedMesh extends AbstractMesh {
  17017. private _sourceMesh;
  17018. private _currentLOD;
  17019. /** @hidden */
  17020. _indexInSourceMeshInstanceArray: number;
  17021. constructor(name: string, source: Mesh);
  17022. /**
  17023. * Returns the string "InstancedMesh".
  17024. */
  17025. getClassName(): string;
  17026. /**
  17027. * If the source mesh receives shadows
  17028. */
  17029. readonly receiveShadows: boolean;
  17030. /**
  17031. * The material of the source mesh
  17032. */
  17033. readonly material: Nullable<Material>;
  17034. /**
  17035. * Visibility of the source mesh
  17036. */
  17037. readonly visibility: number;
  17038. /**
  17039. * Skeleton of the source mesh
  17040. */
  17041. readonly skeleton: Nullable<Skeleton>;
  17042. /**
  17043. * Rendering ground id of the source mesh
  17044. */
  17045. renderingGroupId: number;
  17046. /**
  17047. * Returns the total number of vertices (integer).
  17048. */
  17049. getTotalVertices(): number;
  17050. /**
  17051. * Returns a positive integer : the total number of indices in this mesh geometry.
  17052. * @returns the numner of indices or zero if the mesh has no geometry.
  17053. */
  17054. getTotalIndices(): number;
  17055. /**
  17056. * The source mesh of the instance
  17057. */
  17058. readonly sourceMesh: Mesh;
  17059. /**
  17060. * Is this node ready to be used/rendered
  17061. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17062. * @return {boolean} is it ready
  17063. */
  17064. isReady(completeCheck?: boolean): boolean;
  17065. /**
  17066. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17067. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17068. * @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.
  17069. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17070. */
  17071. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17072. /**
  17073. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17074. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17075. * The `data` are either a numeric array either a Float32Array.
  17076. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17077. * 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).
  17078. * Note that a new underlying VertexBuffer object is created each call.
  17079. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17080. *
  17081. * Possible `kind` values :
  17082. * - VertexBuffer.PositionKind
  17083. * - VertexBuffer.UVKind
  17084. * - VertexBuffer.UV2Kind
  17085. * - VertexBuffer.UV3Kind
  17086. * - VertexBuffer.UV4Kind
  17087. * - VertexBuffer.UV5Kind
  17088. * - VertexBuffer.UV6Kind
  17089. * - VertexBuffer.ColorKind
  17090. * - VertexBuffer.MatricesIndicesKind
  17091. * - VertexBuffer.MatricesIndicesExtraKind
  17092. * - VertexBuffer.MatricesWeightsKind
  17093. * - VertexBuffer.MatricesWeightsExtraKind
  17094. *
  17095. * Returns the Mesh.
  17096. */
  17097. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17098. /**
  17099. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17100. * If the mesh has no geometry, it is simply returned as it is.
  17101. * The `data` are either a numeric array either a Float32Array.
  17102. * No new underlying VertexBuffer object is created.
  17103. * 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.
  17104. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17105. *
  17106. * Possible `kind` values :
  17107. * - VertexBuffer.PositionKind
  17108. * - VertexBuffer.UVKind
  17109. * - VertexBuffer.UV2Kind
  17110. * - VertexBuffer.UV3Kind
  17111. * - VertexBuffer.UV4Kind
  17112. * - VertexBuffer.UV5Kind
  17113. * - VertexBuffer.UV6Kind
  17114. * - VertexBuffer.ColorKind
  17115. * - VertexBuffer.MatricesIndicesKind
  17116. * - VertexBuffer.MatricesIndicesExtraKind
  17117. * - VertexBuffer.MatricesWeightsKind
  17118. * - VertexBuffer.MatricesWeightsExtraKind
  17119. *
  17120. * Returns the Mesh.
  17121. */
  17122. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17123. /**
  17124. * Sets the mesh indices.
  17125. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17126. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17127. * This method creates a new index buffer each call.
  17128. * Returns the Mesh.
  17129. */
  17130. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17131. /**
  17132. * Boolean : True if the mesh owns the requested kind of data.
  17133. */
  17134. isVerticesDataPresent(kind: string): boolean;
  17135. /**
  17136. * Returns an array of indices (IndicesArray).
  17137. */
  17138. getIndices(): Nullable<IndicesArray>;
  17139. readonly _positions: Nullable<Vector3[]>;
  17140. /**
  17141. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17142. * This means the mesh underlying bounding box and sphere are recomputed.
  17143. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17144. * @returns the current mesh
  17145. */
  17146. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17147. /** @hidden */
  17148. _preActivate(): InstancedMesh;
  17149. /** @hidden */
  17150. _activate(renderId: number): boolean;
  17151. /**
  17152. * Returns the current associated LOD AbstractMesh.
  17153. */
  17154. getLOD(camera: Camera): AbstractMesh;
  17155. /** @hidden */
  17156. _syncSubMeshes(): InstancedMesh;
  17157. /** @hidden */
  17158. _generatePointsArray(): boolean;
  17159. /**
  17160. * Creates a new InstancedMesh from the current mesh.
  17161. * - name (string) : the cloned mesh name
  17162. * - newParent (optional Node) : the optional Node to parent the clone to.
  17163. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17164. *
  17165. * Returns the clone.
  17166. */
  17167. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17168. /**
  17169. * Disposes the InstancedMesh.
  17170. * Returns nothing.
  17171. */
  17172. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17173. }
  17174. }
  17175. declare module "babylonjs/Materials/shaderMaterial" {
  17176. import { Scene } from "babylonjs/scene";
  17177. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17179. import { Mesh } from "babylonjs/Meshes/mesh";
  17180. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17181. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17182. import { Texture } from "babylonjs/Materials/Textures/texture";
  17183. import { Material } from "babylonjs/Materials/material";
  17184. /**
  17185. * Defines the options associated with the creation of a shader material.
  17186. */
  17187. export interface IShaderMaterialOptions {
  17188. /**
  17189. * Does the material work in alpha blend mode
  17190. */
  17191. needAlphaBlending: boolean;
  17192. /**
  17193. * Does the material work in alpha test mode
  17194. */
  17195. needAlphaTesting: boolean;
  17196. /**
  17197. * The list of attribute names used in the shader
  17198. */
  17199. attributes: string[];
  17200. /**
  17201. * The list of unifrom names used in the shader
  17202. */
  17203. uniforms: string[];
  17204. /**
  17205. * The list of UBO names used in the shader
  17206. */
  17207. uniformBuffers: string[];
  17208. /**
  17209. * The list of sampler names used in the shader
  17210. */
  17211. samplers: string[];
  17212. /**
  17213. * The list of defines used in the shader
  17214. */
  17215. defines: string[];
  17216. }
  17217. /**
  17218. * 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.
  17219. *
  17220. * This returned material effects how the mesh will look based on the code in the shaders.
  17221. *
  17222. * @see http://doc.babylonjs.com/how_to/shader_material
  17223. */
  17224. export class ShaderMaterial extends Material {
  17225. private _shaderPath;
  17226. private _options;
  17227. private _textures;
  17228. private _textureArrays;
  17229. private _floats;
  17230. private _ints;
  17231. private _floatsArrays;
  17232. private _colors3;
  17233. private _colors3Arrays;
  17234. private _colors4;
  17235. private _vectors2;
  17236. private _vectors3;
  17237. private _vectors4;
  17238. private _matrices;
  17239. private _matrices3x3;
  17240. private _matrices2x2;
  17241. private _vectors2Arrays;
  17242. private _vectors3Arrays;
  17243. private _cachedWorldViewMatrix;
  17244. private _renderId;
  17245. /**
  17246. * Instantiate a new shader material.
  17247. * 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.
  17248. * This returned material effects how the mesh will look based on the code in the shaders.
  17249. * @see http://doc.babylonjs.com/how_to/shader_material
  17250. * @param name Define the name of the material in the scene
  17251. * @param scene Define the scene the material belongs to
  17252. * @param shaderPath Defines the route to the shader code in one of three ways:
  17253. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17254. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17255. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17256. * @param options Define the options used to create the shader
  17257. */
  17258. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17259. /**
  17260. * Gets the options used to compile the shader.
  17261. * They can be modified to trigger a new compilation
  17262. */
  17263. readonly options: IShaderMaterialOptions;
  17264. /**
  17265. * Gets the current class name of the material e.g. "ShaderMaterial"
  17266. * Mainly use in serialization.
  17267. * @returns the class name
  17268. */
  17269. getClassName(): string;
  17270. /**
  17271. * Specifies if the material will require alpha blending
  17272. * @returns a boolean specifying if alpha blending is needed
  17273. */
  17274. needAlphaBlending(): boolean;
  17275. /**
  17276. * Specifies if this material should be rendered in alpha test mode
  17277. * @returns a boolean specifying if an alpha test is needed.
  17278. */
  17279. needAlphaTesting(): boolean;
  17280. private _checkUniform;
  17281. /**
  17282. * Set a texture in the shader.
  17283. * @param name Define the name of the uniform samplers as defined in the shader
  17284. * @param texture Define the texture to bind to this sampler
  17285. * @return the material itself allowing "fluent" like uniform updates
  17286. */
  17287. setTexture(name: string, texture: Texture): ShaderMaterial;
  17288. /**
  17289. * Set a texture array in the shader.
  17290. * @param name Define the name of the uniform sampler array as defined in the shader
  17291. * @param textures Define the list of textures to bind to this sampler
  17292. * @return the material itself allowing "fluent" like uniform updates
  17293. */
  17294. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17295. /**
  17296. * Set a float in the shader.
  17297. * @param name Define the name of the uniform as defined in the shader
  17298. * @param value Define the value to give to the uniform
  17299. * @return the material itself allowing "fluent" like uniform updates
  17300. */
  17301. setFloat(name: string, value: number): ShaderMaterial;
  17302. /**
  17303. * Set a int in the shader.
  17304. * @param name Define the name of the uniform as defined in the shader
  17305. * @param value Define the value to give to the uniform
  17306. * @return the material itself allowing "fluent" like uniform updates
  17307. */
  17308. setInt(name: string, value: number): ShaderMaterial;
  17309. /**
  17310. * Set an array of floats in the shader.
  17311. * @param name Define the name of the uniform as defined in the shader
  17312. * @param value Define the value to give to the uniform
  17313. * @return the material itself allowing "fluent" like uniform updates
  17314. */
  17315. setFloats(name: string, value: number[]): ShaderMaterial;
  17316. /**
  17317. * Set a vec3 in the shader from a Color3.
  17318. * @param name Define the name of the uniform as defined in the shader
  17319. * @param value Define the value to give to the uniform
  17320. * @return the material itself allowing "fluent" like uniform updates
  17321. */
  17322. setColor3(name: string, value: Color3): ShaderMaterial;
  17323. /**
  17324. * Set a vec3 array in the shader from a Color3 array.
  17325. * @param name Define the name of the uniform as defined in the shader
  17326. * @param value Define the value to give to the uniform
  17327. * @return the material itself allowing "fluent" like uniform updates
  17328. */
  17329. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17330. /**
  17331. * Set a vec4 in the shader from a Color4.
  17332. * @param name Define the name of the uniform as defined in the shader
  17333. * @param value Define the value to give to the uniform
  17334. * @return the material itself allowing "fluent" like uniform updates
  17335. */
  17336. setColor4(name: string, value: Color4): ShaderMaterial;
  17337. /**
  17338. * Set a vec2 in the shader from a Vector2.
  17339. * @param name Define the name of the uniform as defined in the shader
  17340. * @param value Define the value to give to the uniform
  17341. * @return the material itself allowing "fluent" like uniform updates
  17342. */
  17343. setVector2(name: string, value: Vector2): ShaderMaterial;
  17344. /**
  17345. * Set a vec3 in the shader from a Vector3.
  17346. * @param name Define the name of the uniform as defined in the shader
  17347. * @param value Define the value to give to the uniform
  17348. * @return the material itself allowing "fluent" like uniform updates
  17349. */
  17350. setVector3(name: string, value: Vector3): ShaderMaterial;
  17351. /**
  17352. * Set a vec4 in the shader from a Vector4.
  17353. * @param name Define the name of the uniform as defined in the shader
  17354. * @param value Define the value to give to the uniform
  17355. * @return the material itself allowing "fluent" like uniform updates
  17356. */
  17357. setVector4(name: string, value: Vector4): ShaderMaterial;
  17358. /**
  17359. * Set a mat4 in the shader from a Matrix.
  17360. * @param name Define the name of the uniform as defined in the shader
  17361. * @param value Define the value to give to the uniform
  17362. * @return the material itself allowing "fluent" like uniform updates
  17363. */
  17364. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17365. /**
  17366. * Set a mat3 in the shader from a Float32Array.
  17367. * @param name Define the name of the uniform as defined in the shader
  17368. * @param value Define the value to give to the uniform
  17369. * @return the material itself allowing "fluent" like uniform updates
  17370. */
  17371. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17372. /**
  17373. * Set a mat2 in the shader from a Float32Array.
  17374. * @param name Define the name of the uniform as defined in the shader
  17375. * @param value Define the value to give to the uniform
  17376. * @return the material itself allowing "fluent" like uniform updates
  17377. */
  17378. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17379. /**
  17380. * Set a vec2 array in the shader from a number array.
  17381. * @param name Define the name of the uniform as defined in the shader
  17382. * @param value Define the value to give to the uniform
  17383. * @return the material itself allowing "fluent" like uniform updates
  17384. */
  17385. setArray2(name: string, value: number[]): ShaderMaterial;
  17386. /**
  17387. * Set a vec3 array in the shader from a number array.
  17388. * @param name Define the name of the uniform as defined in the shader
  17389. * @param value Define the value to give to the uniform
  17390. * @return the material itself allowing "fluent" like uniform updates
  17391. */
  17392. setArray3(name: string, value: number[]): ShaderMaterial;
  17393. private _checkCache;
  17394. /**
  17395. * Specifies that the submesh is ready to be used
  17396. * @param mesh defines the mesh to check
  17397. * @param subMesh defines which submesh to check
  17398. * @param useInstances specifies that instances should be used
  17399. * @returns a boolean indicating that the submesh is ready or not
  17400. */
  17401. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17402. /**
  17403. * Checks if the material is ready to render the requested mesh
  17404. * @param mesh Define the mesh to render
  17405. * @param useInstances Define whether or not the material is used with instances
  17406. * @returns true if ready, otherwise false
  17407. */
  17408. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17409. /**
  17410. * Binds the world matrix to the material
  17411. * @param world defines the world transformation matrix
  17412. */
  17413. bindOnlyWorldMatrix(world: Matrix): void;
  17414. /**
  17415. * Binds the material to the mesh
  17416. * @param world defines the world transformation matrix
  17417. * @param mesh defines the mesh to bind the material to
  17418. */
  17419. bind(world: Matrix, mesh?: Mesh): void;
  17420. /**
  17421. * Gets the active textures from the material
  17422. * @returns an array of textures
  17423. */
  17424. getActiveTextures(): BaseTexture[];
  17425. /**
  17426. * Specifies if the material uses a texture
  17427. * @param texture defines the texture to check against the material
  17428. * @returns a boolean specifying if the material uses the texture
  17429. */
  17430. hasTexture(texture: BaseTexture): boolean;
  17431. /**
  17432. * Makes a duplicate of the material, and gives it a new name
  17433. * @param name defines the new name for the duplicated material
  17434. * @returns the cloned material
  17435. */
  17436. clone(name: string): ShaderMaterial;
  17437. /**
  17438. * Disposes the material
  17439. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17440. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17441. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17442. */
  17443. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17444. /**
  17445. * Serializes this material in a JSON representation
  17446. * @returns the serialized material object
  17447. */
  17448. serialize(): any;
  17449. /**
  17450. * Creates a shader material from parsed shader material data
  17451. * @param source defines the JSON represnetation of the material
  17452. * @param scene defines the hosting scene
  17453. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17454. * @returns a new material
  17455. */
  17456. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17457. }
  17458. }
  17459. declare module "babylonjs/Shaders/color.fragment" {
  17460. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17461. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17462. /** @hidden */
  17463. export var colorPixelShader: {
  17464. name: string;
  17465. shader: string;
  17466. };
  17467. }
  17468. declare module "babylonjs/Shaders/color.vertex" {
  17469. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17471. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17472. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17473. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17474. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17475. /** @hidden */
  17476. export var colorVertexShader: {
  17477. name: string;
  17478. shader: string;
  17479. };
  17480. }
  17481. declare module "babylonjs/Meshes/linesMesh" {
  17482. import { Nullable } from "babylonjs/types";
  17483. import { Scene } from "babylonjs/scene";
  17484. import { Color3 } from "babylonjs/Maths/math";
  17485. import { Node } from "babylonjs/node";
  17486. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17487. import { Mesh } from "babylonjs/Meshes/mesh";
  17488. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17489. import { Effect } from "babylonjs/Materials/effect";
  17490. import { Material } from "babylonjs/Materials/material";
  17491. import "babylonjs/Shaders/color.fragment";
  17492. import "babylonjs/Shaders/color.vertex";
  17493. /**
  17494. * Line mesh
  17495. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17496. */
  17497. export class LinesMesh extends Mesh {
  17498. /**
  17499. * If vertex color should be applied to the mesh
  17500. */
  17501. useVertexColor?: boolean | undefined;
  17502. /**
  17503. * If vertex alpha should be applied to the mesh
  17504. */
  17505. useVertexAlpha?: boolean | undefined;
  17506. /**
  17507. * Color of the line (Default: White)
  17508. */
  17509. color: Color3;
  17510. /**
  17511. * Alpha of the line (Default: 1)
  17512. */
  17513. alpha: number;
  17514. /**
  17515. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17516. * This margin is expressed in world space coordinates, so its value may vary.
  17517. * Default value is 0.1
  17518. */
  17519. intersectionThreshold: number;
  17520. private _colorShader;
  17521. /**
  17522. * Creates a new LinesMesh
  17523. * @param name defines the name
  17524. * @param scene defines the hosting scene
  17525. * @param parent defines the parent mesh if any
  17526. * @param source defines the optional source LinesMesh used to clone data from
  17527. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17528. * When false, achieved by calling a clone(), also passing False.
  17529. * This will make creation of children, recursive.
  17530. * @param useVertexColor defines if this LinesMesh supports vertex color
  17531. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17532. */
  17533. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17534. /**
  17535. * If vertex color should be applied to the mesh
  17536. */
  17537. useVertexColor?: boolean | undefined,
  17538. /**
  17539. * If vertex alpha should be applied to the mesh
  17540. */
  17541. useVertexAlpha?: boolean | undefined);
  17542. private _addClipPlaneDefine;
  17543. private _removeClipPlaneDefine;
  17544. isReady(): boolean;
  17545. /**
  17546. * Returns the string "LineMesh"
  17547. */
  17548. getClassName(): string;
  17549. /**
  17550. * @hidden
  17551. */
  17552. /**
  17553. * @hidden
  17554. */
  17555. material: Material;
  17556. /**
  17557. * @hidden
  17558. */
  17559. readonly checkCollisions: boolean;
  17560. /** @hidden */
  17561. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17562. /** @hidden */
  17563. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17564. /**
  17565. * Disposes of the line mesh
  17566. * @param doNotRecurse If children should be disposed
  17567. */
  17568. dispose(doNotRecurse?: boolean): void;
  17569. /**
  17570. * Returns a new LineMesh object cloned from the current one.
  17571. */
  17572. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17573. /**
  17574. * Creates a new InstancedLinesMesh object from the mesh model.
  17575. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17576. * @param name defines the name of the new instance
  17577. * @returns a new InstancedLinesMesh
  17578. */
  17579. createInstance(name: string): InstancedLinesMesh;
  17580. }
  17581. /**
  17582. * Creates an instance based on a source LinesMesh
  17583. */
  17584. export class InstancedLinesMesh extends InstancedMesh {
  17585. /**
  17586. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17587. * This margin is expressed in world space coordinates, so its value may vary.
  17588. * Initilized with the intersectionThreshold value of the source LinesMesh
  17589. */
  17590. intersectionThreshold: number;
  17591. constructor(name: string, source: LinesMesh);
  17592. /**
  17593. * Returns the string "InstancedLinesMesh".
  17594. */
  17595. getClassName(): string;
  17596. }
  17597. }
  17598. declare module "babylonjs/Shaders/line.fragment" {
  17599. /** @hidden */
  17600. export var linePixelShader: {
  17601. name: string;
  17602. shader: string;
  17603. };
  17604. }
  17605. declare module "babylonjs/Shaders/line.vertex" {
  17606. /** @hidden */
  17607. export var lineVertexShader: {
  17608. name: string;
  17609. shader: string;
  17610. };
  17611. }
  17612. declare module "babylonjs/Rendering/edgesRenderer" {
  17613. import { Nullable } from "babylonjs/types";
  17614. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17616. import { Vector3 } from "babylonjs/Maths/math";
  17617. import { IDisposable } from "babylonjs/scene";
  17618. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17619. import "babylonjs/Shaders/line.fragment";
  17620. import "babylonjs/Shaders/line.vertex";
  17621. module "babylonjs/Meshes/abstractMesh" {
  17622. interface AbstractMesh {
  17623. /**
  17624. * Disables the mesh edge rendering mode
  17625. * @returns the currentAbstractMesh
  17626. */
  17627. disableEdgesRendering(): AbstractMesh;
  17628. /**
  17629. * Enables the edge rendering mode on the mesh.
  17630. * This mode makes the mesh edges visible
  17631. * @param epsilon defines the maximal distance between two angles to detect a face
  17632. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17633. * @returns the currentAbstractMesh
  17634. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17635. */
  17636. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17637. /**
  17638. * Gets the edgesRenderer associated with the mesh
  17639. */
  17640. edgesRenderer: Nullable<EdgesRenderer>;
  17641. }
  17642. }
  17643. module "babylonjs/Meshes/linesMesh" {
  17644. interface LinesMesh {
  17645. /**
  17646. * Enables the edge rendering mode on the mesh.
  17647. * This mode makes the mesh edges visible
  17648. * @param epsilon defines the maximal distance between two angles to detect a face
  17649. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17650. * @returns the currentAbstractMesh
  17651. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17652. */
  17653. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17654. }
  17655. }
  17656. module "babylonjs/Meshes/linesMesh" {
  17657. interface InstancedLinesMesh {
  17658. /**
  17659. * Enables the edge rendering mode on the mesh.
  17660. * This mode makes the mesh edges visible
  17661. * @param epsilon defines the maximal distance between two angles to detect a face
  17662. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17663. * @returns the current InstancedLinesMesh
  17664. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17665. */
  17666. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17667. }
  17668. }
  17669. /**
  17670. * Defines the minimum contract an Edges renderer should follow.
  17671. */
  17672. export interface IEdgesRenderer extends IDisposable {
  17673. /**
  17674. * Gets or sets a boolean indicating if the edgesRenderer is active
  17675. */
  17676. isEnabled: boolean;
  17677. /**
  17678. * Renders the edges of the attached mesh,
  17679. */
  17680. render(): void;
  17681. /**
  17682. * Checks wether or not the edges renderer is ready to render.
  17683. * @return true if ready, otherwise false.
  17684. */
  17685. isReady(): boolean;
  17686. }
  17687. /**
  17688. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17689. */
  17690. export class EdgesRenderer implements IEdgesRenderer {
  17691. /**
  17692. * Define the size of the edges with an orthographic camera
  17693. */
  17694. edgesWidthScalerForOrthographic: number;
  17695. /**
  17696. * Define the size of the edges with a perspective camera
  17697. */
  17698. edgesWidthScalerForPerspective: number;
  17699. protected _source: AbstractMesh;
  17700. protected _linesPositions: number[];
  17701. protected _linesNormals: number[];
  17702. protected _linesIndices: number[];
  17703. protected _epsilon: number;
  17704. protected _indicesCount: number;
  17705. protected _lineShader: ShaderMaterial;
  17706. protected _ib: WebGLBuffer;
  17707. protected _buffers: {
  17708. [key: string]: Nullable<VertexBuffer>;
  17709. };
  17710. protected _checkVerticesInsteadOfIndices: boolean;
  17711. private _meshRebuildObserver;
  17712. private _meshDisposeObserver;
  17713. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17714. isEnabled: boolean;
  17715. /**
  17716. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17717. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17718. * @param source Mesh used to create edges
  17719. * @param epsilon sum of angles in adjacency to check for edge
  17720. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17721. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17722. */
  17723. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17724. protected _prepareRessources(): void;
  17725. /** @hidden */
  17726. _rebuild(): void;
  17727. /**
  17728. * Releases the required resources for the edges renderer
  17729. */
  17730. dispose(): void;
  17731. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17732. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17733. /**
  17734. * Checks if the pair of p0 and p1 is en edge
  17735. * @param faceIndex
  17736. * @param edge
  17737. * @param faceNormals
  17738. * @param p0
  17739. * @param p1
  17740. * @private
  17741. */
  17742. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17743. /**
  17744. * push line into the position, normal and index buffer
  17745. * @protected
  17746. */
  17747. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17748. /**
  17749. * Generates lines edges from adjacencjes
  17750. * @private
  17751. */
  17752. _generateEdgesLines(): void;
  17753. /**
  17754. * Checks wether or not the edges renderer is ready to render.
  17755. * @return true if ready, otherwise false.
  17756. */
  17757. isReady(): boolean;
  17758. /**
  17759. * Renders the edges of the attached mesh,
  17760. */
  17761. render(): void;
  17762. }
  17763. /**
  17764. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17765. */
  17766. export class LineEdgesRenderer extends EdgesRenderer {
  17767. /**
  17768. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17769. * @param source LineMesh used to generate edges
  17770. * @param epsilon not important (specified angle for edge detection)
  17771. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17772. */
  17773. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17774. /**
  17775. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17776. */
  17777. _generateEdgesLines(): void;
  17778. }
  17779. }
  17780. declare module "babylonjs/Rendering/renderingGroup" {
  17781. import { SmartArray } from "babylonjs/Misc/smartArray";
  17782. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17784. import { Nullable } from "babylonjs/types";
  17785. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17786. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17787. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17788. import { Material } from "babylonjs/Materials/material";
  17789. import { Scene } from "babylonjs/scene";
  17790. /**
  17791. * This represents the object necessary to create a rendering group.
  17792. * This is exclusively used and created by the rendering manager.
  17793. * To modify the behavior, you use the available helpers in your scene or meshes.
  17794. * @hidden
  17795. */
  17796. export class RenderingGroup {
  17797. index: number;
  17798. private _scene;
  17799. private _opaqueSubMeshes;
  17800. private _transparentSubMeshes;
  17801. private _alphaTestSubMeshes;
  17802. private _depthOnlySubMeshes;
  17803. private _particleSystems;
  17804. private _spriteManagers;
  17805. private _opaqueSortCompareFn;
  17806. private _alphaTestSortCompareFn;
  17807. private _transparentSortCompareFn;
  17808. private _renderOpaque;
  17809. private _renderAlphaTest;
  17810. private _renderTransparent;
  17811. /** @hidden */
  17812. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17813. onBeforeTransparentRendering: () => void;
  17814. /**
  17815. * Set the opaque sort comparison function.
  17816. * If null the sub meshes will be render in the order they were created
  17817. */
  17818. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17819. /**
  17820. * Set the alpha test sort comparison function.
  17821. * If null the sub meshes will be render in the order they were created
  17822. */
  17823. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17824. /**
  17825. * Set the transparent sort comparison function.
  17826. * If null the sub meshes will be render in the order they were created
  17827. */
  17828. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17829. /**
  17830. * Creates a new rendering group.
  17831. * @param index The rendering group index
  17832. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17833. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17834. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17835. */
  17836. 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>);
  17837. /**
  17838. * Render all the sub meshes contained in the group.
  17839. * @param customRenderFunction Used to override the default render behaviour of the group.
  17840. * @returns true if rendered some submeshes.
  17841. */
  17842. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17843. /**
  17844. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17845. * @param subMeshes The submeshes to render
  17846. */
  17847. private renderOpaqueSorted;
  17848. /**
  17849. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17850. * @param subMeshes The submeshes to render
  17851. */
  17852. private renderAlphaTestSorted;
  17853. /**
  17854. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17855. * @param subMeshes The submeshes to render
  17856. */
  17857. private renderTransparentSorted;
  17858. /**
  17859. * Renders the submeshes in a specified order.
  17860. * @param subMeshes The submeshes to sort before render
  17861. * @param sortCompareFn The comparison function use to sort
  17862. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17863. * @param transparent Specifies to activate blending if true
  17864. */
  17865. private static renderSorted;
  17866. /**
  17867. * Renders the submeshes in the order they were dispatched (no sort applied).
  17868. * @param subMeshes The submeshes to render
  17869. */
  17870. private static renderUnsorted;
  17871. /**
  17872. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17873. * are rendered back to front if in the same alpha index.
  17874. *
  17875. * @param a The first submesh
  17876. * @param b The second submesh
  17877. * @returns The result of the comparison
  17878. */
  17879. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17880. /**
  17881. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17882. * are rendered back to front.
  17883. *
  17884. * @param a The first submesh
  17885. * @param b The second submesh
  17886. * @returns The result of the comparison
  17887. */
  17888. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17889. /**
  17890. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17891. * are rendered front to back (prevent overdraw).
  17892. *
  17893. * @param a The first submesh
  17894. * @param b The second submesh
  17895. * @returns The result of the comparison
  17896. */
  17897. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17898. /**
  17899. * Resets the different lists of submeshes to prepare a new frame.
  17900. */
  17901. prepare(): void;
  17902. dispose(): void;
  17903. /**
  17904. * Inserts the submesh in its correct queue depending on its material.
  17905. * @param subMesh The submesh to dispatch
  17906. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17907. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17908. */
  17909. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17910. dispatchSprites(spriteManager: ISpriteManager): void;
  17911. dispatchParticles(particleSystem: IParticleSystem): void;
  17912. private _renderParticles;
  17913. private _renderSprites;
  17914. }
  17915. }
  17916. declare module "babylonjs/Rendering/renderingManager" {
  17917. import { Nullable } from "babylonjs/types";
  17918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17919. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17920. import { SmartArray } from "babylonjs/Misc/smartArray";
  17921. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17922. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17923. import { Material } from "babylonjs/Materials/material";
  17924. import { Scene } from "babylonjs/scene";
  17925. import { Camera } from "babylonjs/Cameras/camera";
  17926. /**
  17927. * Interface describing the different options available in the rendering manager
  17928. * regarding Auto Clear between groups.
  17929. */
  17930. export interface IRenderingManagerAutoClearSetup {
  17931. /**
  17932. * Defines whether or not autoclear is enable.
  17933. */
  17934. autoClear: boolean;
  17935. /**
  17936. * Defines whether or not to autoclear the depth buffer.
  17937. */
  17938. depth: boolean;
  17939. /**
  17940. * Defines whether or not to autoclear the stencil buffer.
  17941. */
  17942. stencil: boolean;
  17943. }
  17944. /**
  17945. * This class is used by the onRenderingGroupObservable
  17946. */
  17947. export class RenderingGroupInfo {
  17948. /**
  17949. * The Scene that being rendered
  17950. */
  17951. scene: Scene;
  17952. /**
  17953. * The camera currently used for the rendering pass
  17954. */
  17955. camera: Nullable<Camera>;
  17956. /**
  17957. * The ID of the renderingGroup being processed
  17958. */
  17959. renderingGroupId: number;
  17960. }
  17961. /**
  17962. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17963. * It is enable to manage the different groups as well as the different necessary sort functions.
  17964. * This should not be used directly aside of the few static configurations
  17965. */
  17966. export class RenderingManager {
  17967. /**
  17968. * The max id used for rendering groups (not included)
  17969. */
  17970. static MAX_RENDERINGGROUPS: number;
  17971. /**
  17972. * The min id used for rendering groups (included)
  17973. */
  17974. static MIN_RENDERINGGROUPS: number;
  17975. /**
  17976. * Used to globally prevent autoclearing scenes.
  17977. */
  17978. static AUTOCLEAR: boolean;
  17979. /**
  17980. * @hidden
  17981. */
  17982. _useSceneAutoClearSetup: boolean;
  17983. private _scene;
  17984. private _renderingGroups;
  17985. private _depthStencilBufferAlreadyCleaned;
  17986. private _autoClearDepthStencil;
  17987. private _customOpaqueSortCompareFn;
  17988. private _customAlphaTestSortCompareFn;
  17989. private _customTransparentSortCompareFn;
  17990. private _renderingGroupInfo;
  17991. /**
  17992. * Instantiates a new rendering group for a particular scene
  17993. * @param scene Defines the scene the groups belongs to
  17994. */
  17995. constructor(scene: Scene);
  17996. private _clearDepthStencilBuffer;
  17997. /**
  17998. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17999. * @hidden
  18000. */
  18001. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18002. /**
  18003. * Resets the different information of the group to prepare a new frame
  18004. * @hidden
  18005. */
  18006. reset(): void;
  18007. /**
  18008. * Dispose and release the group and its associated resources.
  18009. * @hidden
  18010. */
  18011. dispose(): void;
  18012. /**
  18013. * Clear the info related to rendering groups preventing retention points during dispose.
  18014. */
  18015. freeRenderingGroups(): void;
  18016. private _prepareRenderingGroup;
  18017. /**
  18018. * Add a sprite manager to the rendering manager in order to render it this frame.
  18019. * @param spriteManager Define the sprite manager to render
  18020. */
  18021. dispatchSprites(spriteManager: ISpriteManager): void;
  18022. /**
  18023. * Add a particle system to the rendering manager in order to render it this frame.
  18024. * @param particleSystem Define the particle system to render
  18025. */
  18026. dispatchParticles(particleSystem: IParticleSystem): void;
  18027. /**
  18028. * Add a submesh to the manager in order to render it this frame
  18029. * @param subMesh The submesh to dispatch
  18030. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18031. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18032. */
  18033. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18034. /**
  18035. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18036. * This allowed control for front to back rendering or reversly depending of the special needs.
  18037. *
  18038. * @param renderingGroupId The rendering group id corresponding to its index
  18039. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18040. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18041. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18042. */
  18043. 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;
  18044. /**
  18045. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18046. *
  18047. * @param renderingGroupId The rendering group id corresponding to its index
  18048. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18049. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18050. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18051. */
  18052. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18053. /**
  18054. * Gets the current auto clear configuration for one rendering group of the rendering
  18055. * manager.
  18056. * @param index the rendering group index to get the information for
  18057. * @returns The auto clear setup for the requested rendering group
  18058. */
  18059. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18060. }
  18061. }
  18062. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18063. import { Observable } from "babylonjs/Misc/observable";
  18064. import { SmartArray } from "babylonjs/Misc/smartArray";
  18065. import { Nullable } from "babylonjs/types";
  18066. import { Camera } from "babylonjs/Cameras/camera";
  18067. import { Scene } from "babylonjs/scene";
  18068. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18069. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18071. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18072. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18073. import { Texture } from "babylonjs/Materials/Textures/texture";
  18074. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18075. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18076. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18077. import { Engine } from "babylonjs/Engines/engine";
  18078. /**
  18079. * This Helps creating a texture that will be created from a camera in your scene.
  18080. * It is basically a dynamic texture that could be used to create special effects for instance.
  18081. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18082. */
  18083. export class RenderTargetTexture extends Texture {
  18084. isCube: boolean;
  18085. /**
  18086. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18087. */
  18088. static readonly REFRESHRATE_RENDER_ONCE: number;
  18089. /**
  18090. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18091. */
  18092. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18093. /**
  18094. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18095. * the central point of your effect and can save a lot of performances.
  18096. */
  18097. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18098. /**
  18099. * Use this predicate to dynamically define the list of mesh you want to render.
  18100. * If set, the renderList property will be overwritten.
  18101. */
  18102. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18103. private _renderList;
  18104. /**
  18105. * Use this list to define the list of mesh you want to render.
  18106. */
  18107. renderList: Nullable<Array<AbstractMesh>>;
  18108. private _hookArray;
  18109. /**
  18110. * Define if particles should be rendered in your texture.
  18111. */
  18112. renderParticles: boolean;
  18113. /**
  18114. * Define if sprites should be rendered in your texture.
  18115. */
  18116. renderSprites: boolean;
  18117. /**
  18118. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18119. */
  18120. coordinatesMode: number;
  18121. /**
  18122. * Define the camera used to render the texture.
  18123. */
  18124. activeCamera: Nullable<Camera>;
  18125. /**
  18126. * Override the render function of the texture with your own one.
  18127. */
  18128. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18129. /**
  18130. * Define if camera post processes should be use while rendering the texture.
  18131. */
  18132. useCameraPostProcesses: boolean;
  18133. /**
  18134. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18135. */
  18136. ignoreCameraViewport: boolean;
  18137. private _postProcessManager;
  18138. private _postProcesses;
  18139. private _resizeObserver;
  18140. /**
  18141. * An event triggered when the texture is unbind.
  18142. */
  18143. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18144. /**
  18145. * An event triggered when the texture is unbind.
  18146. */
  18147. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18148. private _onAfterUnbindObserver;
  18149. /**
  18150. * Set a after unbind callback in the texture.
  18151. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18152. */
  18153. onAfterUnbind: () => void;
  18154. /**
  18155. * An event triggered before rendering the texture
  18156. */
  18157. onBeforeRenderObservable: Observable<number>;
  18158. private _onBeforeRenderObserver;
  18159. /**
  18160. * Set a before render callback in the texture.
  18161. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18162. */
  18163. onBeforeRender: (faceIndex: number) => void;
  18164. /**
  18165. * An event triggered after rendering the texture
  18166. */
  18167. onAfterRenderObservable: Observable<number>;
  18168. private _onAfterRenderObserver;
  18169. /**
  18170. * Set a after render callback in the texture.
  18171. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18172. */
  18173. onAfterRender: (faceIndex: number) => void;
  18174. /**
  18175. * An event triggered after the texture clear
  18176. */
  18177. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18178. private _onClearObserver;
  18179. /**
  18180. * Set a clear callback in the texture.
  18181. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18182. */
  18183. onClear: (Engine: Engine) => void;
  18184. /**
  18185. * Define the clear color of the Render Target if it should be different from the scene.
  18186. */
  18187. clearColor: Color4;
  18188. protected _size: number | {
  18189. width: number;
  18190. height: number;
  18191. };
  18192. protected _initialSizeParameter: number | {
  18193. width: number;
  18194. height: number;
  18195. } | {
  18196. ratio: number;
  18197. };
  18198. protected _sizeRatio: Nullable<number>;
  18199. /** @hidden */
  18200. _generateMipMaps: boolean;
  18201. protected _renderingManager: RenderingManager;
  18202. /** @hidden */
  18203. _waitingRenderList: string[];
  18204. protected _doNotChangeAspectRatio: boolean;
  18205. protected _currentRefreshId: number;
  18206. protected _refreshRate: number;
  18207. protected _textureMatrix: Matrix;
  18208. protected _samples: number;
  18209. protected _renderTargetOptions: RenderTargetCreationOptions;
  18210. /**
  18211. * Gets render target creation options that were used.
  18212. */
  18213. readonly renderTargetOptions: RenderTargetCreationOptions;
  18214. protected _engine: Engine;
  18215. protected _onRatioRescale(): void;
  18216. /**
  18217. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18218. * It must define where the camera used to render the texture is set
  18219. */
  18220. boundingBoxPosition: Vector3;
  18221. private _boundingBoxSize;
  18222. /**
  18223. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18224. * When defined, the cubemap will switch to local mode
  18225. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18226. * @example https://www.babylonjs-playground.com/#RNASML
  18227. */
  18228. boundingBoxSize: Vector3;
  18229. /**
  18230. * In case the RTT has been created with a depth texture, get the associated
  18231. * depth texture.
  18232. * Otherwise, return null.
  18233. */
  18234. depthStencilTexture: Nullable<InternalTexture>;
  18235. /**
  18236. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18237. * or used a shadow, depth texture...
  18238. * @param name The friendly name of the texture
  18239. * @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)
  18240. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18241. * @param generateMipMaps True if mip maps need to be generated after render.
  18242. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18243. * @param type The type of the buffer in the RTT (int, half float, float...)
  18244. * @param isCube True if a cube texture needs to be created
  18245. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18246. * @param generateDepthBuffer True to generate a depth buffer
  18247. * @param generateStencilBuffer True to generate a stencil buffer
  18248. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18249. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18250. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18251. */
  18252. constructor(name: string, size: number | {
  18253. width: number;
  18254. height: number;
  18255. } | {
  18256. ratio: number;
  18257. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18258. /**
  18259. * Creates a depth stencil texture.
  18260. * This is only available in WebGL 2 or with the depth texture extension available.
  18261. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18262. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18263. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18264. */
  18265. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18266. private _processSizeParameter;
  18267. /**
  18268. * Define the number of samples to use in case of MSAA.
  18269. * It defaults to one meaning no MSAA has been enabled.
  18270. */
  18271. samples: number;
  18272. /**
  18273. * Resets the refresh counter of the texture and start bak from scratch.
  18274. * Could be useful to regenerate the texture if it is setup to render only once.
  18275. */
  18276. resetRefreshCounter(): void;
  18277. /**
  18278. * Define the refresh rate of the texture or the rendering frequency.
  18279. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18280. */
  18281. refreshRate: number;
  18282. /**
  18283. * Adds a post process to the render target rendering passes.
  18284. * @param postProcess define the post process to add
  18285. */
  18286. addPostProcess(postProcess: PostProcess): void;
  18287. /**
  18288. * Clear all the post processes attached to the render target
  18289. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18290. */
  18291. clearPostProcesses(dispose?: boolean): void;
  18292. /**
  18293. * Remove one of the post process from the list of attached post processes to the texture
  18294. * @param postProcess define the post process to remove from the list
  18295. */
  18296. removePostProcess(postProcess: PostProcess): void;
  18297. /** @hidden */
  18298. _shouldRender(): boolean;
  18299. /**
  18300. * Gets the actual render size of the texture.
  18301. * @returns the width of the render size
  18302. */
  18303. getRenderSize(): number;
  18304. /**
  18305. * Gets the actual render width of the texture.
  18306. * @returns the width of the render size
  18307. */
  18308. getRenderWidth(): number;
  18309. /**
  18310. * Gets the actual render height of the texture.
  18311. * @returns the height of the render size
  18312. */
  18313. getRenderHeight(): number;
  18314. /**
  18315. * Get if the texture can be rescaled or not.
  18316. */
  18317. readonly canRescale: boolean;
  18318. /**
  18319. * Resize the texture using a ratio.
  18320. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18321. */
  18322. scale(ratio: number): void;
  18323. /**
  18324. * Get the texture reflection matrix used to rotate/transform the reflection.
  18325. * @returns the reflection matrix
  18326. */
  18327. getReflectionTextureMatrix(): Matrix;
  18328. /**
  18329. * Resize the texture to a new desired size.
  18330. * Be carrefull as it will recreate all the data in the new texture.
  18331. * @param size Define the new size. It can be:
  18332. * - a number for squared texture,
  18333. * - an object containing { width: number, height: number }
  18334. * - or an object containing a ratio { ratio: number }
  18335. */
  18336. resize(size: number | {
  18337. width: number;
  18338. height: number;
  18339. } | {
  18340. ratio: number;
  18341. }): void;
  18342. /**
  18343. * Renders all the objects from the render list into the texture.
  18344. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18345. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18346. */
  18347. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18348. private _bestReflectionRenderTargetDimension;
  18349. /**
  18350. * @hidden
  18351. * @param faceIndex face index to bind to if this is a cubetexture
  18352. */
  18353. _bindFrameBuffer(faceIndex?: number): void;
  18354. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18355. private renderToTarget;
  18356. /**
  18357. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18358. * This allowed control for front to back rendering or reversly depending of the special needs.
  18359. *
  18360. * @param renderingGroupId The rendering group id corresponding to its index
  18361. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18362. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18363. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18364. */
  18365. 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;
  18366. /**
  18367. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18368. *
  18369. * @param renderingGroupId The rendering group id corresponding to its index
  18370. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18371. */
  18372. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18373. /**
  18374. * Clones the texture.
  18375. * @returns the cloned texture
  18376. */
  18377. clone(): RenderTargetTexture;
  18378. /**
  18379. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18380. * @returns The JSON representation of the texture
  18381. */
  18382. serialize(): any;
  18383. /**
  18384. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18385. */
  18386. disposeFramebufferObjects(): void;
  18387. /**
  18388. * Dispose the texture and release its associated resources.
  18389. */
  18390. dispose(): void;
  18391. /** @hidden */
  18392. _rebuild(): void;
  18393. /**
  18394. * Clear the info related to rendering groups preventing retention point in material dispose.
  18395. */
  18396. freeRenderingGroups(): void;
  18397. /**
  18398. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18399. * @returns the view count
  18400. */
  18401. getViewCount(): number;
  18402. }
  18403. }
  18404. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18405. import { Scene } from "babylonjs/scene";
  18406. import { Plane } from "babylonjs/Maths/math";
  18407. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18408. /**
  18409. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18410. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18411. * You can then easily use it as a reflectionTexture on a flat surface.
  18412. * In case the surface is not a plane, please consider relying on reflection probes.
  18413. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18414. */
  18415. export class MirrorTexture extends RenderTargetTexture {
  18416. private scene;
  18417. /**
  18418. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18419. * 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.
  18420. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18421. */
  18422. mirrorPlane: Plane;
  18423. /**
  18424. * Define the blur ratio used to blur the reflection if needed.
  18425. */
  18426. blurRatio: number;
  18427. /**
  18428. * Define the adaptive blur kernel used to blur the reflection if needed.
  18429. * This will autocompute the closest best match for the `blurKernel`
  18430. */
  18431. adaptiveBlurKernel: number;
  18432. /**
  18433. * Define the blur kernel used to blur the reflection if needed.
  18434. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18435. */
  18436. blurKernel: number;
  18437. /**
  18438. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18439. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18440. */
  18441. blurKernelX: number;
  18442. /**
  18443. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18444. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18445. */
  18446. blurKernelY: number;
  18447. private _autoComputeBlurKernel;
  18448. protected _onRatioRescale(): void;
  18449. private _updateGammaSpace;
  18450. private _imageProcessingConfigChangeObserver;
  18451. private _transformMatrix;
  18452. private _mirrorMatrix;
  18453. private _savedViewMatrix;
  18454. private _blurX;
  18455. private _blurY;
  18456. private _adaptiveBlurKernel;
  18457. private _blurKernelX;
  18458. private _blurKernelY;
  18459. private _blurRatio;
  18460. /**
  18461. * Instantiates a Mirror Texture.
  18462. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18463. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18464. * You can then easily use it as a reflectionTexture on a flat surface.
  18465. * In case the surface is not a plane, please consider relying on reflection probes.
  18466. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18467. * @param name
  18468. * @param size
  18469. * @param scene
  18470. * @param generateMipMaps
  18471. * @param type
  18472. * @param samplingMode
  18473. * @param generateDepthBuffer
  18474. */
  18475. constructor(name: string, size: number | {
  18476. width: number;
  18477. height: number;
  18478. } | {
  18479. ratio: number;
  18480. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18481. private _preparePostProcesses;
  18482. /**
  18483. * Clone the mirror texture.
  18484. * @returns the cloned texture
  18485. */
  18486. clone(): MirrorTexture;
  18487. /**
  18488. * Serialize the texture to a JSON representation you could use in Parse later on
  18489. * @returns the serialized JSON representation
  18490. */
  18491. serialize(): any;
  18492. /**
  18493. * Dispose the texture and release its associated resources.
  18494. */
  18495. dispose(): void;
  18496. }
  18497. }
  18498. declare module "babylonjs/Materials/Textures/texture" {
  18499. import { Observable } from "babylonjs/Misc/observable";
  18500. import { Nullable } from "babylonjs/types";
  18501. import { Scene } from "babylonjs/scene";
  18502. import { Matrix } from "babylonjs/Maths/math";
  18503. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18504. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18505. /**
  18506. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18507. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18508. */
  18509. export class Texture extends BaseTexture {
  18510. /** @hidden */
  18511. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18512. /** @hidden */
  18513. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18514. /** @hidden */
  18515. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18516. /** nearest is mag = nearest and min = nearest and mip = linear */
  18517. static readonly NEAREST_SAMPLINGMODE: number;
  18518. /** nearest is mag = nearest and min = nearest and mip = linear */
  18519. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18520. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18521. static readonly BILINEAR_SAMPLINGMODE: number;
  18522. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18523. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18524. /** Trilinear is mag = linear and min = linear and mip = linear */
  18525. static readonly TRILINEAR_SAMPLINGMODE: number;
  18526. /** Trilinear is mag = linear and min = linear and mip = linear */
  18527. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18528. /** mag = nearest and min = nearest and mip = nearest */
  18529. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18530. /** mag = nearest and min = linear and mip = nearest */
  18531. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18532. /** mag = nearest and min = linear and mip = linear */
  18533. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18534. /** mag = nearest and min = linear and mip = none */
  18535. static readonly NEAREST_LINEAR: number;
  18536. /** mag = nearest and min = nearest and mip = none */
  18537. static readonly NEAREST_NEAREST: number;
  18538. /** mag = linear and min = nearest and mip = nearest */
  18539. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18540. /** mag = linear and min = nearest and mip = linear */
  18541. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18542. /** mag = linear and min = linear and mip = none */
  18543. static readonly LINEAR_LINEAR: number;
  18544. /** mag = linear and min = nearest and mip = none */
  18545. static readonly LINEAR_NEAREST: number;
  18546. /** Explicit coordinates mode */
  18547. static readonly EXPLICIT_MODE: number;
  18548. /** Spherical coordinates mode */
  18549. static readonly SPHERICAL_MODE: number;
  18550. /** Planar coordinates mode */
  18551. static readonly PLANAR_MODE: number;
  18552. /** Cubic coordinates mode */
  18553. static readonly CUBIC_MODE: number;
  18554. /** Projection coordinates mode */
  18555. static readonly PROJECTION_MODE: number;
  18556. /** Inverse Cubic coordinates mode */
  18557. static readonly SKYBOX_MODE: number;
  18558. /** Inverse Cubic coordinates mode */
  18559. static readonly INVCUBIC_MODE: number;
  18560. /** Equirectangular coordinates mode */
  18561. static readonly EQUIRECTANGULAR_MODE: number;
  18562. /** Equirectangular Fixed coordinates mode */
  18563. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18564. /** Equirectangular Fixed Mirrored coordinates mode */
  18565. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18566. /** Texture is not repeating outside of 0..1 UVs */
  18567. static readonly CLAMP_ADDRESSMODE: number;
  18568. /** Texture is repeating outside of 0..1 UVs */
  18569. static readonly WRAP_ADDRESSMODE: number;
  18570. /** Texture is repeating and mirrored */
  18571. static readonly MIRROR_ADDRESSMODE: number;
  18572. /**
  18573. * 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
  18574. */
  18575. static UseSerializedUrlIfAny: boolean;
  18576. /**
  18577. * Define the url of the texture.
  18578. */
  18579. url: Nullable<string>;
  18580. /**
  18581. * Define an offset on the texture to offset the u coordinates of the UVs
  18582. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18583. */
  18584. uOffset: number;
  18585. /**
  18586. * Define an offset on the texture to offset the v coordinates of the UVs
  18587. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18588. */
  18589. vOffset: number;
  18590. /**
  18591. * Define an offset on the texture to scale the u coordinates of the UVs
  18592. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18593. */
  18594. uScale: number;
  18595. /**
  18596. * Define an offset on the texture to scale the v coordinates of the UVs
  18597. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18598. */
  18599. vScale: number;
  18600. /**
  18601. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18602. * @see http://doc.babylonjs.com/how_to/more_materials
  18603. */
  18604. uAng: number;
  18605. /**
  18606. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18607. * @see http://doc.babylonjs.com/how_to/more_materials
  18608. */
  18609. vAng: number;
  18610. /**
  18611. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18612. * @see http://doc.babylonjs.com/how_to/more_materials
  18613. */
  18614. wAng: number;
  18615. /**
  18616. * Defines the center of rotation (U)
  18617. */
  18618. uRotationCenter: number;
  18619. /**
  18620. * Defines the center of rotation (V)
  18621. */
  18622. vRotationCenter: number;
  18623. /**
  18624. * Defines the center of rotation (W)
  18625. */
  18626. wRotationCenter: number;
  18627. /**
  18628. * Are mip maps generated for this texture or not.
  18629. */
  18630. readonly noMipmap: boolean;
  18631. /**
  18632. * List of inspectable custom properties (used by the Inspector)
  18633. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18634. */
  18635. inspectableCustomProperties: Nullable<IInspectable[]>;
  18636. private _noMipmap;
  18637. /** @hidden */
  18638. _invertY: boolean;
  18639. private _rowGenerationMatrix;
  18640. private _cachedTextureMatrix;
  18641. private _projectionModeMatrix;
  18642. private _t0;
  18643. private _t1;
  18644. private _t2;
  18645. private _cachedUOffset;
  18646. private _cachedVOffset;
  18647. private _cachedUScale;
  18648. private _cachedVScale;
  18649. private _cachedUAng;
  18650. private _cachedVAng;
  18651. private _cachedWAng;
  18652. private _cachedProjectionMatrixId;
  18653. private _cachedCoordinatesMode;
  18654. /** @hidden */
  18655. protected _initialSamplingMode: number;
  18656. /** @hidden */
  18657. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18658. private _deleteBuffer;
  18659. protected _format: Nullable<number>;
  18660. private _delayedOnLoad;
  18661. private _delayedOnError;
  18662. /**
  18663. * Observable triggered once the texture has been loaded.
  18664. */
  18665. onLoadObservable: Observable<Texture>;
  18666. protected _isBlocking: boolean;
  18667. /**
  18668. * Is the texture preventing material to render while loading.
  18669. * If false, a default texture will be used instead of the loading one during the preparation step.
  18670. */
  18671. isBlocking: boolean;
  18672. /**
  18673. * Get the current sampling mode associated with the texture.
  18674. */
  18675. readonly samplingMode: number;
  18676. /**
  18677. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18678. */
  18679. readonly invertY: boolean;
  18680. /**
  18681. * Instantiates a new texture.
  18682. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18683. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18684. * @param url define the url of the picture to load as a texture
  18685. * @param scene define the scene the texture will belong to
  18686. * @param noMipmap define if the texture will require mip maps or not
  18687. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18688. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18689. * @param onLoad define a callback triggered when the texture has been loaded
  18690. * @param onError define a callback triggered when an error occurred during the loading session
  18691. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18692. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18693. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18694. */
  18695. 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);
  18696. /**
  18697. * Update the url (and optional buffer) of this texture if url was null during construction.
  18698. * @param url the url of the texture
  18699. * @param buffer the buffer of the texture (defaults to null)
  18700. * @param onLoad callback called when the texture is loaded (defaults to null)
  18701. */
  18702. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18703. /**
  18704. * Finish the loading sequence of a texture flagged as delayed load.
  18705. * @hidden
  18706. */
  18707. delayLoad(): void;
  18708. private _prepareRowForTextureGeneration;
  18709. /**
  18710. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18711. * @returns the transform matrix of the texture.
  18712. */
  18713. getTextureMatrix(): Matrix;
  18714. /**
  18715. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18716. * @returns The reflection texture transform
  18717. */
  18718. getReflectionTextureMatrix(): Matrix;
  18719. /**
  18720. * Clones the texture.
  18721. * @returns the cloned texture
  18722. */
  18723. clone(): Texture;
  18724. /**
  18725. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18726. * @returns The JSON representation of the texture
  18727. */
  18728. serialize(): any;
  18729. /**
  18730. * Get the current class name of the texture useful for serialization or dynamic coding.
  18731. * @returns "Texture"
  18732. */
  18733. getClassName(): string;
  18734. /**
  18735. * Dispose the texture and release its associated resources.
  18736. */
  18737. dispose(): void;
  18738. /**
  18739. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18740. * @param parsedTexture Define the JSON representation of the texture
  18741. * @param scene Define the scene the parsed texture should be instantiated in
  18742. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18743. * @returns The parsed texture if successful
  18744. */
  18745. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18746. /**
  18747. * Creates a texture from its base 64 representation.
  18748. * @param data Define the base64 payload without the data: prefix
  18749. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18750. * @param scene Define the scene the texture should belong to
  18751. * @param noMipmap Forces the texture to not create mip map information if true
  18752. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18753. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18754. * @param onLoad define a callback triggered when the texture has been loaded
  18755. * @param onError define a callback triggered when an error occurred during the loading session
  18756. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18757. * @returns the created texture
  18758. */
  18759. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18760. /**
  18761. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18762. * @param data Define the base64 payload without the data: prefix
  18763. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18764. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18765. * @param scene Define the scene the texture should belong to
  18766. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18767. * @param noMipmap Forces the texture to not create mip map information if true
  18768. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18769. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18770. * @param onLoad define a callback triggered when the texture has been loaded
  18771. * @param onError define a callback triggered when an error occurred during the loading session
  18772. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18773. * @returns the created texture
  18774. */
  18775. 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;
  18776. }
  18777. }
  18778. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18779. import { Nullable } from "babylonjs/types";
  18780. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18781. import { Scene } from "babylonjs/scene";
  18782. module "babylonjs/Engines/engine" {
  18783. interface Engine {
  18784. /**
  18785. * Creates a raw texture
  18786. * @param data defines the data to store in the texture
  18787. * @param width defines the width of the texture
  18788. * @param height defines the height of the texture
  18789. * @param format defines the format of the data
  18790. * @param generateMipMaps defines if the engine should generate the mip levels
  18791. * @param invertY defines if data must be stored with Y axis inverted
  18792. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18793. * @param compression defines the compression used (null by default)
  18794. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18795. * @returns the raw texture inside an InternalTexture
  18796. */
  18797. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18798. /**
  18799. * Update a raw texture
  18800. * @param texture defines the texture to update
  18801. * @param data defines the data to store in the texture
  18802. * @param format defines the format of the data
  18803. * @param invertY defines if data must be stored with Y axis inverted
  18804. */
  18805. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18806. /**
  18807. * Update a raw texture
  18808. * @param texture defines the texture to update
  18809. * @param data defines the data to store in the texture
  18810. * @param format defines the format of the data
  18811. * @param invertY defines if data must be stored with Y axis inverted
  18812. * @param compression defines the compression used (null by default)
  18813. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18814. */
  18815. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18816. /**
  18817. * Creates a new raw cube texture
  18818. * @param data defines the array of data to use to create each face
  18819. * @param size defines the size of the textures
  18820. * @param format defines the format of the data
  18821. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18822. * @param generateMipMaps defines if the engine should generate the mip levels
  18823. * @param invertY defines if data must be stored with Y axis inverted
  18824. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18825. * @param compression defines the compression used (null by default)
  18826. * @returns the cube texture as an InternalTexture
  18827. */
  18828. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18829. /**
  18830. * Update a raw cube texture
  18831. * @param texture defines the texture to udpdate
  18832. * @param data defines the data to store
  18833. * @param format defines the data format
  18834. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18835. * @param invertY defines if data must be stored with Y axis inverted
  18836. */
  18837. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18838. /**
  18839. * Update a raw cube texture
  18840. * @param texture defines the texture to udpdate
  18841. * @param data defines the data to store
  18842. * @param format defines the data format
  18843. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18844. * @param invertY defines if data must be stored with Y axis inverted
  18845. * @param compression defines the compression used (null by default)
  18846. */
  18847. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18848. /**
  18849. * Update a raw cube texture
  18850. * @param texture defines the texture to udpdate
  18851. * @param data defines the data to store
  18852. * @param format defines the data format
  18853. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18854. * @param invertY defines if data must be stored with Y axis inverted
  18855. * @param compression defines the compression used (null by default)
  18856. * @param level defines which level of the texture to update
  18857. */
  18858. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18859. /**
  18860. * Creates a new raw cube texture from a specified url
  18861. * @param url defines the url where the data is located
  18862. * @param scene defines the current scene
  18863. * @param size defines the size of the textures
  18864. * @param format defines the format of the data
  18865. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18866. * @param noMipmap defines if the engine should avoid generating the mip levels
  18867. * @param callback defines a callback used to extract texture data from loaded data
  18868. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18869. * @param onLoad defines a callback called when texture is loaded
  18870. * @param onError defines a callback called if there is an error
  18871. * @returns the cube texture as an InternalTexture
  18872. */
  18873. 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;
  18874. /**
  18875. * Creates a new raw cube texture from a specified url
  18876. * @param url defines the url where the data is located
  18877. * @param scene defines the current scene
  18878. * @param size defines the size of the textures
  18879. * @param format defines the format of the data
  18880. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18881. * @param noMipmap defines if the engine should avoid generating the mip levels
  18882. * @param callback defines a callback used to extract texture data from loaded data
  18883. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18884. * @param onLoad defines a callback called when texture is loaded
  18885. * @param onError defines a callback called if there is an error
  18886. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18887. * @param invertY defines if data must be stored with Y axis inverted
  18888. * @returns the cube texture as an InternalTexture
  18889. */
  18890. 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;
  18891. /**
  18892. * Creates a new raw 3D texture
  18893. * @param data defines the data used to create the texture
  18894. * @param width defines the width of the texture
  18895. * @param height defines the height of the texture
  18896. * @param depth defines the depth of the texture
  18897. * @param format defines the format of the texture
  18898. * @param generateMipMaps defines if the engine must generate mip levels
  18899. * @param invertY defines if data must be stored with Y axis inverted
  18900. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18901. * @param compression defines the compressed used (can be null)
  18902. * @param textureType defines the compressed used (can be null)
  18903. * @returns a new raw 3D texture (stored in an InternalTexture)
  18904. */
  18905. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18906. /**
  18907. * Update a raw 3D texture
  18908. * @param texture defines the texture to update
  18909. * @param data defines the data to store
  18910. * @param format defines the data format
  18911. * @param invertY defines if data must be stored with Y axis inverted
  18912. */
  18913. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18914. /**
  18915. * Update a raw 3D texture
  18916. * @param texture defines the texture to update
  18917. * @param data defines the data to store
  18918. * @param format defines the data format
  18919. * @param invertY defines if data must be stored with Y axis inverted
  18920. * @param compression defines the used compression (can be null)
  18921. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18922. */
  18923. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18924. }
  18925. }
  18926. }
  18927. declare module "babylonjs/Materials/Textures/rawTexture" {
  18928. import { Scene } from "babylonjs/scene";
  18929. import { Texture } from "babylonjs/Materials/Textures/texture";
  18930. import "babylonjs/Engines/Extensions/engine.rawTexture";
  18931. /**
  18932. * Raw texture can help creating a texture directly from an array of data.
  18933. * This can be super useful if you either get the data from an uncompressed source or
  18934. * if you wish to create your texture pixel by pixel.
  18935. */
  18936. export class RawTexture extends Texture {
  18937. /**
  18938. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18939. */
  18940. format: number;
  18941. private _engine;
  18942. /**
  18943. * Instantiates a new RawTexture.
  18944. * Raw texture can help creating a texture directly from an array of data.
  18945. * This can be super useful if you either get the data from an uncompressed source or
  18946. * if you wish to create your texture pixel by pixel.
  18947. * @param data define the array of data to use to create the texture
  18948. * @param width define the width of the texture
  18949. * @param height define the height of the texture
  18950. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18951. * @param scene define the scene the texture belongs to
  18952. * @param generateMipMaps define whether mip maps should be generated or not
  18953. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18954. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18955. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18956. */
  18957. constructor(data: ArrayBufferView, width: number, height: number,
  18958. /**
  18959. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18960. */
  18961. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18962. /**
  18963. * Updates the texture underlying data.
  18964. * @param data Define the new data of the texture
  18965. */
  18966. update(data: ArrayBufferView): void;
  18967. /**
  18968. * Creates a luminance texture from some data.
  18969. * @param data Define the texture data
  18970. * @param width Define the width of the texture
  18971. * @param height Define the height of the texture
  18972. * @param scene Define the scene the texture belongs to
  18973. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18974. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18975. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18976. * @returns the luminance texture
  18977. */
  18978. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18979. /**
  18980. * Creates a luminance alpha texture from some data.
  18981. * @param data Define the texture data
  18982. * @param width Define the width of the texture
  18983. * @param height Define the height of the texture
  18984. * @param scene Define the scene the texture belongs to
  18985. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18986. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18987. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18988. * @returns the luminance alpha texture
  18989. */
  18990. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18991. /**
  18992. * Creates an alpha texture from some data.
  18993. * @param data Define the texture data
  18994. * @param width Define the width of the texture
  18995. * @param height Define the height of the texture
  18996. * @param scene Define the scene the texture belongs to
  18997. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18998. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18999. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19000. * @returns the alpha texture
  19001. */
  19002. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19003. /**
  19004. * Creates a RGB texture from some data.
  19005. * @param data Define the texture data
  19006. * @param width Define the width of the texture
  19007. * @param height Define the height of the texture
  19008. * @param scene Define the scene the texture belongs to
  19009. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19010. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19011. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19012. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19013. * @returns the RGB alpha texture
  19014. */
  19015. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19016. /**
  19017. * Creates a RGBA texture from some data.
  19018. * @param data Define the texture data
  19019. * @param width Define the width of the texture
  19020. * @param height Define the height of the texture
  19021. * @param scene Define the scene the texture belongs to
  19022. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19023. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19024. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19025. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19026. * @returns the RGBA texture
  19027. */
  19028. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19029. /**
  19030. * Creates a R texture from some data.
  19031. * @param data Define the texture data
  19032. * @param width Define the width of the texture
  19033. * @param height Define the height of the texture
  19034. * @param scene Define the scene the texture belongs to
  19035. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19036. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19037. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19038. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19039. * @returns the R texture
  19040. */
  19041. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19042. }
  19043. }
  19044. declare module "babylonjs/Animations/runtimeAnimation" {
  19045. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19046. import { Animatable } from "babylonjs/Animations/animatable";
  19047. import { Scene } from "babylonjs/scene";
  19048. /**
  19049. * Defines a runtime animation
  19050. */
  19051. export class RuntimeAnimation {
  19052. private _events;
  19053. /**
  19054. * The current frame of the runtime animation
  19055. */
  19056. private _currentFrame;
  19057. /**
  19058. * The animation used by the runtime animation
  19059. */
  19060. private _animation;
  19061. /**
  19062. * The target of the runtime animation
  19063. */
  19064. private _target;
  19065. /**
  19066. * The initiating animatable
  19067. */
  19068. private _host;
  19069. /**
  19070. * The original value of the runtime animation
  19071. */
  19072. private _originalValue;
  19073. /**
  19074. * The original blend value of the runtime animation
  19075. */
  19076. private _originalBlendValue;
  19077. /**
  19078. * The offsets cache of the runtime animation
  19079. */
  19080. private _offsetsCache;
  19081. /**
  19082. * The high limits cache of the runtime animation
  19083. */
  19084. private _highLimitsCache;
  19085. /**
  19086. * Specifies if the runtime animation has been stopped
  19087. */
  19088. private _stopped;
  19089. /**
  19090. * The blending factor of the runtime animation
  19091. */
  19092. private _blendingFactor;
  19093. /**
  19094. * The BabylonJS scene
  19095. */
  19096. private _scene;
  19097. /**
  19098. * The current value of the runtime animation
  19099. */
  19100. private _currentValue;
  19101. /** @hidden */
  19102. _animationState: _IAnimationState;
  19103. /**
  19104. * The active target of the runtime animation
  19105. */
  19106. private _activeTargets;
  19107. private _currentActiveTarget;
  19108. private _directTarget;
  19109. /**
  19110. * The target path of the runtime animation
  19111. */
  19112. private _targetPath;
  19113. /**
  19114. * The weight of the runtime animation
  19115. */
  19116. private _weight;
  19117. /**
  19118. * The ratio offset of the runtime animation
  19119. */
  19120. private _ratioOffset;
  19121. /**
  19122. * The previous delay of the runtime animation
  19123. */
  19124. private _previousDelay;
  19125. /**
  19126. * The previous ratio of the runtime animation
  19127. */
  19128. private _previousRatio;
  19129. private _enableBlending;
  19130. private _keys;
  19131. private _minFrame;
  19132. private _maxFrame;
  19133. private _minValue;
  19134. private _maxValue;
  19135. private _targetIsArray;
  19136. /**
  19137. * Gets the current frame of the runtime animation
  19138. */
  19139. readonly currentFrame: number;
  19140. /**
  19141. * Gets the weight of the runtime animation
  19142. */
  19143. readonly weight: number;
  19144. /**
  19145. * Gets the current value of the runtime animation
  19146. */
  19147. readonly currentValue: any;
  19148. /**
  19149. * Gets the target path of the runtime animation
  19150. */
  19151. readonly targetPath: string;
  19152. /**
  19153. * Gets the actual target of the runtime animation
  19154. */
  19155. readonly target: any;
  19156. /** @hidden */
  19157. _onLoop: () => void;
  19158. /**
  19159. * Create a new RuntimeAnimation object
  19160. * @param target defines the target of the animation
  19161. * @param animation defines the source animation object
  19162. * @param scene defines the hosting scene
  19163. * @param host defines the initiating Animatable
  19164. */
  19165. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19166. private _preparePath;
  19167. /**
  19168. * Gets the animation from the runtime animation
  19169. */
  19170. readonly animation: Animation;
  19171. /**
  19172. * Resets the runtime animation to the beginning
  19173. * @param restoreOriginal defines whether to restore the target property to the original value
  19174. */
  19175. reset(restoreOriginal?: boolean): void;
  19176. /**
  19177. * Specifies if the runtime animation is stopped
  19178. * @returns Boolean specifying if the runtime animation is stopped
  19179. */
  19180. isStopped(): boolean;
  19181. /**
  19182. * Disposes of the runtime animation
  19183. */
  19184. dispose(): void;
  19185. /**
  19186. * Apply the interpolated value to the target
  19187. * @param currentValue defines the value computed by the animation
  19188. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19189. */
  19190. setValue(currentValue: any, weight: number): void;
  19191. private _getOriginalValues;
  19192. private _setValue;
  19193. /**
  19194. * Gets the loop pmode of the runtime animation
  19195. * @returns Loop Mode
  19196. */
  19197. private _getCorrectLoopMode;
  19198. /**
  19199. * Move the current animation to a given frame
  19200. * @param frame defines the frame to move to
  19201. */
  19202. goToFrame(frame: number): void;
  19203. /**
  19204. * @hidden Internal use only
  19205. */
  19206. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19207. /**
  19208. * Execute the current animation
  19209. * @param delay defines the delay to add to the current frame
  19210. * @param from defines the lower bound of the animation range
  19211. * @param to defines the upper bound of the animation range
  19212. * @param loop defines if the current animation must loop
  19213. * @param speedRatio defines the current speed ratio
  19214. * @param weight defines the weight of the animation (default is -1 so no weight)
  19215. * @param onLoop optional callback called when animation loops
  19216. * @returns a boolean indicating if the animation is running
  19217. */
  19218. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19219. }
  19220. }
  19221. declare module "babylonjs/Animations/animatable" {
  19222. import { Animation } from "babylonjs/Animations/animation";
  19223. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19224. import { Nullable } from "babylonjs/types";
  19225. import { Observable } from "babylonjs/Misc/observable";
  19226. import { Scene } from "babylonjs/scene";
  19227. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19228. import { Node } from "babylonjs/node";
  19229. /**
  19230. * Class used to store an actual running animation
  19231. */
  19232. export class Animatable {
  19233. /** defines the target object */
  19234. target: any;
  19235. /** defines the starting frame number (default is 0) */
  19236. fromFrame: number;
  19237. /** defines the ending frame number (default is 100) */
  19238. toFrame: number;
  19239. /** defines if the animation must loop (default is false) */
  19240. loopAnimation: boolean;
  19241. /** defines a callback to call when animation ends if it is not looping */
  19242. onAnimationEnd?: (() => void) | null | undefined;
  19243. /** defines a callback to call when animation loops */
  19244. onAnimationLoop?: (() => void) | null | undefined;
  19245. private _localDelayOffset;
  19246. private _pausedDelay;
  19247. private _runtimeAnimations;
  19248. private _paused;
  19249. private _scene;
  19250. private _speedRatio;
  19251. private _weight;
  19252. private _syncRoot;
  19253. /**
  19254. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19255. * This will only apply for non looping animation (default is true)
  19256. */
  19257. disposeOnEnd: boolean;
  19258. /**
  19259. * Gets a boolean indicating if the animation has started
  19260. */
  19261. animationStarted: boolean;
  19262. /**
  19263. * Observer raised when the animation ends
  19264. */
  19265. onAnimationEndObservable: Observable<Animatable>;
  19266. /**
  19267. * Observer raised when the animation loops
  19268. */
  19269. onAnimationLoopObservable: Observable<Animatable>;
  19270. /**
  19271. * Gets the root Animatable used to synchronize and normalize animations
  19272. */
  19273. readonly syncRoot: Nullable<Animatable>;
  19274. /**
  19275. * Gets the current frame of the first RuntimeAnimation
  19276. * Used to synchronize Animatables
  19277. */
  19278. readonly masterFrame: number;
  19279. /**
  19280. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19281. */
  19282. weight: number;
  19283. /**
  19284. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19285. */
  19286. speedRatio: number;
  19287. /**
  19288. * Creates a new Animatable
  19289. * @param scene defines the hosting scene
  19290. * @param target defines the target object
  19291. * @param fromFrame defines the starting frame number (default is 0)
  19292. * @param toFrame defines the ending frame number (default is 100)
  19293. * @param loopAnimation defines if the animation must loop (default is false)
  19294. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19295. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19296. * @param animations defines a group of animation to add to the new Animatable
  19297. * @param onAnimationLoop defines a callback to call when animation loops
  19298. */
  19299. constructor(scene: Scene,
  19300. /** defines the target object */
  19301. target: any,
  19302. /** defines the starting frame number (default is 0) */
  19303. fromFrame?: number,
  19304. /** defines the ending frame number (default is 100) */
  19305. toFrame?: number,
  19306. /** defines if the animation must loop (default is false) */
  19307. loopAnimation?: boolean, speedRatio?: number,
  19308. /** defines a callback to call when animation ends if it is not looping */
  19309. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19310. /** defines a callback to call when animation loops */
  19311. onAnimationLoop?: (() => void) | null | undefined);
  19312. /**
  19313. * Synchronize and normalize current Animatable with a source Animatable
  19314. * This is useful when using animation weights and when animations are not of the same length
  19315. * @param root defines the root Animatable to synchronize with
  19316. * @returns the current Animatable
  19317. */
  19318. syncWith(root: Animatable): Animatable;
  19319. /**
  19320. * Gets the list of runtime animations
  19321. * @returns an array of RuntimeAnimation
  19322. */
  19323. getAnimations(): RuntimeAnimation[];
  19324. /**
  19325. * Adds more animations to the current animatable
  19326. * @param target defines the target of the animations
  19327. * @param animations defines the new animations to add
  19328. */
  19329. appendAnimations(target: any, animations: Animation[]): void;
  19330. /**
  19331. * Gets the source animation for a specific property
  19332. * @param property defines the propertyu to look for
  19333. * @returns null or the source animation for the given property
  19334. */
  19335. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19336. /**
  19337. * Gets the runtime animation for a specific property
  19338. * @param property defines the propertyu to look for
  19339. * @returns null or the runtime animation for the given property
  19340. */
  19341. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19342. /**
  19343. * Resets the animatable to its original state
  19344. */
  19345. reset(): void;
  19346. /**
  19347. * Allows the animatable to blend with current running animations
  19348. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19349. * @param blendingSpeed defines the blending speed to use
  19350. */
  19351. enableBlending(blendingSpeed: number): void;
  19352. /**
  19353. * Disable animation blending
  19354. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19355. */
  19356. disableBlending(): void;
  19357. /**
  19358. * Jump directly to a given frame
  19359. * @param frame defines the frame to jump to
  19360. */
  19361. goToFrame(frame: number): void;
  19362. /**
  19363. * Pause the animation
  19364. */
  19365. pause(): void;
  19366. /**
  19367. * Restart the animation
  19368. */
  19369. restart(): void;
  19370. private _raiseOnAnimationEnd;
  19371. /**
  19372. * Stop and delete the current animation
  19373. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19374. * @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)
  19375. */
  19376. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19377. /**
  19378. * Wait asynchronously for the animation to end
  19379. * @returns a promise which will be fullfilled when the animation ends
  19380. */
  19381. waitAsync(): Promise<Animatable>;
  19382. /** @hidden */
  19383. _animate(delay: number): boolean;
  19384. }
  19385. module "babylonjs/scene" {
  19386. interface Scene {
  19387. /** @hidden */
  19388. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19389. /** @hidden */
  19390. _processLateAnimationBindingsForMatrices(holder: {
  19391. totalWeight: number;
  19392. animations: RuntimeAnimation[];
  19393. originalValue: Matrix;
  19394. }): any;
  19395. /** @hidden */
  19396. _processLateAnimationBindingsForQuaternions(holder: {
  19397. totalWeight: number;
  19398. animations: RuntimeAnimation[];
  19399. originalValue: Quaternion;
  19400. }, refQuaternion: Quaternion): Quaternion;
  19401. /** @hidden */
  19402. _processLateAnimationBindings(): void;
  19403. /**
  19404. * Will start the animation sequence of a given target
  19405. * @param target defines the target
  19406. * @param from defines from which frame should animation start
  19407. * @param to defines until which frame should animation run.
  19408. * @param weight defines the weight to apply to the animation (1.0 by default)
  19409. * @param loop defines if the animation loops
  19410. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19411. * @param onAnimationEnd defines the function to be executed when the animation ends
  19412. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19413. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19414. * @param onAnimationLoop defines the callback to call when an animation loops
  19415. * @returns the animatable object created for this animation
  19416. */
  19417. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19418. /**
  19419. * Will start the animation sequence of a given target
  19420. * @param target defines the target
  19421. * @param from defines from which frame should animation start
  19422. * @param to defines until which frame should animation run.
  19423. * @param loop defines if the animation loops
  19424. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19425. * @param onAnimationEnd defines the function to be executed when the animation ends
  19426. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19427. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19428. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19429. * @param onAnimationLoop defines the callback to call when an animation loops
  19430. * @returns the animatable object created for this animation
  19431. */
  19432. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19433. /**
  19434. * Will start the animation sequence of a given target and its hierarchy
  19435. * @param target defines the target
  19436. * @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.
  19437. * @param from defines from which frame should animation start
  19438. * @param to defines until which frame should animation run.
  19439. * @param loop defines if the animation loops
  19440. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19441. * @param onAnimationEnd defines the function to be executed when the animation ends
  19442. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19443. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19444. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19445. * @param onAnimationLoop defines the callback to call when an animation loops
  19446. * @returns the list of created animatables
  19447. */
  19448. 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[];
  19449. /**
  19450. * Begin a new animation on a given node
  19451. * @param target defines the target where the animation will take place
  19452. * @param animations defines the list of animations to start
  19453. * @param from defines the initial value
  19454. * @param to defines the final value
  19455. * @param loop defines if you want animation to loop (off by default)
  19456. * @param speedRatio defines the speed ratio to apply to all animations
  19457. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19458. * @param onAnimationLoop defines the callback to call when an animation loops
  19459. * @returns the list of created animatables
  19460. */
  19461. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19462. /**
  19463. * Begin a new animation on a given node and its hierarchy
  19464. * @param target defines the root node where the animation will take place
  19465. * @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.
  19466. * @param animations defines the list of animations to start
  19467. * @param from defines the initial value
  19468. * @param to defines the final value
  19469. * @param loop defines if you want animation to loop (off by default)
  19470. * @param speedRatio defines the speed ratio to apply to all animations
  19471. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19472. * @param onAnimationLoop defines the callback to call when an animation loops
  19473. * @returns the list of animatables created for all nodes
  19474. */
  19475. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19476. /**
  19477. * Gets the animatable associated with a specific target
  19478. * @param target defines the target of the animatable
  19479. * @returns the required animatable if found
  19480. */
  19481. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19482. /**
  19483. * Gets all animatables associated with a given target
  19484. * @param target defines the target to look animatables for
  19485. * @returns an array of Animatables
  19486. */
  19487. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19488. /**
  19489. * Will stop the animation of the given target
  19490. * @param target - the target
  19491. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19492. * @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)
  19493. */
  19494. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19495. /**
  19496. * Stops and removes all animations that have been applied to the scene
  19497. */
  19498. stopAllAnimations(): void;
  19499. }
  19500. }
  19501. module "babylonjs/Bones/bone" {
  19502. interface Bone {
  19503. /**
  19504. * Copy an animation range from another bone
  19505. * @param source defines the source bone
  19506. * @param rangeName defines the range name to copy
  19507. * @param frameOffset defines the frame offset
  19508. * @param rescaleAsRequired defines if rescaling must be applied if required
  19509. * @param skelDimensionsRatio defines the scaling ratio
  19510. * @returns true if operation was successful
  19511. */
  19512. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19513. }
  19514. }
  19515. }
  19516. declare module "babylonjs/Bones/skeleton" {
  19517. import { Bone } from "babylonjs/Bones/bone";
  19518. import { IAnimatable } from "babylonjs/Misc/tools";
  19519. import { Observable } from "babylonjs/Misc/observable";
  19520. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19521. import { Scene } from "babylonjs/scene";
  19522. import { Nullable } from "babylonjs/types";
  19523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19524. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19525. import { Animatable } from "babylonjs/Animations/animatable";
  19526. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19527. import { Animation } from "babylonjs/Animations/animation";
  19528. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19529. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19530. /**
  19531. * Class used to handle skinning animations
  19532. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19533. */
  19534. export class Skeleton implements IAnimatable {
  19535. /** defines the skeleton name */
  19536. name: string;
  19537. /** defines the skeleton Id */
  19538. id: string;
  19539. /**
  19540. * Defines the list of child bones
  19541. */
  19542. bones: Bone[];
  19543. /**
  19544. * Defines an estimate of the dimension of the skeleton at rest
  19545. */
  19546. dimensionsAtRest: Vector3;
  19547. /**
  19548. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19549. */
  19550. needInitialSkinMatrix: boolean;
  19551. /**
  19552. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19553. */
  19554. overrideMesh: Nullable<AbstractMesh>;
  19555. /**
  19556. * Gets the list of animations attached to this skeleton
  19557. */
  19558. animations: Array<Animation>;
  19559. private _scene;
  19560. private _isDirty;
  19561. private _transformMatrices;
  19562. private _transformMatrixTexture;
  19563. private _meshesWithPoseMatrix;
  19564. private _animatables;
  19565. private _identity;
  19566. private _synchronizedWithMesh;
  19567. private _ranges;
  19568. private _lastAbsoluteTransformsUpdateId;
  19569. private _canUseTextureForBones;
  19570. private _uniqueId;
  19571. /** @hidden */
  19572. _numBonesWithLinkedTransformNode: number;
  19573. /**
  19574. * Specifies if the skeleton should be serialized
  19575. */
  19576. doNotSerialize: boolean;
  19577. private _useTextureToStoreBoneMatrices;
  19578. /**
  19579. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19580. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19581. */
  19582. useTextureToStoreBoneMatrices: boolean;
  19583. private _animationPropertiesOverride;
  19584. /**
  19585. * Gets or sets the animation properties override
  19586. */
  19587. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19588. /**
  19589. * List of inspectable custom properties (used by the Inspector)
  19590. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19591. */
  19592. inspectableCustomProperties: IInspectable[];
  19593. /**
  19594. * An observable triggered before computing the skeleton's matrices
  19595. */
  19596. onBeforeComputeObservable: Observable<Skeleton>;
  19597. /**
  19598. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19599. */
  19600. readonly isUsingTextureForMatrices: boolean;
  19601. /**
  19602. * Gets the unique ID of this skeleton
  19603. */
  19604. readonly uniqueId: number;
  19605. /**
  19606. * Creates a new skeleton
  19607. * @param name defines the skeleton name
  19608. * @param id defines the skeleton Id
  19609. * @param scene defines the hosting scene
  19610. */
  19611. constructor(
  19612. /** defines the skeleton name */
  19613. name: string,
  19614. /** defines the skeleton Id */
  19615. id: string, scene: Scene);
  19616. /**
  19617. * Gets the current object class name.
  19618. * @return the class name
  19619. */
  19620. getClassName(): string;
  19621. /**
  19622. * Returns an array containing the root bones
  19623. * @returns an array containing the root bones
  19624. */
  19625. getChildren(): Array<Bone>;
  19626. /**
  19627. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19628. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19629. * @returns a Float32Array containing matrices data
  19630. */
  19631. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19632. /**
  19633. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19634. * @returns a raw texture containing the data
  19635. */
  19636. getTransformMatrixTexture(): Nullable<RawTexture>;
  19637. /**
  19638. * Gets the current hosting scene
  19639. * @returns a scene object
  19640. */
  19641. getScene(): Scene;
  19642. /**
  19643. * Gets a string representing the current skeleton data
  19644. * @param fullDetails defines a boolean indicating if we want a verbose version
  19645. * @returns a string representing the current skeleton data
  19646. */
  19647. toString(fullDetails?: boolean): string;
  19648. /**
  19649. * Get bone's index searching by name
  19650. * @param name defines bone's name to search for
  19651. * @return the indice of the bone. Returns -1 if not found
  19652. */
  19653. getBoneIndexByName(name: string): number;
  19654. /**
  19655. * Creater a new animation range
  19656. * @param name defines the name of the range
  19657. * @param from defines the start key
  19658. * @param to defines the end key
  19659. */
  19660. createAnimationRange(name: string, from: number, to: number): void;
  19661. /**
  19662. * Delete a specific animation range
  19663. * @param name defines the name of the range
  19664. * @param deleteFrames defines if frames must be removed as well
  19665. */
  19666. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19667. /**
  19668. * Gets a specific animation range
  19669. * @param name defines the name of the range to look for
  19670. * @returns the requested animation range or null if not found
  19671. */
  19672. getAnimationRange(name: string): Nullable<AnimationRange>;
  19673. /**
  19674. * Gets the list of all animation ranges defined on this skeleton
  19675. * @returns an array
  19676. */
  19677. getAnimationRanges(): Nullable<AnimationRange>[];
  19678. /**
  19679. * Copy animation range from a source skeleton.
  19680. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19681. * @param source defines the source skeleton
  19682. * @param name defines the name of the range to copy
  19683. * @param rescaleAsRequired defines if rescaling must be applied if required
  19684. * @returns true if operation was successful
  19685. */
  19686. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19687. /**
  19688. * Forces the skeleton to go to rest pose
  19689. */
  19690. returnToRest(): void;
  19691. private _getHighestAnimationFrame;
  19692. /**
  19693. * Begin a specific animation range
  19694. * @param name defines the name of the range to start
  19695. * @param loop defines if looping must be turned on (false by default)
  19696. * @param speedRatio defines the speed ratio to apply (1 by default)
  19697. * @param onAnimationEnd defines a callback which will be called when animation will end
  19698. * @returns a new animatable
  19699. */
  19700. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19701. /** @hidden */
  19702. _markAsDirty(): void;
  19703. /** @hidden */
  19704. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19705. /** @hidden */
  19706. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19707. private _computeTransformMatrices;
  19708. /**
  19709. * Build all resources required to render a skeleton
  19710. */
  19711. prepare(): void;
  19712. /**
  19713. * Gets the list of animatables currently running for this skeleton
  19714. * @returns an array of animatables
  19715. */
  19716. getAnimatables(): IAnimatable[];
  19717. /**
  19718. * Clone the current skeleton
  19719. * @param name defines the name of the new skeleton
  19720. * @param id defines the id of the new skeleton
  19721. * @returns the new skeleton
  19722. */
  19723. clone(name: string, id: string): Skeleton;
  19724. /**
  19725. * Enable animation blending for this skeleton
  19726. * @param blendingSpeed defines the blending speed to apply
  19727. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19728. */
  19729. enableBlending(blendingSpeed?: number): void;
  19730. /**
  19731. * Releases all resources associated with the current skeleton
  19732. */
  19733. dispose(): void;
  19734. /**
  19735. * Serialize the skeleton in a JSON object
  19736. * @returns a JSON object
  19737. */
  19738. serialize(): any;
  19739. /**
  19740. * Creates a new skeleton from serialized data
  19741. * @param parsedSkeleton defines the serialized data
  19742. * @param scene defines the hosting scene
  19743. * @returns a new skeleton
  19744. */
  19745. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19746. /**
  19747. * Compute all node absolute transforms
  19748. * @param forceUpdate defines if computation must be done even if cache is up to date
  19749. */
  19750. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19751. /**
  19752. * Gets the root pose matrix
  19753. * @returns a matrix
  19754. */
  19755. getPoseMatrix(): Nullable<Matrix>;
  19756. /**
  19757. * Sorts bones per internal index
  19758. */
  19759. sortBones(): void;
  19760. private _sortBones;
  19761. }
  19762. }
  19763. declare module "babylonjs/Morph/morphTarget" {
  19764. import { IAnimatable } from "babylonjs/Misc/tools";
  19765. import { Observable } from "babylonjs/Misc/observable";
  19766. import { Nullable, FloatArray } from "babylonjs/types";
  19767. import { Scene } from "babylonjs/scene";
  19768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19769. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19770. /**
  19771. * Defines a target to use with MorphTargetManager
  19772. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19773. */
  19774. export class MorphTarget implements IAnimatable {
  19775. /** defines the name of the target */
  19776. name: string;
  19777. /**
  19778. * Gets or sets the list of animations
  19779. */
  19780. animations: import("babylonjs/Animations/animation").Animation[];
  19781. private _scene;
  19782. private _positions;
  19783. private _normals;
  19784. private _tangents;
  19785. private _influence;
  19786. /**
  19787. * Observable raised when the influence changes
  19788. */
  19789. onInfluenceChanged: Observable<boolean>;
  19790. /** @hidden */
  19791. _onDataLayoutChanged: Observable<void>;
  19792. /**
  19793. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19794. */
  19795. influence: number;
  19796. /**
  19797. * Gets or sets the id of the morph Target
  19798. */
  19799. id: string;
  19800. private _animationPropertiesOverride;
  19801. /**
  19802. * Gets or sets the animation properties override
  19803. */
  19804. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19805. /**
  19806. * Creates a new MorphTarget
  19807. * @param name defines the name of the target
  19808. * @param influence defines the influence to use
  19809. * @param scene defines the scene the morphtarget belongs to
  19810. */
  19811. constructor(
  19812. /** defines the name of the target */
  19813. name: string, influence?: number, scene?: Nullable<Scene>);
  19814. /**
  19815. * Gets a boolean defining if the target contains position data
  19816. */
  19817. readonly hasPositions: boolean;
  19818. /**
  19819. * Gets a boolean defining if the target contains normal data
  19820. */
  19821. readonly hasNormals: boolean;
  19822. /**
  19823. * Gets a boolean defining if the target contains tangent data
  19824. */
  19825. readonly hasTangents: boolean;
  19826. /**
  19827. * Affects position data to this target
  19828. * @param data defines the position data to use
  19829. */
  19830. setPositions(data: Nullable<FloatArray>): void;
  19831. /**
  19832. * Gets the position data stored in this target
  19833. * @returns a FloatArray containing the position data (or null if not present)
  19834. */
  19835. getPositions(): Nullable<FloatArray>;
  19836. /**
  19837. * Affects normal data to this target
  19838. * @param data defines the normal data to use
  19839. */
  19840. setNormals(data: Nullable<FloatArray>): void;
  19841. /**
  19842. * Gets the normal data stored in this target
  19843. * @returns a FloatArray containing the normal data (or null if not present)
  19844. */
  19845. getNormals(): Nullable<FloatArray>;
  19846. /**
  19847. * Affects tangent data to this target
  19848. * @param data defines the tangent data to use
  19849. */
  19850. setTangents(data: Nullable<FloatArray>): void;
  19851. /**
  19852. * Gets the tangent data stored in this target
  19853. * @returns a FloatArray containing the tangent data (or null if not present)
  19854. */
  19855. getTangents(): Nullable<FloatArray>;
  19856. /**
  19857. * Serializes the current target into a Serialization object
  19858. * @returns the serialized object
  19859. */
  19860. serialize(): any;
  19861. /**
  19862. * Returns the string "MorphTarget"
  19863. * @returns "MorphTarget"
  19864. */
  19865. getClassName(): string;
  19866. /**
  19867. * Creates a new target from serialized data
  19868. * @param serializationObject defines the serialized data to use
  19869. * @returns a new MorphTarget
  19870. */
  19871. static Parse(serializationObject: any): MorphTarget;
  19872. /**
  19873. * Creates a MorphTarget from mesh data
  19874. * @param mesh defines the source mesh
  19875. * @param name defines the name to use for the new target
  19876. * @param influence defines the influence to attach to the target
  19877. * @returns a new MorphTarget
  19878. */
  19879. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19880. }
  19881. }
  19882. declare module "babylonjs/Morph/morphTargetManager" {
  19883. import { Nullable } from "babylonjs/types";
  19884. import { Scene } from "babylonjs/scene";
  19885. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19886. /**
  19887. * This class is used to deform meshes using morphing between different targets
  19888. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19889. */
  19890. export class MorphTargetManager {
  19891. private _targets;
  19892. private _targetInfluenceChangedObservers;
  19893. private _targetDataLayoutChangedObservers;
  19894. private _activeTargets;
  19895. private _scene;
  19896. private _influences;
  19897. private _supportsNormals;
  19898. private _supportsTangents;
  19899. private _vertexCount;
  19900. private _uniqueId;
  19901. private _tempInfluences;
  19902. /**
  19903. * Creates a new MorphTargetManager
  19904. * @param scene defines the current scene
  19905. */
  19906. constructor(scene?: Nullable<Scene>);
  19907. /**
  19908. * Gets the unique ID of this manager
  19909. */
  19910. readonly uniqueId: number;
  19911. /**
  19912. * Gets the number of vertices handled by this manager
  19913. */
  19914. readonly vertexCount: number;
  19915. /**
  19916. * Gets a boolean indicating if this manager supports morphing of normals
  19917. */
  19918. readonly supportsNormals: boolean;
  19919. /**
  19920. * Gets a boolean indicating if this manager supports morphing of tangents
  19921. */
  19922. readonly supportsTangents: boolean;
  19923. /**
  19924. * Gets the number of targets stored in this manager
  19925. */
  19926. readonly numTargets: number;
  19927. /**
  19928. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19929. */
  19930. readonly numInfluencers: number;
  19931. /**
  19932. * Gets the list of influences (one per target)
  19933. */
  19934. readonly influences: Float32Array;
  19935. /**
  19936. * Gets the active target at specified index. An active target is a target with an influence > 0
  19937. * @param index defines the index to check
  19938. * @returns the requested target
  19939. */
  19940. getActiveTarget(index: number): MorphTarget;
  19941. /**
  19942. * Gets the target at specified index
  19943. * @param index defines the index to check
  19944. * @returns the requested target
  19945. */
  19946. getTarget(index: number): MorphTarget;
  19947. /**
  19948. * Add a new target to this manager
  19949. * @param target defines the target to add
  19950. */
  19951. addTarget(target: MorphTarget): void;
  19952. /**
  19953. * Removes a target from the manager
  19954. * @param target defines the target to remove
  19955. */
  19956. removeTarget(target: MorphTarget): void;
  19957. /**
  19958. * Serializes the current manager into a Serialization object
  19959. * @returns the serialized object
  19960. */
  19961. serialize(): any;
  19962. private _syncActiveTargets;
  19963. /**
  19964. * Syncrhonize the targets with all the meshes using this morph target manager
  19965. */
  19966. synchronize(): void;
  19967. /**
  19968. * Creates a new MorphTargetManager from serialized data
  19969. * @param serializationObject defines the serialized data
  19970. * @param scene defines the hosting scene
  19971. * @returns the new MorphTargetManager
  19972. */
  19973. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19974. }
  19975. }
  19976. declare module "babylonjs/Meshes/groundMesh" {
  19977. import { Scene } from "babylonjs/scene";
  19978. import { Vector3 } from "babylonjs/Maths/math";
  19979. import { Mesh } from "babylonjs/Meshes/mesh";
  19980. /**
  19981. * Mesh representing the gorund
  19982. */
  19983. export class GroundMesh extends Mesh {
  19984. /** If octree should be generated */
  19985. generateOctree: boolean;
  19986. private _heightQuads;
  19987. /** @hidden */
  19988. _subdivisionsX: number;
  19989. /** @hidden */
  19990. _subdivisionsY: number;
  19991. /** @hidden */
  19992. _width: number;
  19993. /** @hidden */
  19994. _height: number;
  19995. /** @hidden */
  19996. _minX: number;
  19997. /** @hidden */
  19998. _maxX: number;
  19999. /** @hidden */
  20000. _minZ: number;
  20001. /** @hidden */
  20002. _maxZ: number;
  20003. constructor(name: string, scene: Scene);
  20004. /**
  20005. * "GroundMesh"
  20006. * @returns "GroundMesh"
  20007. */
  20008. getClassName(): string;
  20009. /**
  20010. * The minimum of x and y subdivisions
  20011. */
  20012. readonly subdivisions: number;
  20013. /**
  20014. * X subdivisions
  20015. */
  20016. readonly subdivisionsX: number;
  20017. /**
  20018. * Y subdivisions
  20019. */
  20020. readonly subdivisionsY: number;
  20021. /**
  20022. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20023. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20024. * @param chunksCount the number of subdivisions for x and y
  20025. * @param octreeBlocksSize (Default: 32)
  20026. */
  20027. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20028. /**
  20029. * Returns a height (y) value in the Worl system :
  20030. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20031. * @param x x coordinate
  20032. * @param z z coordinate
  20033. * @returns the ground y position if (x, z) are outside the ground surface.
  20034. */
  20035. getHeightAtCoordinates(x: number, z: number): number;
  20036. /**
  20037. * Returns a normalized vector (Vector3) orthogonal to the ground
  20038. * at the ground coordinates (x, z) expressed in the World system.
  20039. * @param x x coordinate
  20040. * @param z z coordinate
  20041. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20042. */
  20043. getNormalAtCoordinates(x: number, z: number): Vector3;
  20044. /**
  20045. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20046. * at the ground coordinates (x, z) expressed in the World system.
  20047. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20048. * @param x x coordinate
  20049. * @param z z coordinate
  20050. * @param ref vector to store the result
  20051. * @returns the GroundMesh.
  20052. */
  20053. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20054. /**
  20055. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20056. * if the ground has been updated.
  20057. * This can be used in the render loop.
  20058. * @returns the GroundMesh.
  20059. */
  20060. updateCoordinateHeights(): GroundMesh;
  20061. private _getFacetAt;
  20062. private _initHeightQuads;
  20063. private _computeHeightQuads;
  20064. /**
  20065. * Serializes this ground mesh
  20066. * @param serializationObject object to write serialization to
  20067. */
  20068. serialize(serializationObject: any): void;
  20069. /**
  20070. * Parses a serialized ground mesh
  20071. * @param parsedMesh the serialized mesh
  20072. * @param scene the scene to create the ground mesh in
  20073. * @returns the created ground mesh
  20074. */
  20075. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20076. }
  20077. }
  20078. declare module "babylonjs/Physics/physicsJoint" {
  20079. import { Vector3 } from "babylonjs/Maths/math";
  20080. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20081. /**
  20082. * Interface for Physics-Joint data
  20083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20084. */
  20085. export interface PhysicsJointData {
  20086. /**
  20087. * The main pivot of the joint
  20088. */
  20089. mainPivot?: Vector3;
  20090. /**
  20091. * The connected pivot of the joint
  20092. */
  20093. connectedPivot?: Vector3;
  20094. /**
  20095. * The main axis of the joint
  20096. */
  20097. mainAxis?: Vector3;
  20098. /**
  20099. * The connected axis of the joint
  20100. */
  20101. connectedAxis?: Vector3;
  20102. /**
  20103. * The collision of the joint
  20104. */
  20105. collision?: boolean;
  20106. /**
  20107. * Native Oimo/Cannon/Energy data
  20108. */
  20109. nativeParams?: any;
  20110. }
  20111. /**
  20112. * This is a holder class for the physics joint created by the physics plugin
  20113. * It holds a set of functions to control the underlying joint
  20114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20115. */
  20116. export class PhysicsJoint {
  20117. /**
  20118. * The type of the physics joint
  20119. */
  20120. type: number;
  20121. /**
  20122. * The data for the physics joint
  20123. */
  20124. jointData: PhysicsJointData;
  20125. private _physicsJoint;
  20126. protected _physicsPlugin: IPhysicsEnginePlugin;
  20127. /**
  20128. * Initializes the physics joint
  20129. * @param type The type of the physics joint
  20130. * @param jointData The data for the physics joint
  20131. */
  20132. constructor(
  20133. /**
  20134. * The type of the physics joint
  20135. */
  20136. type: number,
  20137. /**
  20138. * The data for the physics joint
  20139. */
  20140. jointData: PhysicsJointData);
  20141. /**
  20142. * Gets the physics joint
  20143. */
  20144. /**
  20145. * Sets the physics joint
  20146. */
  20147. physicsJoint: any;
  20148. /**
  20149. * Sets the physics plugin
  20150. */
  20151. physicsPlugin: IPhysicsEnginePlugin;
  20152. /**
  20153. * Execute a function that is physics-plugin specific.
  20154. * @param {Function} func the function that will be executed.
  20155. * It accepts two parameters: the physics world and the physics joint
  20156. */
  20157. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20158. /**
  20159. * Distance-Joint type
  20160. */
  20161. static DistanceJoint: number;
  20162. /**
  20163. * Hinge-Joint type
  20164. */
  20165. static HingeJoint: number;
  20166. /**
  20167. * Ball-and-Socket joint type
  20168. */
  20169. static BallAndSocketJoint: number;
  20170. /**
  20171. * Wheel-Joint type
  20172. */
  20173. static WheelJoint: number;
  20174. /**
  20175. * Slider-Joint type
  20176. */
  20177. static SliderJoint: number;
  20178. /**
  20179. * Prismatic-Joint type
  20180. */
  20181. static PrismaticJoint: number;
  20182. /**
  20183. * Universal-Joint type
  20184. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20185. */
  20186. static UniversalJoint: number;
  20187. /**
  20188. * Hinge-Joint 2 type
  20189. */
  20190. static Hinge2Joint: number;
  20191. /**
  20192. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20193. */
  20194. static PointToPointJoint: number;
  20195. /**
  20196. * Spring-Joint type
  20197. */
  20198. static SpringJoint: number;
  20199. /**
  20200. * Lock-Joint type
  20201. */
  20202. static LockJoint: number;
  20203. }
  20204. /**
  20205. * A class representing a physics distance joint
  20206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20207. */
  20208. export class DistanceJoint extends PhysicsJoint {
  20209. /**
  20210. *
  20211. * @param jointData The data for the Distance-Joint
  20212. */
  20213. constructor(jointData: DistanceJointData);
  20214. /**
  20215. * Update the predefined distance.
  20216. * @param maxDistance The maximum preferred distance
  20217. * @param minDistance The minimum preferred distance
  20218. */
  20219. updateDistance(maxDistance: number, minDistance?: number): void;
  20220. }
  20221. /**
  20222. * Represents a Motor-Enabled Joint
  20223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20224. */
  20225. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20226. /**
  20227. * Initializes the Motor-Enabled Joint
  20228. * @param type The type of the joint
  20229. * @param jointData The physica joint data for the joint
  20230. */
  20231. constructor(type: number, jointData: PhysicsJointData);
  20232. /**
  20233. * Set the motor values.
  20234. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20235. * @param force the force to apply
  20236. * @param maxForce max force for this motor.
  20237. */
  20238. setMotor(force?: number, maxForce?: number): void;
  20239. /**
  20240. * Set the motor's limits.
  20241. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20242. * @param upperLimit The upper limit of the motor
  20243. * @param lowerLimit The lower limit of the motor
  20244. */
  20245. setLimit(upperLimit: number, lowerLimit?: number): void;
  20246. }
  20247. /**
  20248. * This class represents a single physics Hinge-Joint
  20249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20250. */
  20251. export class HingeJoint extends MotorEnabledJoint {
  20252. /**
  20253. * Initializes the Hinge-Joint
  20254. * @param jointData The joint data for the Hinge-Joint
  20255. */
  20256. constructor(jointData: PhysicsJointData);
  20257. /**
  20258. * Set the motor values.
  20259. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20260. * @param {number} force the force to apply
  20261. * @param {number} maxForce max force for this motor.
  20262. */
  20263. setMotor(force?: number, maxForce?: number): void;
  20264. /**
  20265. * Set the motor's limits.
  20266. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20267. * @param upperLimit The upper limit of the motor
  20268. * @param lowerLimit The lower limit of the motor
  20269. */
  20270. setLimit(upperLimit: number, lowerLimit?: number): void;
  20271. }
  20272. /**
  20273. * This class represents a dual hinge physics joint (same as wheel joint)
  20274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20275. */
  20276. export class Hinge2Joint extends MotorEnabledJoint {
  20277. /**
  20278. * Initializes the Hinge2-Joint
  20279. * @param jointData The joint data for the Hinge2-Joint
  20280. */
  20281. constructor(jointData: PhysicsJointData);
  20282. /**
  20283. * Set the motor values.
  20284. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20285. * @param {number} targetSpeed the speed the motor is to reach
  20286. * @param {number} maxForce max force for this motor.
  20287. * @param {motorIndex} the motor's index, 0 or 1.
  20288. */
  20289. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20290. /**
  20291. * Set the motor limits.
  20292. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20293. * @param {number} upperLimit the upper limit
  20294. * @param {number} lowerLimit lower limit
  20295. * @param {motorIndex} the motor's index, 0 or 1.
  20296. */
  20297. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20298. }
  20299. /**
  20300. * Interface for a motor enabled joint
  20301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20302. */
  20303. export interface IMotorEnabledJoint {
  20304. /**
  20305. * Physics joint
  20306. */
  20307. physicsJoint: any;
  20308. /**
  20309. * Sets the motor of the motor-enabled joint
  20310. * @param force The force of the motor
  20311. * @param maxForce The maximum force of the motor
  20312. * @param motorIndex The index of the motor
  20313. */
  20314. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20315. /**
  20316. * Sets the limit of the motor
  20317. * @param upperLimit The upper limit of the motor
  20318. * @param lowerLimit The lower limit of the motor
  20319. * @param motorIndex The index of the motor
  20320. */
  20321. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20322. }
  20323. /**
  20324. * Joint data for a Distance-Joint
  20325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20326. */
  20327. export interface DistanceJointData extends PhysicsJointData {
  20328. /**
  20329. * Max distance the 2 joint objects can be apart
  20330. */
  20331. maxDistance: number;
  20332. }
  20333. /**
  20334. * Joint data from a spring joint
  20335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20336. */
  20337. export interface SpringJointData extends PhysicsJointData {
  20338. /**
  20339. * Length of the spring
  20340. */
  20341. length: number;
  20342. /**
  20343. * Stiffness of the spring
  20344. */
  20345. stiffness: number;
  20346. /**
  20347. * Damping of the spring
  20348. */
  20349. damping: number;
  20350. /** this callback will be called when applying the force to the impostors. */
  20351. forceApplicationCallback: () => void;
  20352. }
  20353. }
  20354. declare module "babylonjs/Physics/physicsRaycastResult" {
  20355. import { Vector3 } from "babylonjs/Maths/math";
  20356. /**
  20357. * Holds the data for the raycast result
  20358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20359. */
  20360. export class PhysicsRaycastResult {
  20361. private _hasHit;
  20362. private _hitDistance;
  20363. private _hitNormalWorld;
  20364. private _hitPointWorld;
  20365. private _rayFromWorld;
  20366. private _rayToWorld;
  20367. /**
  20368. * Gets if there was a hit
  20369. */
  20370. readonly hasHit: boolean;
  20371. /**
  20372. * Gets the distance from the hit
  20373. */
  20374. readonly hitDistance: number;
  20375. /**
  20376. * Gets the hit normal/direction in the world
  20377. */
  20378. readonly hitNormalWorld: Vector3;
  20379. /**
  20380. * Gets the hit point in the world
  20381. */
  20382. readonly hitPointWorld: Vector3;
  20383. /**
  20384. * Gets the ray "start point" of the ray in the world
  20385. */
  20386. readonly rayFromWorld: Vector3;
  20387. /**
  20388. * Gets the ray "end point" of the ray in the world
  20389. */
  20390. readonly rayToWorld: Vector3;
  20391. /**
  20392. * Sets the hit data (normal & point in world space)
  20393. * @param hitNormalWorld defines the normal in world space
  20394. * @param hitPointWorld defines the point in world space
  20395. */
  20396. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20397. /**
  20398. * Sets the distance from the start point to the hit point
  20399. * @param distance
  20400. */
  20401. setHitDistance(distance: number): void;
  20402. /**
  20403. * Calculates the distance manually
  20404. */
  20405. calculateHitDistance(): void;
  20406. /**
  20407. * Resets all the values to default
  20408. * @param from The from point on world space
  20409. * @param to The to point on world space
  20410. */
  20411. reset(from?: Vector3, to?: Vector3): void;
  20412. }
  20413. /**
  20414. * Interface for the size containing width and height
  20415. */
  20416. interface IXYZ {
  20417. /**
  20418. * X
  20419. */
  20420. x: number;
  20421. /**
  20422. * Y
  20423. */
  20424. y: number;
  20425. /**
  20426. * Z
  20427. */
  20428. z: number;
  20429. }
  20430. }
  20431. declare module "babylonjs/Physics/IPhysicsEngine" {
  20432. import { Nullable } from "babylonjs/types";
  20433. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20435. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20436. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20437. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20438. /**
  20439. * Interface used to describe a physics joint
  20440. */
  20441. export interface PhysicsImpostorJoint {
  20442. /** Defines the main impostor to which the joint is linked */
  20443. mainImpostor: PhysicsImpostor;
  20444. /** Defines the impostor that is connected to the main impostor using this joint */
  20445. connectedImpostor: PhysicsImpostor;
  20446. /** Defines the joint itself */
  20447. joint: PhysicsJoint;
  20448. }
  20449. /** @hidden */
  20450. export interface IPhysicsEnginePlugin {
  20451. world: any;
  20452. name: string;
  20453. setGravity(gravity: Vector3): void;
  20454. setTimeStep(timeStep: number): void;
  20455. getTimeStep(): number;
  20456. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20457. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20458. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20459. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20460. removePhysicsBody(impostor: PhysicsImpostor): void;
  20461. generateJoint(joint: PhysicsImpostorJoint): void;
  20462. removeJoint(joint: PhysicsImpostorJoint): void;
  20463. isSupported(): boolean;
  20464. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20465. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20466. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20467. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20468. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20469. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20470. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20471. getBodyMass(impostor: PhysicsImpostor): number;
  20472. getBodyFriction(impostor: PhysicsImpostor): number;
  20473. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20474. getBodyRestitution(impostor: PhysicsImpostor): number;
  20475. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20476. getBodyPressure?(impostor: PhysicsImpostor): number;
  20477. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20478. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20479. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20480. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20481. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20482. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20483. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20484. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20485. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20486. sleepBody(impostor: PhysicsImpostor): void;
  20487. wakeUpBody(impostor: PhysicsImpostor): void;
  20488. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20489. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20490. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20491. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20492. getRadius(impostor: PhysicsImpostor): number;
  20493. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20494. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20495. dispose(): void;
  20496. }
  20497. /**
  20498. * Interface used to define a physics engine
  20499. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20500. */
  20501. export interface IPhysicsEngine {
  20502. /**
  20503. * Gets the gravity vector used by the simulation
  20504. */
  20505. gravity: Vector3;
  20506. /**
  20507. * Sets the gravity vector used by the simulation
  20508. * @param gravity defines the gravity vector to use
  20509. */
  20510. setGravity(gravity: Vector3): void;
  20511. /**
  20512. * Set the time step of the physics engine.
  20513. * Default is 1/60.
  20514. * To slow it down, enter 1/600 for example.
  20515. * To speed it up, 1/30
  20516. * @param newTimeStep the new timestep to apply to this world.
  20517. */
  20518. setTimeStep(newTimeStep: number): void;
  20519. /**
  20520. * Get the time step of the physics engine.
  20521. * @returns the current time step
  20522. */
  20523. getTimeStep(): number;
  20524. /**
  20525. * Release all resources
  20526. */
  20527. dispose(): void;
  20528. /**
  20529. * Gets the name of the current physics plugin
  20530. * @returns the name of the plugin
  20531. */
  20532. getPhysicsPluginName(): string;
  20533. /**
  20534. * Adding a new impostor for the impostor tracking.
  20535. * This will be done by the impostor itself.
  20536. * @param impostor the impostor to add
  20537. */
  20538. addImpostor(impostor: PhysicsImpostor): void;
  20539. /**
  20540. * Remove an impostor from the engine.
  20541. * This impostor and its mesh will not longer be updated by the physics engine.
  20542. * @param impostor the impostor to remove
  20543. */
  20544. removeImpostor(impostor: PhysicsImpostor): void;
  20545. /**
  20546. * Add a joint to the physics engine
  20547. * @param mainImpostor defines the main impostor to which the joint is added.
  20548. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20549. * @param joint defines the joint that will connect both impostors.
  20550. */
  20551. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20552. /**
  20553. * Removes a joint from the simulation
  20554. * @param mainImpostor defines the impostor used with the joint
  20555. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20556. * @param joint defines the joint to remove
  20557. */
  20558. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20559. /**
  20560. * Gets the current plugin used to run the simulation
  20561. * @returns current plugin
  20562. */
  20563. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20564. /**
  20565. * Gets the list of physic impostors
  20566. * @returns an array of PhysicsImpostor
  20567. */
  20568. getImpostors(): Array<PhysicsImpostor>;
  20569. /**
  20570. * Gets the impostor for a physics enabled object
  20571. * @param object defines the object impersonated by the impostor
  20572. * @returns the PhysicsImpostor or null if not found
  20573. */
  20574. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20575. /**
  20576. * Gets the impostor for a physics body object
  20577. * @param body defines physics body used by the impostor
  20578. * @returns the PhysicsImpostor or null if not found
  20579. */
  20580. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20581. /**
  20582. * Does a raycast in the physics world
  20583. * @param from when should the ray start?
  20584. * @param to when should the ray end?
  20585. * @returns PhysicsRaycastResult
  20586. */
  20587. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20588. /**
  20589. * Called by the scene. No need to call it.
  20590. * @param delta defines the timespam between frames
  20591. */
  20592. _step(delta: number): void;
  20593. }
  20594. }
  20595. declare module "babylonjs/Physics/physicsImpostor" {
  20596. import { Nullable, IndicesArray } from "babylonjs/types";
  20597. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20600. import { Scene } from "babylonjs/scene";
  20601. import { Bone } from "babylonjs/Bones/bone";
  20602. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20603. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20604. /**
  20605. * The interface for the physics imposter parameters
  20606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20607. */
  20608. export interface PhysicsImpostorParameters {
  20609. /**
  20610. * The mass of the physics imposter
  20611. */
  20612. mass: number;
  20613. /**
  20614. * The friction of the physics imposter
  20615. */
  20616. friction?: number;
  20617. /**
  20618. * The coefficient of restitution of the physics imposter
  20619. */
  20620. restitution?: number;
  20621. /**
  20622. * The native options of the physics imposter
  20623. */
  20624. nativeOptions?: any;
  20625. /**
  20626. * Specifies if the parent should be ignored
  20627. */
  20628. ignoreParent?: boolean;
  20629. /**
  20630. * Specifies if bi-directional transformations should be disabled
  20631. */
  20632. disableBidirectionalTransformation?: boolean;
  20633. /**
  20634. * The pressure inside the physics imposter, soft object only
  20635. */
  20636. pressure?: number;
  20637. /**
  20638. * The stiffness the physics imposter, soft object only
  20639. */
  20640. stiffness?: number;
  20641. /**
  20642. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20643. */
  20644. velocityIterations?: number;
  20645. /**
  20646. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20647. */
  20648. positionIterations?: number;
  20649. /**
  20650. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20651. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20652. * Add to fix multiple points
  20653. */
  20654. fixedPoints?: number;
  20655. /**
  20656. * The collision margin around a soft object
  20657. */
  20658. margin?: number;
  20659. /**
  20660. * The collision margin around a soft object
  20661. */
  20662. damping?: number;
  20663. /**
  20664. * The path for a rope based on an extrusion
  20665. */
  20666. path?: any;
  20667. /**
  20668. * The shape of an extrusion used for a rope based on an extrusion
  20669. */
  20670. shape?: any;
  20671. }
  20672. /**
  20673. * Interface for a physics-enabled object
  20674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20675. */
  20676. export interface IPhysicsEnabledObject {
  20677. /**
  20678. * The position of the physics-enabled object
  20679. */
  20680. position: Vector3;
  20681. /**
  20682. * The rotation of the physics-enabled object
  20683. */
  20684. rotationQuaternion: Nullable<Quaternion>;
  20685. /**
  20686. * The scale of the physics-enabled object
  20687. */
  20688. scaling: Vector3;
  20689. /**
  20690. * The rotation of the physics-enabled object
  20691. */
  20692. rotation?: Vector3;
  20693. /**
  20694. * The parent of the physics-enabled object
  20695. */
  20696. parent?: any;
  20697. /**
  20698. * The bounding info of the physics-enabled object
  20699. * @returns The bounding info of the physics-enabled object
  20700. */
  20701. getBoundingInfo(): BoundingInfo;
  20702. /**
  20703. * Computes the world matrix
  20704. * @param force Specifies if the world matrix should be computed by force
  20705. * @returns A world matrix
  20706. */
  20707. computeWorldMatrix(force: boolean): Matrix;
  20708. /**
  20709. * Gets the world matrix
  20710. * @returns A world matrix
  20711. */
  20712. getWorldMatrix?(): Matrix;
  20713. /**
  20714. * Gets the child meshes
  20715. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20716. * @returns An array of abstract meshes
  20717. */
  20718. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20719. /**
  20720. * Gets the vertex data
  20721. * @param kind The type of vertex data
  20722. * @returns A nullable array of numbers, or a float32 array
  20723. */
  20724. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20725. /**
  20726. * Gets the indices from the mesh
  20727. * @returns A nullable array of index arrays
  20728. */
  20729. getIndices?(): Nullable<IndicesArray>;
  20730. /**
  20731. * Gets the scene from the mesh
  20732. * @returns the indices array or null
  20733. */
  20734. getScene?(): Scene;
  20735. /**
  20736. * Gets the absolute position from the mesh
  20737. * @returns the absolute position
  20738. */
  20739. getAbsolutePosition(): Vector3;
  20740. /**
  20741. * Gets the absolute pivot point from the mesh
  20742. * @returns the absolute pivot point
  20743. */
  20744. getAbsolutePivotPoint(): Vector3;
  20745. /**
  20746. * Rotates the mesh
  20747. * @param axis The axis of rotation
  20748. * @param amount The amount of rotation
  20749. * @param space The space of the rotation
  20750. * @returns The rotation transform node
  20751. */
  20752. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20753. /**
  20754. * Translates the mesh
  20755. * @param axis The axis of translation
  20756. * @param distance The distance of translation
  20757. * @param space The space of the translation
  20758. * @returns The transform node
  20759. */
  20760. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20761. /**
  20762. * Sets the absolute position of the mesh
  20763. * @param absolutePosition The absolute position of the mesh
  20764. * @returns The transform node
  20765. */
  20766. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20767. /**
  20768. * Gets the class name of the mesh
  20769. * @returns The class name
  20770. */
  20771. getClassName(): string;
  20772. }
  20773. /**
  20774. * Represents a physics imposter
  20775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20776. */
  20777. export class PhysicsImpostor {
  20778. /**
  20779. * The physics-enabled object used as the physics imposter
  20780. */
  20781. object: IPhysicsEnabledObject;
  20782. /**
  20783. * The type of the physics imposter
  20784. */
  20785. type: number;
  20786. private _options;
  20787. private _scene?;
  20788. /**
  20789. * The default object size of the imposter
  20790. */
  20791. static DEFAULT_OBJECT_SIZE: Vector3;
  20792. /**
  20793. * The identity quaternion of the imposter
  20794. */
  20795. static IDENTITY_QUATERNION: Quaternion;
  20796. /** @hidden */
  20797. _pluginData: any;
  20798. private _physicsEngine;
  20799. private _physicsBody;
  20800. private _bodyUpdateRequired;
  20801. private _onBeforePhysicsStepCallbacks;
  20802. private _onAfterPhysicsStepCallbacks;
  20803. /** @hidden */
  20804. _onPhysicsCollideCallbacks: Array<{
  20805. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20806. otherImpostors: Array<PhysicsImpostor>;
  20807. }>;
  20808. private _deltaPosition;
  20809. private _deltaRotation;
  20810. private _deltaRotationConjugated;
  20811. /** hidden */
  20812. _isFromLine: boolean;
  20813. private _parent;
  20814. private _isDisposed;
  20815. private static _tmpVecs;
  20816. private static _tmpQuat;
  20817. /**
  20818. * Specifies if the physics imposter is disposed
  20819. */
  20820. readonly isDisposed: boolean;
  20821. /**
  20822. * Gets the mass of the physics imposter
  20823. */
  20824. mass: number;
  20825. /**
  20826. * Gets the coefficient of friction
  20827. */
  20828. /**
  20829. * Sets the coefficient of friction
  20830. */
  20831. friction: number;
  20832. /**
  20833. * Gets the coefficient of restitution
  20834. */
  20835. /**
  20836. * Sets the coefficient of restitution
  20837. */
  20838. restitution: number;
  20839. /**
  20840. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20841. */
  20842. /**
  20843. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20844. */
  20845. pressure: number;
  20846. /**
  20847. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20848. */
  20849. /**
  20850. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20851. */
  20852. stiffness: number;
  20853. /**
  20854. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20855. */
  20856. /**
  20857. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20858. */
  20859. velocityIterations: number;
  20860. /**
  20861. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20862. */
  20863. /**
  20864. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20865. */
  20866. positionIterations: number;
  20867. /**
  20868. * The unique id of the physics imposter
  20869. * set by the physics engine when adding this impostor to the array
  20870. */
  20871. uniqueId: number;
  20872. /**
  20873. * @hidden
  20874. */
  20875. soft: boolean;
  20876. /**
  20877. * @hidden
  20878. */
  20879. segments: number;
  20880. private _joints;
  20881. /**
  20882. * Initializes the physics imposter
  20883. * @param object The physics-enabled object used as the physics imposter
  20884. * @param type The type of the physics imposter
  20885. * @param _options The options for the physics imposter
  20886. * @param _scene The Babylon scene
  20887. */
  20888. constructor(
  20889. /**
  20890. * The physics-enabled object used as the physics imposter
  20891. */
  20892. object: IPhysicsEnabledObject,
  20893. /**
  20894. * The type of the physics imposter
  20895. */
  20896. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20897. /**
  20898. * This function will completly initialize this impostor.
  20899. * It will create a new body - but only if this mesh has no parent.
  20900. * If it has, this impostor will not be used other than to define the impostor
  20901. * of the child mesh.
  20902. * @hidden
  20903. */
  20904. _init(): void;
  20905. private _getPhysicsParent;
  20906. /**
  20907. * Should a new body be generated.
  20908. * @returns boolean specifying if body initialization is required
  20909. */
  20910. isBodyInitRequired(): boolean;
  20911. /**
  20912. * Sets the updated scaling
  20913. * @param updated Specifies if the scaling is updated
  20914. */
  20915. setScalingUpdated(): void;
  20916. /**
  20917. * Force a regeneration of this or the parent's impostor's body.
  20918. * Use under cautious - This will remove all joints already implemented.
  20919. */
  20920. forceUpdate(): void;
  20921. /**
  20922. * Gets the body that holds this impostor. Either its own, or its parent.
  20923. */
  20924. /**
  20925. * Set the physics body. Used mainly by the physics engine/plugin
  20926. */
  20927. physicsBody: any;
  20928. /**
  20929. * Get the parent of the physics imposter
  20930. * @returns Physics imposter or null
  20931. */
  20932. /**
  20933. * Sets the parent of the physics imposter
  20934. */
  20935. parent: Nullable<PhysicsImpostor>;
  20936. /**
  20937. * Resets the update flags
  20938. */
  20939. resetUpdateFlags(): void;
  20940. /**
  20941. * Gets the object extend size
  20942. * @returns the object extend size
  20943. */
  20944. getObjectExtendSize(): Vector3;
  20945. /**
  20946. * Gets the object center
  20947. * @returns The object center
  20948. */
  20949. getObjectCenter(): Vector3;
  20950. /**
  20951. * Get a specific parametes from the options parameter
  20952. * @param paramName The object parameter name
  20953. * @returns The object parameter
  20954. */
  20955. getParam(paramName: string): any;
  20956. /**
  20957. * Sets a specific parameter in the options given to the physics plugin
  20958. * @param paramName The parameter name
  20959. * @param value The value of the parameter
  20960. */
  20961. setParam(paramName: string, value: number): void;
  20962. /**
  20963. * Specifically change the body's mass option. Won't recreate the physics body object
  20964. * @param mass The mass of the physics imposter
  20965. */
  20966. setMass(mass: number): void;
  20967. /**
  20968. * Gets the linear velocity
  20969. * @returns linear velocity or null
  20970. */
  20971. getLinearVelocity(): Nullable<Vector3>;
  20972. /**
  20973. * Sets the linear velocity
  20974. * @param velocity linear velocity or null
  20975. */
  20976. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20977. /**
  20978. * Gets the angular velocity
  20979. * @returns angular velocity or null
  20980. */
  20981. getAngularVelocity(): Nullable<Vector3>;
  20982. /**
  20983. * Sets the angular velocity
  20984. * @param velocity The velocity or null
  20985. */
  20986. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20987. /**
  20988. * Execute a function with the physics plugin native code
  20989. * Provide a function the will have two variables - the world object and the physics body object
  20990. * @param func The function to execute with the physics plugin native code
  20991. */
  20992. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20993. /**
  20994. * Register a function that will be executed before the physics world is stepping forward
  20995. * @param func The function to execute before the physics world is stepped forward
  20996. */
  20997. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20998. /**
  20999. * Unregister a function that will be executed before the physics world is stepping forward
  21000. * @param func The function to execute before the physics world is stepped forward
  21001. */
  21002. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21003. /**
  21004. * Register a function that will be executed after the physics step
  21005. * @param func The function to execute after physics step
  21006. */
  21007. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21008. /**
  21009. * Unregisters a function that will be executed after the physics step
  21010. * @param func The function to execute after physics step
  21011. */
  21012. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21013. /**
  21014. * register a function that will be executed when this impostor collides against a different body
  21015. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21016. * @param func Callback that is executed on collision
  21017. */
  21018. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21019. /**
  21020. * Unregisters the physics imposter on contact
  21021. * @param collideAgainst The physics object to collide against
  21022. * @param func Callback to execute on collision
  21023. */
  21024. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21025. private _tmpQuat;
  21026. private _tmpQuat2;
  21027. /**
  21028. * Get the parent rotation
  21029. * @returns The parent rotation
  21030. */
  21031. getParentsRotation(): Quaternion;
  21032. /**
  21033. * this function is executed by the physics engine.
  21034. */
  21035. beforeStep: () => void;
  21036. /**
  21037. * this function is executed by the physics engine
  21038. */
  21039. afterStep: () => void;
  21040. /**
  21041. * Legacy collision detection event support
  21042. */
  21043. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21044. /**
  21045. * event and body object due to cannon's event-based architecture.
  21046. */
  21047. onCollide: (e: {
  21048. body: any;
  21049. }) => void;
  21050. /**
  21051. * Apply a force
  21052. * @param force The force to apply
  21053. * @param contactPoint The contact point for the force
  21054. * @returns The physics imposter
  21055. */
  21056. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21057. /**
  21058. * Apply an impulse
  21059. * @param force The impulse force
  21060. * @param contactPoint The contact point for the impulse force
  21061. * @returns The physics imposter
  21062. */
  21063. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21064. /**
  21065. * A help function to create a joint
  21066. * @param otherImpostor A physics imposter used to create a joint
  21067. * @param jointType The type of joint
  21068. * @param jointData The data for the joint
  21069. * @returns The physics imposter
  21070. */
  21071. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21072. /**
  21073. * Add a joint to this impostor with a different impostor
  21074. * @param otherImpostor A physics imposter used to add a joint
  21075. * @param joint The joint to add
  21076. * @returns The physics imposter
  21077. */
  21078. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21079. /**
  21080. * Add an anchor to a cloth impostor
  21081. * @param otherImpostor rigid impostor to anchor to
  21082. * @param width ratio across width from 0 to 1
  21083. * @param height ratio up height from 0 to 1
  21084. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21085. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21086. * @returns impostor the soft imposter
  21087. */
  21088. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21089. /**
  21090. * Add a hook to a rope impostor
  21091. * @param otherImpostor rigid impostor to anchor to
  21092. * @param length ratio across rope from 0 to 1
  21093. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21094. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21095. * @returns impostor the rope imposter
  21096. */
  21097. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21098. /**
  21099. * Will keep this body still, in a sleep mode.
  21100. * @returns the physics imposter
  21101. */
  21102. sleep(): PhysicsImpostor;
  21103. /**
  21104. * Wake the body up.
  21105. * @returns The physics imposter
  21106. */
  21107. wakeUp(): PhysicsImpostor;
  21108. /**
  21109. * Clones the physics imposter
  21110. * @param newObject The physics imposter clones to this physics-enabled object
  21111. * @returns A nullable physics imposter
  21112. */
  21113. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21114. /**
  21115. * Disposes the physics imposter
  21116. */
  21117. dispose(): void;
  21118. /**
  21119. * Sets the delta position
  21120. * @param position The delta position amount
  21121. */
  21122. setDeltaPosition(position: Vector3): void;
  21123. /**
  21124. * Sets the delta rotation
  21125. * @param rotation The delta rotation amount
  21126. */
  21127. setDeltaRotation(rotation: Quaternion): void;
  21128. /**
  21129. * Gets the box size of the physics imposter and stores the result in the input parameter
  21130. * @param result Stores the box size
  21131. * @returns The physics imposter
  21132. */
  21133. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21134. /**
  21135. * Gets the radius of the physics imposter
  21136. * @returns Radius of the physics imposter
  21137. */
  21138. getRadius(): number;
  21139. /**
  21140. * Sync a bone with this impostor
  21141. * @param bone The bone to sync to the impostor.
  21142. * @param boneMesh The mesh that the bone is influencing.
  21143. * @param jointPivot The pivot of the joint / bone in local space.
  21144. * @param distToJoint Optional distance from the impostor to the joint.
  21145. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21146. */
  21147. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21148. /**
  21149. * Sync impostor to a bone
  21150. * @param bone The bone that the impostor will be synced to.
  21151. * @param boneMesh The mesh that the bone is influencing.
  21152. * @param jointPivot The pivot of the joint / bone in local space.
  21153. * @param distToJoint Optional distance from the impostor to the joint.
  21154. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21155. * @param boneAxis Optional vector3 axis the bone is aligned with
  21156. */
  21157. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21158. /**
  21159. * No-Imposter type
  21160. */
  21161. static NoImpostor: number;
  21162. /**
  21163. * Sphere-Imposter type
  21164. */
  21165. static SphereImpostor: number;
  21166. /**
  21167. * Box-Imposter type
  21168. */
  21169. static BoxImpostor: number;
  21170. /**
  21171. * Plane-Imposter type
  21172. */
  21173. static PlaneImpostor: number;
  21174. /**
  21175. * Mesh-imposter type
  21176. */
  21177. static MeshImpostor: number;
  21178. /**
  21179. * Cylinder-Imposter type
  21180. */
  21181. static CylinderImpostor: number;
  21182. /**
  21183. * Particle-Imposter type
  21184. */
  21185. static ParticleImpostor: number;
  21186. /**
  21187. * Heightmap-Imposter type
  21188. */
  21189. static HeightmapImpostor: number;
  21190. /**
  21191. * ConvexHull-Impostor type (Ammo.js plugin only)
  21192. */
  21193. static ConvexHullImpostor: number;
  21194. /**
  21195. * Rope-Imposter type
  21196. */
  21197. static RopeImpostor: number;
  21198. /**
  21199. * Cloth-Imposter type
  21200. */
  21201. static ClothImpostor: number;
  21202. /**
  21203. * Softbody-Imposter type
  21204. */
  21205. static SoftbodyImpostor: number;
  21206. }
  21207. }
  21208. declare module "babylonjs/Meshes/mesh" {
  21209. import { Observable } from "babylonjs/Misc/observable";
  21210. import { IAnimatable } from "babylonjs/Misc/tools";
  21211. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21212. import { Camera } from "babylonjs/Cameras/camera";
  21213. import { Scene } from "babylonjs/scene";
  21214. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21215. import { Engine } from "babylonjs/Engines/engine";
  21216. import { Node } from "babylonjs/node";
  21217. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21218. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21219. import { Buffer } from "babylonjs/Meshes/buffer";
  21220. import { Geometry } from "babylonjs/Meshes/geometry";
  21221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21222. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21223. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21224. import { Effect } from "babylonjs/Materials/effect";
  21225. import { Material } from "babylonjs/Materials/material";
  21226. import { Skeleton } from "babylonjs/Bones/skeleton";
  21227. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21228. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21229. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21230. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21231. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21232. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21233. /**
  21234. * Class used to represent a specific level of detail of a mesh
  21235. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21236. */
  21237. export class MeshLODLevel {
  21238. /** Defines the distance where this level should star being displayed */
  21239. distance: number;
  21240. /** Defines the mesh to use to render this level */
  21241. mesh: Nullable<Mesh>;
  21242. /**
  21243. * Creates a new LOD level
  21244. * @param distance defines the distance where this level should star being displayed
  21245. * @param mesh defines the mesh to use to render this level
  21246. */
  21247. constructor(
  21248. /** Defines the distance where this level should star being displayed */
  21249. distance: number,
  21250. /** Defines the mesh to use to render this level */
  21251. mesh: Nullable<Mesh>);
  21252. }
  21253. /**
  21254. * @hidden
  21255. **/
  21256. export class _CreationDataStorage {
  21257. closePath?: boolean;
  21258. closeArray?: boolean;
  21259. idx: number[];
  21260. dashSize: number;
  21261. gapSize: number;
  21262. path3D: Path3D;
  21263. pathArray: Vector3[][];
  21264. arc: number;
  21265. radius: number;
  21266. cap: number;
  21267. tessellation: number;
  21268. }
  21269. /**
  21270. * @hidden
  21271. **/
  21272. class _InstanceDataStorage {
  21273. visibleInstances: any;
  21274. batchCache: _InstancesBatch;
  21275. instancesBufferSize: number;
  21276. instancesBuffer: Nullable<Buffer>;
  21277. instancesData: Float32Array;
  21278. overridenInstanceCount: number;
  21279. isFrozen: boolean;
  21280. previousBatch: _InstancesBatch;
  21281. hardwareInstancedRendering: boolean;
  21282. sideOrientation: number;
  21283. }
  21284. /**
  21285. * @hidden
  21286. **/
  21287. export class _InstancesBatch {
  21288. mustReturn: boolean;
  21289. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21290. renderSelf: boolean[];
  21291. hardwareInstancedRendering: boolean[];
  21292. }
  21293. /**
  21294. * Class used to represent renderable models
  21295. */
  21296. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21297. /**
  21298. * Mesh side orientation : usually the external or front surface
  21299. */
  21300. static readonly FRONTSIDE: number;
  21301. /**
  21302. * Mesh side orientation : usually the internal or back surface
  21303. */
  21304. static readonly BACKSIDE: number;
  21305. /**
  21306. * Mesh side orientation : both internal and external or front and back surfaces
  21307. */
  21308. static readonly DOUBLESIDE: number;
  21309. /**
  21310. * Mesh side orientation : by default, `FRONTSIDE`
  21311. */
  21312. static readonly DEFAULTSIDE: number;
  21313. /**
  21314. * Mesh cap setting : no cap
  21315. */
  21316. static readonly NO_CAP: number;
  21317. /**
  21318. * Mesh cap setting : one cap at the beginning of the mesh
  21319. */
  21320. static readonly CAP_START: number;
  21321. /**
  21322. * Mesh cap setting : one cap at the end of the mesh
  21323. */
  21324. static readonly CAP_END: number;
  21325. /**
  21326. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21327. */
  21328. static readonly CAP_ALL: number;
  21329. /**
  21330. * Gets the default side orientation.
  21331. * @param orientation the orientation to value to attempt to get
  21332. * @returns the default orientation
  21333. * @hidden
  21334. */
  21335. static _GetDefaultSideOrientation(orientation?: number): number;
  21336. private _onBeforeRenderObservable;
  21337. private _onBeforeBindObservable;
  21338. private _onAfterRenderObservable;
  21339. private _onBeforeDrawObservable;
  21340. /**
  21341. * An event triggered before rendering the mesh
  21342. */
  21343. readonly onBeforeRenderObservable: Observable<Mesh>;
  21344. /**
  21345. * An event triggered before binding the mesh
  21346. */
  21347. readonly onBeforeBindObservable: Observable<Mesh>;
  21348. /**
  21349. * An event triggered after rendering the mesh
  21350. */
  21351. readonly onAfterRenderObservable: Observable<Mesh>;
  21352. /**
  21353. * An event triggered before drawing the mesh
  21354. */
  21355. readonly onBeforeDrawObservable: Observable<Mesh>;
  21356. private _onBeforeDrawObserver;
  21357. /**
  21358. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21359. */
  21360. onBeforeDraw: () => void;
  21361. /**
  21362. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21363. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21364. */
  21365. delayLoadState: number;
  21366. /**
  21367. * Gets the list of instances created from this mesh
  21368. * it is not supposed to be modified manually.
  21369. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21370. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21371. */
  21372. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21373. /**
  21374. * Gets the file containing delay loading data for this mesh
  21375. */
  21376. delayLoadingFile: string;
  21377. /** @hidden */
  21378. _binaryInfo: any;
  21379. private _LODLevels;
  21380. /**
  21381. * User defined function used to change how LOD level selection is done
  21382. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21383. */
  21384. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21385. private _morphTargetManager;
  21386. /**
  21387. * Gets or sets the morph target manager
  21388. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21389. */
  21390. morphTargetManager: Nullable<MorphTargetManager>;
  21391. /** @hidden */
  21392. _creationDataStorage: Nullable<_CreationDataStorage>;
  21393. /** @hidden */
  21394. _geometry: Nullable<Geometry>;
  21395. /** @hidden */
  21396. _delayInfo: Array<string>;
  21397. /** @hidden */
  21398. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21399. /** @hidden */
  21400. _instanceDataStorage: _InstanceDataStorage;
  21401. private _effectiveMaterial;
  21402. /** @hidden */
  21403. _shouldGenerateFlatShading: boolean;
  21404. private _preActivateId;
  21405. /** @hidden */
  21406. _originalBuilderSideOrientation: number;
  21407. /**
  21408. * Use this property to change the original side orientation defined at construction time
  21409. */
  21410. overrideMaterialSideOrientation: Nullable<number>;
  21411. private _areNormalsFrozen;
  21412. private _sourcePositions;
  21413. private _sourceNormals;
  21414. private _source;
  21415. private meshMap;
  21416. /**
  21417. * Gets the source mesh (the one used to clone this one from)
  21418. */
  21419. readonly source: Nullable<Mesh>;
  21420. /**
  21421. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21422. */
  21423. isUnIndexed: boolean;
  21424. /**
  21425. * @constructor
  21426. * @param name The value used by scene.getMeshByName() to do a lookup.
  21427. * @param scene The scene to add this mesh to.
  21428. * @param parent The parent of this mesh, if it has one
  21429. * @param source An optional Mesh from which geometry is shared, cloned.
  21430. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21431. * When false, achieved by calling a clone(), also passing False.
  21432. * This will make creation of children, recursive.
  21433. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21434. */
  21435. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21436. /**
  21437. * Gets the class name
  21438. * @returns the string "Mesh".
  21439. */
  21440. getClassName(): string;
  21441. /** @hidden */
  21442. readonly _isMesh: boolean;
  21443. /**
  21444. * Returns a description of this mesh
  21445. * @param fullDetails define if full details about this mesh must be used
  21446. * @returns a descriptive string representing this mesh
  21447. */
  21448. toString(fullDetails?: boolean): string;
  21449. /** @hidden */
  21450. _unBindEffect(): void;
  21451. /**
  21452. * Gets a boolean indicating if this mesh has LOD
  21453. */
  21454. readonly hasLODLevels: boolean;
  21455. /**
  21456. * Gets the list of MeshLODLevel associated with the current mesh
  21457. * @returns an array of MeshLODLevel
  21458. */
  21459. getLODLevels(): MeshLODLevel[];
  21460. private _sortLODLevels;
  21461. /**
  21462. * Add a mesh as LOD level triggered at the given distance.
  21463. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21464. * @param distance The distance from the center of the object to show this level
  21465. * @param mesh The mesh to be added as LOD level (can be null)
  21466. * @return This mesh (for chaining)
  21467. */
  21468. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21469. /**
  21470. * Returns the LOD level mesh at the passed distance or null if not found.
  21471. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21472. * @param distance The distance from the center of the object to show this level
  21473. * @returns a Mesh or `null`
  21474. */
  21475. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21476. /**
  21477. * Remove a mesh from the LOD array
  21478. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21479. * @param mesh defines the mesh to be removed
  21480. * @return This mesh (for chaining)
  21481. */
  21482. removeLODLevel(mesh: Mesh): Mesh;
  21483. /**
  21484. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21485. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21486. * @param camera defines the camera to use to compute distance
  21487. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21488. * @return This mesh (for chaining)
  21489. */
  21490. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21491. /**
  21492. * Gets the mesh internal Geometry object
  21493. */
  21494. readonly geometry: Nullable<Geometry>;
  21495. /**
  21496. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21497. * @returns the total number of vertices
  21498. */
  21499. getTotalVertices(): number;
  21500. /**
  21501. * Returns the content of an associated vertex buffer
  21502. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21503. * - VertexBuffer.PositionKind
  21504. * - VertexBuffer.UVKind
  21505. * - VertexBuffer.UV2Kind
  21506. * - VertexBuffer.UV3Kind
  21507. * - VertexBuffer.UV4Kind
  21508. * - VertexBuffer.UV5Kind
  21509. * - VertexBuffer.UV6Kind
  21510. * - VertexBuffer.ColorKind
  21511. * - VertexBuffer.MatricesIndicesKind
  21512. * - VertexBuffer.MatricesIndicesExtraKind
  21513. * - VertexBuffer.MatricesWeightsKind
  21514. * - VertexBuffer.MatricesWeightsExtraKind
  21515. * @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
  21516. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21517. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21518. */
  21519. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21520. /**
  21521. * Returns the mesh VertexBuffer object from the requested `kind`
  21522. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21523. * - VertexBuffer.PositionKind
  21524. * - VertexBuffer.UVKind
  21525. * - VertexBuffer.UV2Kind
  21526. * - VertexBuffer.UV3Kind
  21527. * - VertexBuffer.UV4Kind
  21528. * - VertexBuffer.UV5Kind
  21529. * - VertexBuffer.UV6Kind
  21530. * - VertexBuffer.ColorKind
  21531. * - VertexBuffer.MatricesIndicesKind
  21532. * - VertexBuffer.MatricesIndicesExtraKind
  21533. * - VertexBuffer.MatricesWeightsKind
  21534. * - VertexBuffer.MatricesWeightsExtraKind
  21535. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21536. */
  21537. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21538. /**
  21539. * Tests if a specific vertex buffer is associated with this mesh
  21540. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21541. * - VertexBuffer.PositionKind
  21542. * - VertexBuffer.UVKind
  21543. * - VertexBuffer.UV2Kind
  21544. * - VertexBuffer.UV3Kind
  21545. * - VertexBuffer.UV4Kind
  21546. * - VertexBuffer.UV5Kind
  21547. * - VertexBuffer.UV6Kind
  21548. * - VertexBuffer.ColorKind
  21549. * - VertexBuffer.MatricesIndicesKind
  21550. * - VertexBuffer.MatricesIndicesExtraKind
  21551. * - VertexBuffer.MatricesWeightsKind
  21552. * - VertexBuffer.MatricesWeightsExtraKind
  21553. * @returns a boolean
  21554. */
  21555. isVerticesDataPresent(kind: string): boolean;
  21556. /**
  21557. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21558. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21559. * - VertexBuffer.PositionKind
  21560. * - VertexBuffer.UVKind
  21561. * - VertexBuffer.UV2Kind
  21562. * - VertexBuffer.UV3Kind
  21563. * - VertexBuffer.UV4Kind
  21564. * - VertexBuffer.UV5Kind
  21565. * - VertexBuffer.UV6Kind
  21566. * - VertexBuffer.ColorKind
  21567. * - VertexBuffer.MatricesIndicesKind
  21568. * - VertexBuffer.MatricesIndicesExtraKind
  21569. * - VertexBuffer.MatricesWeightsKind
  21570. * - VertexBuffer.MatricesWeightsExtraKind
  21571. * @returns a boolean
  21572. */
  21573. isVertexBufferUpdatable(kind: string): boolean;
  21574. /**
  21575. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21576. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21577. * - VertexBuffer.PositionKind
  21578. * - VertexBuffer.UVKind
  21579. * - VertexBuffer.UV2Kind
  21580. * - VertexBuffer.UV3Kind
  21581. * - VertexBuffer.UV4Kind
  21582. * - VertexBuffer.UV5Kind
  21583. * - VertexBuffer.UV6Kind
  21584. * - VertexBuffer.ColorKind
  21585. * - VertexBuffer.MatricesIndicesKind
  21586. * - VertexBuffer.MatricesIndicesExtraKind
  21587. * - VertexBuffer.MatricesWeightsKind
  21588. * - VertexBuffer.MatricesWeightsExtraKind
  21589. * @returns an array of strings
  21590. */
  21591. getVerticesDataKinds(): string[];
  21592. /**
  21593. * Returns a positive integer : the total number of indices in this mesh geometry.
  21594. * @returns the numner of indices or zero if the mesh has no geometry.
  21595. */
  21596. getTotalIndices(): number;
  21597. /**
  21598. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21599. * @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.
  21600. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21601. * @returns the indices array or an empty array if the mesh has no geometry
  21602. */
  21603. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21604. readonly isBlocked: boolean;
  21605. /**
  21606. * Determine if the current mesh is ready to be rendered
  21607. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21608. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21609. * @returns true if all associated assets are ready (material, textures, shaders)
  21610. */
  21611. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21612. /**
  21613. * 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.
  21614. */
  21615. readonly areNormalsFrozen: boolean;
  21616. /**
  21617. * 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.
  21618. * @returns the current mesh
  21619. */
  21620. freezeNormals(): Mesh;
  21621. /**
  21622. * 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
  21623. * @returns the current mesh
  21624. */
  21625. unfreezeNormals(): Mesh;
  21626. /**
  21627. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21628. */
  21629. overridenInstanceCount: number;
  21630. /** @hidden */
  21631. _preActivate(): Mesh;
  21632. /** @hidden */
  21633. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21634. /** @hidden */
  21635. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21636. /**
  21637. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21638. * This means the mesh underlying bounding box and sphere are recomputed.
  21639. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21640. * @returns the current mesh
  21641. */
  21642. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21643. /** @hidden */
  21644. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21645. /**
  21646. * This function will subdivide the mesh into multiple submeshes
  21647. * @param count defines the expected number of submeshes
  21648. */
  21649. subdivide(count: number): void;
  21650. /**
  21651. * Copy a FloatArray into a specific associated vertex buffer
  21652. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21653. * - VertexBuffer.PositionKind
  21654. * - VertexBuffer.UVKind
  21655. * - VertexBuffer.UV2Kind
  21656. * - VertexBuffer.UV3Kind
  21657. * - VertexBuffer.UV4Kind
  21658. * - VertexBuffer.UV5Kind
  21659. * - VertexBuffer.UV6Kind
  21660. * - VertexBuffer.ColorKind
  21661. * - VertexBuffer.MatricesIndicesKind
  21662. * - VertexBuffer.MatricesIndicesExtraKind
  21663. * - VertexBuffer.MatricesWeightsKind
  21664. * - VertexBuffer.MatricesWeightsExtraKind
  21665. * @param data defines the data source
  21666. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21667. * @param stride defines the data stride size (can be null)
  21668. * @returns the current mesh
  21669. */
  21670. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21671. /**
  21672. * Flags an associated vertex buffer as updatable
  21673. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21674. * - VertexBuffer.PositionKind
  21675. * - VertexBuffer.UVKind
  21676. * - VertexBuffer.UV2Kind
  21677. * - VertexBuffer.UV3Kind
  21678. * - VertexBuffer.UV4Kind
  21679. * - VertexBuffer.UV5Kind
  21680. * - VertexBuffer.UV6Kind
  21681. * - VertexBuffer.ColorKind
  21682. * - VertexBuffer.MatricesIndicesKind
  21683. * - VertexBuffer.MatricesIndicesExtraKind
  21684. * - VertexBuffer.MatricesWeightsKind
  21685. * - VertexBuffer.MatricesWeightsExtraKind
  21686. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21687. */
  21688. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21689. /**
  21690. * Sets the mesh global Vertex Buffer
  21691. * @param buffer defines the buffer to use
  21692. * @returns the current mesh
  21693. */
  21694. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21695. /**
  21696. * Update a specific associated vertex buffer
  21697. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21698. * - VertexBuffer.PositionKind
  21699. * - VertexBuffer.UVKind
  21700. * - VertexBuffer.UV2Kind
  21701. * - VertexBuffer.UV3Kind
  21702. * - VertexBuffer.UV4Kind
  21703. * - VertexBuffer.UV5Kind
  21704. * - VertexBuffer.UV6Kind
  21705. * - VertexBuffer.ColorKind
  21706. * - VertexBuffer.MatricesIndicesKind
  21707. * - VertexBuffer.MatricesIndicesExtraKind
  21708. * - VertexBuffer.MatricesWeightsKind
  21709. * - VertexBuffer.MatricesWeightsExtraKind
  21710. * @param data defines the data source
  21711. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21712. * @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)
  21713. * @returns the current mesh
  21714. */
  21715. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21716. /**
  21717. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21718. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21719. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21720. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21721. * @returns the current mesh
  21722. */
  21723. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21724. /**
  21725. * Creates a un-shared specific occurence of the geometry for the mesh.
  21726. * @returns the current mesh
  21727. */
  21728. makeGeometryUnique(): Mesh;
  21729. /**
  21730. * Set the index buffer of this mesh
  21731. * @param indices defines the source data
  21732. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21733. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21734. * @returns the current mesh
  21735. */
  21736. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21737. /**
  21738. * Update the current index buffer
  21739. * @param indices defines the source data
  21740. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21741. * @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)
  21742. * @returns the current mesh
  21743. */
  21744. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21745. /**
  21746. * Invert the geometry to move from a right handed system to a left handed one.
  21747. * @returns the current mesh
  21748. */
  21749. toLeftHanded(): Mesh;
  21750. /** @hidden */
  21751. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21752. /** @hidden */
  21753. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21754. /**
  21755. * Registers for this mesh a javascript function called just before the rendering process
  21756. * @param func defines the function to call before rendering this mesh
  21757. * @returns the current mesh
  21758. */
  21759. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21760. /**
  21761. * Disposes a previously registered javascript function called before the rendering
  21762. * @param func defines the function to remove
  21763. * @returns the current mesh
  21764. */
  21765. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21766. /**
  21767. * Registers for this mesh a javascript function called just after the rendering is complete
  21768. * @param func defines the function to call after rendering this mesh
  21769. * @returns the current mesh
  21770. */
  21771. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21772. /**
  21773. * Disposes a previously registered javascript function called after the rendering.
  21774. * @param func defines the function to remove
  21775. * @returns the current mesh
  21776. */
  21777. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21778. /** @hidden */
  21779. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21780. /** @hidden */
  21781. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21782. /** @hidden */
  21783. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21784. /** @hidden */
  21785. _freeze(): void;
  21786. /** @hidden */
  21787. _unFreeze(): void;
  21788. /**
  21789. * 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
  21790. * @param subMesh defines the subMesh to render
  21791. * @param enableAlphaMode defines if alpha mode can be changed
  21792. * @returns the current mesh
  21793. */
  21794. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21795. private _onBeforeDraw;
  21796. /**
  21797. * Renormalize the mesh and patch it up if there are no weights
  21798. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21799. * However in the case of zero weights then we set just a single influence to 1.
  21800. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21801. */
  21802. cleanMatrixWeights(): void;
  21803. private normalizeSkinFourWeights;
  21804. private normalizeSkinWeightsAndExtra;
  21805. /**
  21806. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21807. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21808. * the user know there was an issue with importing the mesh
  21809. * @returns a validation object with skinned, valid and report string
  21810. */
  21811. validateSkinning(): {
  21812. skinned: boolean;
  21813. valid: boolean;
  21814. report: string;
  21815. };
  21816. /** @hidden */
  21817. _checkDelayState(): Mesh;
  21818. private _queueLoad;
  21819. /**
  21820. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21821. * A mesh is in the frustum if its bounding box intersects the frustum
  21822. * @param frustumPlanes defines the frustum to test
  21823. * @returns true if the mesh is in the frustum planes
  21824. */
  21825. isInFrustum(frustumPlanes: Plane[]): boolean;
  21826. /**
  21827. * Sets the mesh material by the material or multiMaterial `id` property
  21828. * @param id is a string identifying the material or the multiMaterial
  21829. * @returns the current mesh
  21830. */
  21831. setMaterialByID(id: string): Mesh;
  21832. /**
  21833. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21834. * @returns an array of IAnimatable
  21835. */
  21836. getAnimatables(): IAnimatable[];
  21837. /**
  21838. * Modifies the mesh geometry according to the passed transformation matrix.
  21839. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21840. * The mesh normals are modified using the same transformation.
  21841. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21842. * @param transform defines the transform matrix to use
  21843. * @see http://doc.babylonjs.com/resources/baking_transformations
  21844. * @returns the current mesh
  21845. */
  21846. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21847. /**
  21848. * Modifies the mesh geometry according to its own current World Matrix.
  21849. * The mesh World Matrix is then reset.
  21850. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21851. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21852. * @see http://doc.babylonjs.com/resources/baking_transformations
  21853. * @returns the current mesh
  21854. */
  21855. bakeCurrentTransformIntoVertices(): Mesh;
  21856. /** @hidden */
  21857. readonly _positions: Nullable<Vector3[]>;
  21858. /** @hidden */
  21859. _resetPointsArrayCache(): Mesh;
  21860. /** @hidden */
  21861. _generatePointsArray(): boolean;
  21862. /**
  21863. * Returns a new Mesh object generated from the current mesh properties.
  21864. * This method must not get confused with createInstance()
  21865. * @param name is a string, the name given to the new mesh
  21866. * @param newParent can be any Node object (default `null`)
  21867. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21868. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21869. * @returns a new mesh
  21870. */
  21871. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21872. /**
  21873. * Releases resources associated with this mesh.
  21874. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21875. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21876. */
  21877. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21878. /**
  21879. * Modifies the mesh geometry according to a displacement map.
  21880. * 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.
  21881. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21882. * @param url is a string, the URL from the image file is to be downloaded.
  21883. * @param minHeight is the lower limit of the displacement.
  21884. * @param maxHeight is the upper limit of the displacement.
  21885. * @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.
  21886. * @param uvOffset is an optional vector2 used to offset UV.
  21887. * @param uvScale is an optional vector2 used to scale UV.
  21888. * @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.
  21889. * @returns the Mesh.
  21890. */
  21891. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21892. /**
  21893. * Modifies the mesh geometry according to a displacementMap buffer.
  21894. * 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.
  21895. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21896. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21897. * @param heightMapWidth is the width of the buffer image.
  21898. * @param heightMapHeight is the height of the buffer image.
  21899. * @param minHeight is the lower limit of the displacement.
  21900. * @param maxHeight is the upper limit of the displacement.
  21901. * @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.
  21902. * @param uvOffset is an optional vector2 used to offset UV.
  21903. * @param uvScale is an optional vector2 used to scale UV.
  21904. * @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.
  21905. * @returns the Mesh.
  21906. */
  21907. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21908. /**
  21909. * Modify the mesh to get a flat shading rendering.
  21910. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21911. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21912. * @returns current mesh
  21913. */
  21914. convertToFlatShadedMesh(): Mesh;
  21915. /**
  21916. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21917. * In other words, more vertices, no more indices and a single bigger VBO.
  21918. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21919. * @returns current mesh
  21920. */
  21921. convertToUnIndexedMesh(): Mesh;
  21922. /**
  21923. * Inverses facet orientations.
  21924. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21925. * @param flipNormals will also inverts the normals
  21926. * @returns current mesh
  21927. */
  21928. flipFaces(flipNormals?: boolean): Mesh;
  21929. /**
  21930. * Increase the number of facets and hence vertices in a mesh
  21931. * Vertex normals are interpolated from existing vertex normals
  21932. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21933. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21934. */
  21935. increaseVertices(numberPerEdge: number): void;
  21936. /**
  21937. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21938. * This will undo any application of covertToFlatShadedMesh
  21939. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21940. */
  21941. forceSharedVertices(): void;
  21942. /** @hidden */
  21943. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21944. /** @hidden */
  21945. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21946. /**
  21947. * Creates a new InstancedMesh object from the mesh model.
  21948. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21949. * @param name defines the name of the new instance
  21950. * @returns a new InstancedMesh
  21951. */
  21952. createInstance(name: string): InstancedMesh;
  21953. /**
  21954. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21955. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21956. * @returns the current mesh
  21957. */
  21958. synchronizeInstances(): Mesh;
  21959. /**
  21960. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21961. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21962. * This should be used together with the simplification to avoid disappearing triangles.
  21963. * @param successCallback an optional success callback to be called after the optimization finished.
  21964. * @returns the current mesh
  21965. */
  21966. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21967. /**
  21968. * Serialize current mesh
  21969. * @param serializationObject defines the object which will receive the serialization data
  21970. */
  21971. serialize(serializationObject: any): void;
  21972. /** @hidden */
  21973. _syncGeometryWithMorphTargetManager(): void;
  21974. /** @hidden */
  21975. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21976. /**
  21977. * Returns a new Mesh object parsed from the source provided.
  21978. * @param parsedMesh is the source
  21979. * @param scene defines the hosting scene
  21980. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21981. * @returns a new Mesh
  21982. */
  21983. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21984. /**
  21985. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21986. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21987. * @param name defines the name of the mesh to create
  21988. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21989. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21990. * @param closePath creates a seam between the first and the last points of each path of the path array
  21991. * @param offset is taken in account only if the `pathArray` is containing a single path
  21992. * @param scene defines the hosting scene
  21993. * @param updatable defines if the mesh must be flagged as updatable
  21994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21995. * @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)
  21996. * @returns a new Mesh
  21997. */
  21998. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21999. /**
  22000. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22001. * @param name defines the name of the mesh to create
  22002. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22003. * @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
  22004. * @param scene defines the hosting scene
  22005. * @param updatable defines if the mesh must be flagged as updatable
  22006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22007. * @returns a new Mesh
  22008. */
  22009. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22010. /**
  22011. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22012. * @param name defines the name of the mesh to create
  22013. * @param size sets the size (float) of each box side (default 1)
  22014. * @param scene defines the hosting scene
  22015. * @param updatable defines if the mesh must be flagged as updatable
  22016. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22017. * @returns a new Mesh
  22018. */
  22019. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22020. /**
  22021. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22022. * @param name defines the name of the mesh to create
  22023. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22024. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22025. * @param scene defines the hosting scene
  22026. * @param updatable defines if the mesh must be flagged as updatable
  22027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22028. * @returns a new Mesh
  22029. */
  22030. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22031. /**
  22032. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22033. * @param name defines the name of the mesh to create
  22034. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22035. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22036. * @param scene defines the hosting scene
  22037. * @returns a new Mesh
  22038. */
  22039. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22040. /**
  22041. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22042. * @param name defines the name of the mesh to create
  22043. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22044. * @param diameterTop set the top cap diameter (floats, default 1)
  22045. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22046. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22047. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22048. * @param scene defines the hosting scene
  22049. * @param updatable defines if the mesh must be flagged as updatable
  22050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22051. * @returns a new Mesh
  22052. */
  22053. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22054. /**
  22055. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22056. * @param name defines the name of the mesh to create
  22057. * @param diameter sets the diameter size (float) of the torus (default 1)
  22058. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22059. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22060. * @param scene defines the hosting scene
  22061. * @param updatable defines if the mesh must be flagged as updatable
  22062. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22063. * @returns a new Mesh
  22064. */
  22065. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22066. /**
  22067. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22068. * @param name defines the name of the mesh to create
  22069. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22070. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22071. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22072. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22073. * @param p the number of windings on X axis (positive integers, default 2)
  22074. * @param q the number of windings on Y axis (positive integers, default 3)
  22075. * @param scene defines the hosting scene
  22076. * @param updatable defines if the mesh must be flagged as updatable
  22077. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22078. * @returns a new Mesh
  22079. */
  22080. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22081. /**
  22082. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22083. * @param name defines the name of the mesh to create
  22084. * @param points is an array successive Vector3
  22085. * @param scene defines the hosting scene
  22086. * @param updatable defines if the mesh must be flagged as updatable
  22087. * @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).
  22088. * @returns a new Mesh
  22089. */
  22090. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22091. /**
  22092. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22093. * @param name defines the name of the mesh to create
  22094. * @param points is an array successive Vector3
  22095. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22096. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22097. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22098. * @param scene defines the hosting scene
  22099. * @param updatable defines if the mesh must be flagged as updatable
  22100. * @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)
  22101. * @returns a new Mesh
  22102. */
  22103. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22104. /**
  22105. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22106. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22107. * 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.
  22108. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22109. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22110. * Remember you can only change the shape positions, not their number when updating a polygon.
  22111. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22112. * @param name defines the name of the mesh to create
  22113. * @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
  22114. * @param scene defines the hosting scene
  22115. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22116. * @param updatable defines if the mesh must be flagged as updatable
  22117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22118. * @param earcutInjection can be used to inject your own earcut reference
  22119. * @returns a new Mesh
  22120. */
  22121. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22122. /**
  22123. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22124. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22125. * @param name defines the name of the mesh to create
  22126. * @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
  22127. * @param depth defines the height of extrusion
  22128. * @param scene defines the hosting scene
  22129. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22130. * @param updatable defines if the mesh must be flagged as updatable
  22131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22132. * @param earcutInjection can be used to inject your own earcut reference
  22133. * @returns a new Mesh
  22134. */
  22135. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22136. /**
  22137. * Creates an extruded shape mesh.
  22138. * 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
  22139. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22140. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22141. * @param name defines the name of the mesh to create
  22142. * @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
  22143. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22144. * @param scale is the value to scale the shape
  22145. * @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
  22146. * @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
  22147. * @param scene defines the hosting scene
  22148. * @param updatable defines if the mesh must be flagged as updatable
  22149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22150. * @param instance 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)
  22151. * @returns a new Mesh
  22152. */
  22153. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22154. /**
  22155. * Creates an custom extruded shape mesh.
  22156. * The custom extrusion is a parametric shape.
  22157. * It has no predefined shape. Its final shape will depend on the input parameters.
  22158. * Please consider using the same method from the MeshBuilder class instead
  22159. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22160. * @param name defines the name of the mesh to create
  22161. * @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
  22162. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22163. * @param scaleFunction is a custom Javascript function called on each path point
  22164. * @param rotationFunction is a custom Javascript function called on each path point
  22165. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22166. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22167. * @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
  22168. * @param scene defines the hosting scene
  22169. * @param updatable defines if the mesh must be flagged as updatable
  22170. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22171. * @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)
  22172. * @returns a new Mesh
  22173. */
  22174. 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;
  22175. /**
  22176. * Creates lathe mesh.
  22177. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22178. * Please consider using the same method from the MeshBuilder class instead
  22179. * @param name defines the name of the mesh to create
  22180. * @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
  22181. * @param radius is the radius value of the lathe
  22182. * @param tessellation is the side number of the lathe.
  22183. * @param scene defines the hosting scene
  22184. * @param updatable defines if the mesh must be flagged as updatable
  22185. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22186. * @returns a new Mesh
  22187. */
  22188. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22189. /**
  22190. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22191. * @param name defines the name of the mesh to create
  22192. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22193. * @param scene defines the hosting scene
  22194. * @param updatable defines if the mesh must be flagged as updatable
  22195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22196. * @returns a new Mesh
  22197. */
  22198. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22199. /**
  22200. * Creates a ground mesh.
  22201. * Please consider using the same method from the MeshBuilder class instead
  22202. * @param name defines the name of the mesh to create
  22203. * @param width set the width of the ground
  22204. * @param height set the height of the ground
  22205. * @param subdivisions sets the number of subdivisions per side
  22206. * @param scene defines the hosting scene
  22207. * @param updatable defines if the mesh must be flagged as updatable
  22208. * @returns a new Mesh
  22209. */
  22210. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22211. /**
  22212. * Creates a tiled ground mesh.
  22213. * Please consider using the same method from the MeshBuilder class instead
  22214. * @param name defines the name of the mesh to create
  22215. * @param xmin set the ground minimum X coordinate
  22216. * @param zmin set the ground minimum Y coordinate
  22217. * @param xmax set the ground maximum X coordinate
  22218. * @param zmax set the ground maximum Z coordinate
  22219. * @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
  22220. * @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
  22221. * @param scene defines the hosting scene
  22222. * @param updatable defines if the mesh must be flagged as updatable
  22223. * @returns a new Mesh
  22224. */
  22225. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22226. w: number;
  22227. h: number;
  22228. }, precision: {
  22229. w: number;
  22230. h: number;
  22231. }, scene: Scene, updatable?: boolean): Mesh;
  22232. /**
  22233. * Creates a ground mesh from a height map.
  22234. * Please consider using the same method from the MeshBuilder class instead
  22235. * @see http://doc.babylonjs.com/babylon101/height_map
  22236. * @param name defines the name of the mesh to create
  22237. * @param url sets the URL of the height map image resource
  22238. * @param width set the ground width size
  22239. * @param height set the ground height size
  22240. * @param subdivisions sets the number of subdivision per side
  22241. * @param minHeight is the minimum altitude on the ground
  22242. * @param maxHeight is the maximum altitude on the ground
  22243. * @param scene defines the hosting scene
  22244. * @param updatable defines if the mesh must be flagged as updatable
  22245. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22246. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22247. * @returns a new Mesh
  22248. */
  22249. 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;
  22250. /**
  22251. * Creates a tube mesh.
  22252. * The tube is a parametric shape.
  22253. * It has no predefined shape. Its final shape will depend on the input parameters.
  22254. * Please consider using the same method from the MeshBuilder class instead
  22255. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22256. * @param name defines the name of the mesh to create
  22257. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22258. * @param radius sets the tube radius size
  22259. * @param tessellation is the number of sides on the tubular surface
  22260. * @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
  22261. * @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
  22262. * @param scene defines the hosting scene
  22263. * @param updatable defines if the mesh must be flagged as updatable
  22264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22265. * @param 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)
  22266. * @returns a new Mesh
  22267. */
  22268. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22269. (i: number, distance: number): number;
  22270. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22271. /**
  22272. * Creates a polyhedron mesh.
  22273. * Please consider using the same method from the MeshBuilder class instead.
  22274. * * 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
  22275. * * The parameter `size` (positive float, default 1) sets the polygon size
  22276. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22277. * * 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`
  22278. * * 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
  22279. * * 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)`)
  22280. * * 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
  22281. * * 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
  22282. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22283. * * If you create a double-sided mesh, you can choose what parts of 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
  22284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22285. * @param name defines the name of the mesh to create
  22286. * @param options defines the options used to create the mesh
  22287. * @param scene defines the hosting scene
  22288. * @returns a new Mesh
  22289. */
  22290. static CreatePolyhedron(name: string, options: {
  22291. type?: number;
  22292. size?: number;
  22293. sizeX?: number;
  22294. sizeY?: number;
  22295. sizeZ?: number;
  22296. custom?: any;
  22297. faceUV?: Vector4[];
  22298. faceColors?: Color4[];
  22299. updatable?: boolean;
  22300. sideOrientation?: number;
  22301. }, scene: Scene): Mesh;
  22302. /**
  22303. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22304. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22305. * * 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`)
  22306. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22307. * * 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
  22308. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22309. * * If you create a double-sided mesh, you can choose what parts of 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
  22310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22311. * @param name defines the name of the mesh
  22312. * @param options defines the options used to create the mesh
  22313. * @param scene defines the hosting scene
  22314. * @returns a new Mesh
  22315. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22316. */
  22317. static CreateIcoSphere(name: string, options: {
  22318. radius?: number;
  22319. flat?: boolean;
  22320. subdivisions?: number;
  22321. sideOrientation?: number;
  22322. updatable?: boolean;
  22323. }, scene: Scene): Mesh;
  22324. /**
  22325. * Creates a decal mesh.
  22326. * Please consider using the same method from the MeshBuilder class instead.
  22327. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22328. * @param name defines the name of the mesh
  22329. * @param sourceMesh defines the mesh receiving the decal
  22330. * @param position sets the position of the decal in world coordinates
  22331. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22332. * @param size sets the decal scaling
  22333. * @param angle sets the angle to rotate the decal
  22334. * @returns a new Mesh
  22335. */
  22336. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22337. /**
  22338. * Prepare internal position array for software CPU skinning
  22339. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22340. */
  22341. setPositionsForCPUSkinning(): Float32Array;
  22342. /**
  22343. * Prepare internal normal array for software CPU skinning
  22344. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22345. */
  22346. setNormalsForCPUSkinning(): Float32Array;
  22347. /**
  22348. * Updates the vertex buffer by applying transformation from the bones
  22349. * @param skeleton defines the skeleton to apply to current mesh
  22350. * @returns the current mesh
  22351. */
  22352. applySkeleton(skeleton: Skeleton): Mesh;
  22353. /**
  22354. * 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
  22355. * @param meshes defines the list of meshes to scan
  22356. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22357. */
  22358. static MinMax(meshes: AbstractMesh[]): {
  22359. min: Vector3;
  22360. max: Vector3;
  22361. };
  22362. /**
  22363. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22364. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22365. * @returns a vector3
  22366. */
  22367. static Center(meshesOrMinMaxVector: {
  22368. min: Vector3;
  22369. max: Vector3;
  22370. } | AbstractMesh[]): Vector3;
  22371. /**
  22372. * Merge the array of meshes into a single mesh for performance reasons.
  22373. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22374. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22375. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22376. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22377. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22378. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22379. * @returns a new mesh
  22380. */
  22381. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22382. /** @hidden */
  22383. addInstance(instance: InstancedMesh): void;
  22384. /** @hidden */
  22385. removeInstance(instance: InstancedMesh): void;
  22386. }
  22387. }
  22388. declare module "babylonjs/Materials/material" {
  22389. import { IAnimatable } from "babylonjs/Misc/tools";
  22390. import { SmartArray } from "babylonjs/Misc/smartArray";
  22391. import { Observable } from "babylonjs/Misc/observable";
  22392. import { Nullable } from "babylonjs/types";
  22393. import { Scene } from "babylonjs/scene";
  22394. import { Matrix } from "babylonjs/Maths/math";
  22395. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22397. import { Mesh } from "babylonjs/Meshes/mesh";
  22398. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22399. import { Effect } from "babylonjs/Materials/effect";
  22400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22401. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22402. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22403. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22404. import { Animation } from "babylonjs/Animations/animation";
  22405. /**
  22406. * Base class for the main features of a material in Babylon.js
  22407. */
  22408. export class Material implements IAnimatable {
  22409. /**
  22410. * Returns the triangle fill mode
  22411. */
  22412. static readonly TriangleFillMode: number;
  22413. /**
  22414. * Returns the wireframe mode
  22415. */
  22416. static readonly WireFrameFillMode: number;
  22417. /**
  22418. * Returns the point fill mode
  22419. */
  22420. static readonly PointFillMode: number;
  22421. /**
  22422. * Returns the point list draw mode
  22423. */
  22424. static readonly PointListDrawMode: number;
  22425. /**
  22426. * Returns the line list draw mode
  22427. */
  22428. static readonly LineListDrawMode: number;
  22429. /**
  22430. * Returns the line loop draw mode
  22431. */
  22432. static readonly LineLoopDrawMode: number;
  22433. /**
  22434. * Returns the line strip draw mode
  22435. */
  22436. static readonly LineStripDrawMode: number;
  22437. /**
  22438. * Returns the triangle strip draw mode
  22439. */
  22440. static readonly TriangleStripDrawMode: number;
  22441. /**
  22442. * Returns the triangle fan draw mode
  22443. */
  22444. static readonly TriangleFanDrawMode: number;
  22445. /**
  22446. * Stores the clock-wise side orientation
  22447. */
  22448. static readonly ClockWiseSideOrientation: number;
  22449. /**
  22450. * Stores the counter clock-wise side orientation
  22451. */
  22452. static readonly CounterClockWiseSideOrientation: number;
  22453. /**
  22454. * The dirty texture flag value
  22455. */
  22456. static readonly TextureDirtyFlag: number;
  22457. /**
  22458. * The dirty light flag value
  22459. */
  22460. static readonly LightDirtyFlag: number;
  22461. /**
  22462. * The dirty fresnel flag value
  22463. */
  22464. static readonly FresnelDirtyFlag: number;
  22465. /**
  22466. * The dirty attribute flag value
  22467. */
  22468. static readonly AttributesDirtyFlag: number;
  22469. /**
  22470. * The dirty misc flag value
  22471. */
  22472. static readonly MiscDirtyFlag: number;
  22473. /**
  22474. * The all dirty flag value
  22475. */
  22476. static readonly AllDirtyFlag: number;
  22477. /**
  22478. * The ID of the material
  22479. */
  22480. id: string;
  22481. /**
  22482. * Gets or sets the unique id of the material
  22483. */
  22484. uniqueId: number;
  22485. /**
  22486. * The name of the material
  22487. */
  22488. name: string;
  22489. /**
  22490. * Gets or sets user defined metadata
  22491. */
  22492. metadata: any;
  22493. /**
  22494. * For internal use only. Please do not use.
  22495. */
  22496. reservedDataStore: any;
  22497. /**
  22498. * Specifies if the ready state should be checked on each call
  22499. */
  22500. checkReadyOnEveryCall: boolean;
  22501. /**
  22502. * Specifies if the ready state should be checked once
  22503. */
  22504. checkReadyOnlyOnce: boolean;
  22505. /**
  22506. * The state of the material
  22507. */
  22508. state: string;
  22509. /**
  22510. * The alpha value of the material
  22511. */
  22512. protected _alpha: number;
  22513. /**
  22514. * List of inspectable custom properties (used by the Inspector)
  22515. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22516. */
  22517. inspectableCustomProperties: IInspectable[];
  22518. /**
  22519. * Sets the alpha value of the material
  22520. */
  22521. /**
  22522. * Gets the alpha value of the material
  22523. */
  22524. alpha: number;
  22525. /**
  22526. * Specifies if back face culling is enabled
  22527. */
  22528. protected _backFaceCulling: boolean;
  22529. /**
  22530. * Sets the back-face culling state
  22531. */
  22532. /**
  22533. * Gets the back-face culling state
  22534. */
  22535. backFaceCulling: boolean;
  22536. /**
  22537. * Stores the value for side orientation
  22538. */
  22539. sideOrientation: number;
  22540. /**
  22541. * Callback triggered when the material is compiled
  22542. */
  22543. onCompiled: Nullable<(effect: Effect) => void>;
  22544. /**
  22545. * Callback triggered when an error occurs
  22546. */
  22547. onError: Nullable<(effect: Effect, errors: string) => void>;
  22548. /**
  22549. * Callback triggered to get the render target textures
  22550. */
  22551. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22552. /**
  22553. * Gets a boolean indicating that current material needs to register RTT
  22554. */
  22555. readonly hasRenderTargetTextures: boolean;
  22556. /**
  22557. * Specifies if the material should be serialized
  22558. */
  22559. doNotSerialize: boolean;
  22560. /**
  22561. * @hidden
  22562. */
  22563. _storeEffectOnSubMeshes: boolean;
  22564. /**
  22565. * Stores the animations for the material
  22566. */
  22567. animations: Nullable<Array<Animation>>;
  22568. /**
  22569. * An event triggered when the material is disposed
  22570. */
  22571. onDisposeObservable: Observable<Material>;
  22572. /**
  22573. * An observer which watches for dispose events
  22574. */
  22575. private _onDisposeObserver;
  22576. private _onUnBindObservable;
  22577. /**
  22578. * Called during a dispose event
  22579. */
  22580. onDispose: () => void;
  22581. private _onBindObservable;
  22582. /**
  22583. * An event triggered when the material is bound
  22584. */
  22585. readonly onBindObservable: Observable<AbstractMesh>;
  22586. /**
  22587. * An observer which watches for bind events
  22588. */
  22589. private _onBindObserver;
  22590. /**
  22591. * Called during a bind event
  22592. */
  22593. onBind: (Mesh: AbstractMesh) => void;
  22594. /**
  22595. * An event triggered when the material is unbound
  22596. */
  22597. readonly onUnBindObservable: Observable<Material>;
  22598. /**
  22599. * Stores the value of the alpha mode
  22600. */
  22601. private _alphaMode;
  22602. /**
  22603. * Sets the value of the alpha mode.
  22604. *
  22605. * | Value | Type | Description |
  22606. * | --- | --- | --- |
  22607. * | 0 | ALPHA_DISABLE | |
  22608. * | 1 | ALPHA_ADD | |
  22609. * | 2 | ALPHA_COMBINE | |
  22610. * | 3 | ALPHA_SUBTRACT | |
  22611. * | 4 | ALPHA_MULTIPLY | |
  22612. * | 5 | ALPHA_MAXIMIZED | |
  22613. * | 6 | ALPHA_ONEONE | |
  22614. * | 7 | ALPHA_PREMULTIPLIED | |
  22615. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22616. * | 9 | ALPHA_INTERPOLATE | |
  22617. * | 10 | ALPHA_SCREENMODE | |
  22618. *
  22619. */
  22620. /**
  22621. * Gets the value of the alpha mode
  22622. */
  22623. alphaMode: number;
  22624. /**
  22625. * Stores the state of the need depth pre-pass value
  22626. */
  22627. private _needDepthPrePass;
  22628. /**
  22629. * Sets the need depth pre-pass value
  22630. */
  22631. /**
  22632. * Gets the depth pre-pass value
  22633. */
  22634. needDepthPrePass: boolean;
  22635. /**
  22636. * Specifies if depth writing should be disabled
  22637. */
  22638. disableDepthWrite: boolean;
  22639. /**
  22640. * Specifies if depth writing should be forced
  22641. */
  22642. forceDepthWrite: boolean;
  22643. /**
  22644. * Specifies if there should be a separate pass for culling
  22645. */
  22646. separateCullingPass: boolean;
  22647. /**
  22648. * Stores the state specifing if fog should be enabled
  22649. */
  22650. private _fogEnabled;
  22651. /**
  22652. * Sets the state for enabling fog
  22653. */
  22654. /**
  22655. * Gets the value of the fog enabled state
  22656. */
  22657. fogEnabled: boolean;
  22658. /**
  22659. * Stores the size of points
  22660. */
  22661. pointSize: number;
  22662. /**
  22663. * Stores the z offset value
  22664. */
  22665. zOffset: number;
  22666. /**
  22667. * Gets a value specifying if wireframe mode is enabled
  22668. */
  22669. /**
  22670. * Sets the state of wireframe mode
  22671. */
  22672. wireframe: boolean;
  22673. /**
  22674. * Gets the value specifying if point clouds are enabled
  22675. */
  22676. /**
  22677. * Sets the state of point cloud mode
  22678. */
  22679. pointsCloud: boolean;
  22680. /**
  22681. * Gets the material fill mode
  22682. */
  22683. /**
  22684. * Sets the material fill mode
  22685. */
  22686. fillMode: number;
  22687. /**
  22688. * @hidden
  22689. * Stores the effects for the material
  22690. */
  22691. _effect: Nullable<Effect>;
  22692. /**
  22693. * @hidden
  22694. * Specifies if the material was previously ready
  22695. */
  22696. _wasPreviouslyReady: boolean;
  22697. /**
  22698. * Specifies if uniform buffers should be used
  22699. */
  22700. private _useUBO;
  22701. /**
  22702. * Stores a reference to the scene
  22703. */
  22704. private _scene;
  22705. /**
  22706. * Stores the fill mode state
  22707. */
  22708. private _fillMode;
  22709. /**
  22710. * Specifies if the depth write state should be cached
  22711. */
  22712. private _cachedDepthWriteState;
  22713. /**
  22714. * Stores the uniform buffer
  22715. */
  22716. protected _uniformBuffer: UniformBuffer;
  22717. /** @hidden */
  22718. _indexInSceneMaterialArray: number;
  22719. /** @hidden */
  22720. meshMap: Nullable<{
  22721. [id: string]: AbstractMesh | undefined;
  22722. }>;
  22723. /**
  22724. * Creates a material instance
  22725. * @param name defines the name of the material
  22726. * @param scene defines the scene to reference
  22727. * @param doNotAdd specifies if the material should be added to the scene
  22728. */
  22729. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22730. /**
  22731. * Returns a string representation of the current material
  22732. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22733. * @returns a string with material information
  22734. */
  22735. toString(fullDetails?: boolean): string;
  22736. /**
  22737. * Gets the class name of the material
  22738. * @returns a string with the class name of the material
  22739. */
  22740. getClassName(): string;
  22741. /**
  22742. * Specifies if updates for the material been locked
  22743. */
  22744. readonly isFrozen: boolean;
  22745. /**
  22746. * Locks updates for the material
  22747. */
  22748. freeze(): void;
  22749. /**
  22750. * Unlocks updates for the material
  22751. */
  22752. unfreeze(): void;
  22753. /**
  22754. * Specifies if the material is ready to be used
  22755. * @param mesh defines the mesh to check
  22756. * @param useInstances specifies if instances should be used
  22757. * @returns a boolean indicating if the material is ready to be used
  22758. */
  22759. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22760. /**
  22761. * Specifies that the submesh is ready to be used
  22762. * @param mesh defines the mesh to check
  22763. * @param subMesh defines which submesh to check
  22764. * @param useInstances specifies that instances should be used
  22765. * @returns a boolean indicating that the submesh is ready or not
  22766. */
  22767. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22768. /**
  22769. * Returns the material effect
  22770. * @returns the effect associated with the material
  22771. */
  22772. getEffect(): Nullable<Effect>;
  22773. /**
  22774. * Returns the current scene
  22775. * @returns a Scene
  22776. */
  22777. getScene(): Scene;
  22778. /**
  22779. * Specifies if the material will require alpha blending
  22780. * @returns a boolean specifying if alpha blending is needed
  22781. */
  22782. needAlphaBlending(): boolean;
  22783. /**
  22784. * Specifies if the mesh will require alpha blending
  22785. * @param mesh defines the mesh to check
  22786. * @returns a boolean specifying if alpha blending is needed for the mesh
  22787. */
  22788. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22789. /**
  22790. * Specifies if this material should be rendered in alpha test mode
  22791. * @returns a boolean specifying if an alpha test is needed.
  22792. */
  22793. needAlphaTesting(): boolean;
  22794. /**
  22795. * Gets the texture used for the alpha test
  22796. * @returns the texture to use for alpha testing
  22797. */
  22798. getAlphaTestTexture(): Nullable<BaseTexture>;
  22799. /**
  22800. * Marks the material to indicate that it needs to be re-calculated
  22801. */
  22802. markDirty(): void;
  22803. /** @hidden */
  22804. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22805. /**
  22806. * Binds the material to the mesh
  22807. * @param world defines the world transformation matrix
  22808. * @param mesh defines the mesh to bind the material to
  22809. */
  22810. bind(world: Matrix, mesh?: Mesh): void;
  22811. /**
  22812. * Binds the submesh to the material
  22813. * @param world defines the world transformation matrix
  22814. * @param mesh defines the mesh containing the submesh
  22815. * @param subMesh defines the submesh to bind the material to
  22816. */
  22817. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22818. /**
  22819. * Binds the world matrix to the material
  22820. * @param world defines the world transformation matrix
  22821. */
  22822. bindOnlyWorldMatrix(world: Matrix): void;
  22823. /**
  22824. * Binds the scene's uniform buffer to the effect.
  22825. * @param effect defines the effect to bind to the scene uniform buffer
  22826. * @param sceneUbo defines the uniform buffer storing scene data
  22827. */
  22828. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22829. /**
  22830. * Binds the view matrix to the effect
  22831. * @param effect defines the effect to bind the view matrix to
  22832. */
  22833. bindView(effect: Effect): void;
  22834. /**
  22835. * Binds the view projection matrix to the effect
  22836. * @param effect defines the effect to bind the view projection matrix to
  22837. */
  22838. bindViewProjection(effect: Effect): void;
  22839. /**
  22840. * Specifies if material alpha testing should be turned on for the mesh
  22841. * @param mesh defines the mesh to check
  22842. */
  22843. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22844. /**
  22845. * Processes to execute after binding the material to a mesh
  22846. * @param mesh defines the rendered mesh
  22847. */
  22848. protected _afterBind(mesh?: Mesh): void;
  22849. /**
  22850. * Unbinds the material from the mesh
  22851. */
  22852. unbind(): void;
  22853. /**
  22854. * Gets the active textures from the material
  22855. * @returns an array of textures
  22856. */
  22857. getActiveTextures(): BaseTexture[];
  22858. /**
  22859. * Specifies if the material uses a texture
  22860. * @param texture defines the texture to check against the material
  22861. * @returns a boolean specifying if the material uses the texture
  22862. */
  22863. hasTexture(texture: BaseTexture): boolean;
  22864. /**
  22865. * Makes a duplicate of the material, and gives it a new name
  22866. * @param name defines the new name for the duplicated material
  22867. * @returns the cloned material
  22868. */
  22869. clone(name: string): Nullable<Material>;
  22870. /**
  22871. * Gets the meshes bound to the material
  22872. * @returns an array of meshes bound to the material
  22873. */
  22874. getBindedMeshes(): AbstractMesh[];
  22875. /**
  22876. * Force shader compilation
  22877. * @param mesh defines the mesh associated with this material
  22878. * @param onCompiled defines a function to execute once the material is compiled
  22879. * @param options defines the options to configure the compilation
  22880. */
  22881. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22882. clipPlane: boolean;
  22883. }>): void;
  22884. /**
  22885. * Force shader compilation
  22886. * @param mesh defines the mesh that will use this material
  22887. * @param options defines additional options for compiling the shaders
  22888. * @returns a promise that resolves when the compilation completes
  22889. */
  22890. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22891. clipPlane: boolean;
  22892. }>): Promise<void>;
  22893. private static readonly _ImageProcessingDirtyCallBack;
  22894. private static readonly _TextureDirtyCallBack;
  22895. private static readonly _FresnelDirtyCallBack;
  22896. private static readonly _MiscDirtyCallBack;
  22897. private static readonly _LightsDirtyCallBack;
  22898. private static readonly _AttributeDirtyCallBack;
  22899. private static _FresnelAndMiscDirtyCallBack;
  22900. private static _TextureAndMiscDirtyCallBack;
  22901. private static readonly _DirtyCallbackArray;
  22902. private static readonly _RunDirtyCallBacks;
  22903. /**
  22904. * Marks a define in the material to indicate that it needs to be re-computed
  22905. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22906. */
  22907. markAsDirty(flag: number): void;
  22908. /**
  22909. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22910. * @param func defines a function which checks material defines against the submeshes
  22911. */
  22912. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22913. /**
  22914. * Indicates that image processing needs to be re-calculated for all submeshes
  22915. */
  22916. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22917. /**
  22918. * Indicates that textures need to be re-calculated for all submeshes
  22919. */
  22920. protected _markAllSubMeshesAsTexturesDirty(): void;
  22921. /**
  22922. * Indicates that fresnel needs to be re-calculated for all submeshes
  22923. */
  22924. protected _markAllSubMeshesAsFresnelDirty(): void;
  22925. /**
  22926. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22927. */
  22928. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22929. /**
  22930. * Indicates that lights need to be re-calculated for all submeshes
  22931. */
  22932. protected _markAllSubMeshesAsLightsDirty(): void;
  22933. /**
  22934. * Indicates that attributes need to be re-calculated for all submeshes
  22935. */
  22936. protected _markAllSubMeshesAsAttributesDirty(): void;
  22937. /**
  22938. * Indicates that misc needs to be re-calculated for all submeshes
  22939. */
  22940. protected _markAllSubMeshesAsMiscDirty(): void;
  22941. /**
  22942. * Indicates that textures and misc need to be re-calculated for all submeshes
  22943. */
  22944. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22945. /**
  22946. * Disposes the material
  22947. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22948. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22949. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22950. */
  22951. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22952. /** @hidden */
  22953. private releaseVertexArrayObject;
  22954. /**
  22955. * Serializes this material
  22956. * @returns the serialized material object
  22957. */
  22958. serialize(): any;
  22959. /**
  22960. * Creates a material from parsed material data
  22961. * @param parsedMaterial defines parsed material data
  22962. * @param scene defines the hosting scene
  22963. * @param rootUrl defines the root URL to use to load textures
  22964. * @returns a new material
  22965. */
  22966. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22967. }
  22968. }
  22969. declare module "babylonjs/Meshes/subMesh" {
  22970. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22971. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22972. import { Engine } from "babylonjs/Engines/engine";
  22973. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22974. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22975. import { Effect } from "babylonjs/Materials/effect";
  22976. import { Collider } from "babylonjs/Collisions/collider";
  22977. import { Material } from "babylonjs/Materials/material";
  22978. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22980. import { Mesh } from "babylonjs/Meshes/mesh";
  22981. import { Ray } from "babylonjs/Culling/ray";
  22982. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22983. /**
  22984. * Base class for submeshes
  22985. */
  22986. export class BaseSubMesh {
  22987. /** @hidden */
  22988. _materialDefines: Nullable<MaterialDefines>;
  22989. /** @hidden */
  22990. _materialEffect: Nullable<Effect>;
  22991. /**
  22992. * Gets associated effect
  22993. */
  22994. readonly effect: Nullable<Effect>;
  22995. /**
  22996. * Sets associated effect (effect used to render this submesh)
  22997. * @param effect defines the effect to associate with
  22998. * @param defines defines the set of defines used to compile this effect
  22999. */
  23000. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23001. }
  23002. /**
  23003. * Defines a subdivision inside a mesh
  23004. */
  23005. export class SubMesh extends BaseSubMesh implements ICullable {
  23006. /** the material index to use */
  23007. materialIndex: number;
  23008. /** vertex index start */
  23009. verticesStart: number;
  23010. /** vertices count */
  23011. verticesCount: number;
  23012. /** index start */
  23013. indexStart: number;
  23014. /** indices count */
  23015. indexCount: number;
  23016. /** @hidden */
  23017. _linesIndexCount: number;
  23018. private _mesh;
  23019. private _renderingMesh;
  23020. private _boundingInfo;
  23021. private _linesIndexBuffer;
  23022. /** @hidden */
  23023. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23024. /** @hidden */
  23025. _trianglePlanes: Plane[];
  23026. /** @hidden */
  23027. _lastColliderTransformMatrix: Nullable<Matrix>;
  23028. /** @hidden */
  23029. _renderId: number;
  23030. /** @hidden */
  23031. _alphaIndex: number;
  23032. /** @hidden */
  23033. _distanceToCamera: number;
  23034. /** @hidden */
  23035. _id: number;
  23036. private _currentMaterial;
  23037. /**
  23038. * Add a new submesh to a mesh
  23039. * @param materialIndex defines the material index to use
  23040. * @param verticesStart defines vertex index start
  23041. * @param verticesCount defines vertices count
  23042. * @param indexStart defines index start
  23043. * @param indexCount defines indices count
  23044. * @param mesh defines the parent mesh
  23045. * @param renderingMesh defines an optional rendering mesh
  23046. * @param createBoundingBox defines if bounding box should be created for this submesh
  23047. * @returns the new submesh
  23048. */
  23049. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23050. /**
  23051. * Creates a new submesh
  23052. * @param materialIndex defines the material index to use
  23053. * @param verticesStart defines vertex index start
  23054. * @param verticesCount defines vertices count
  23055. * @param indexStart defines index start
  23056. * @param indexCount defines indices count
  23057. * @param mesh defines the parent mesh
  23058. * @param renderingMesh defines an optional rendering mesh
  23059. * @param createBoundingBox defines if bounding box should be created for this submesh
  23060. */
  23061. constructor(
  23062. /** the material index to use */
  23063. materialIndex: number,
  23064. /** vertex index start */
  23065. verticesStart: number,
  23066. /** vertices count */
  23067. verticesCount: number,
  23068. /** index start */
  23069. indexStart: number,
  23070. /** indices count */
  23071. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23072. /**
  23073. * Returns true if this submesh covers the entire parent mesh
  23074. * @ignorenaming
  23075. */
  23076. readonly IsGlobal: boolean;
  23077. /**
  23078. * Returns the submesh BoudingInfo object
  23079. * @returns current bounding info (or mesh's one if the submesh is global)
  23080. */
  23081. getBoundingInfo(): BoundingInfo;
  23082. /**
  23083. * Sets the submesh BoundingInfo
  23084. * @param boundingInfo defines the new bounding info to use
  23085. * @returns the SubMesh
  23086. */
  23087. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23088. /**
  23089. * Returns the mesh of the current submesh
  23090. * @return the parent mesh
  23091. */
  23092. getMesh(): AbstractMesh;
  23093. /**
  23094. * Returns the rendering mesh of the submesh
  23095. * @returns the rendering mesh (could be different from parent mesh)
  23096. */
  23097. getRenderingMesh(): Mesh;
  23098. /**
  23099. * Returns the submesh material
  23100. * @returns null or the current material
  23101. */
  23102. getMaterial(): Nullable<Material>;
  23103. /**
  23104. * Sets a new updated BoundingInfo object to the submesh
  23105. * @returns the SubMesh
  23106. */
  23107. refreshBoundingInfo(): SubMesh;
  23108. /** @hidden */
  23109. _checkCollision(collider: Collider): boolean;
  23110. /**
  23111. * Updates the submesh BoundingInfo
  23112. * @param world defines the world matrix to use to update the bounding info
  23113. * @returns the submesh
  23114. */
  23115. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23116. /**
  23117. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23118. * @param frustumPlanes defines the frustum planes
  23119. * @returns true if the submesh is intersecting with the frustum
  23120. */
  23121. isInFrustum(frustumPlanes: Plane[]): boolean;
  23122. /**
  23123. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23124. * @param frustumPlanes defines the frustum planes
  23125. * @returns true if the submesh is inside the frustum
  23126. */
  23127. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23128. /**
  23129. * Renders the submesh
  23130. * @param enableAlphaMode defines if alpha needs to be used
  23131. * @returns the submesh
  23132. */
  23133. render(enableAlphaMode: boolean): SubMesh;
  23134. /**
  23135. * @hidden
  23136. */
  23137. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23138. /**
  23139. * Checks if the submesh intersects with a ray
  23140. * @param ray defines the ray to test
  23141. * @returns true is the passed ray intersects the submesh bounding box
  23142. */
  23143. canIntersects(ray: Ray): boolean;
  23144. /**
  23145. * Intersects current submesh with a ray
  23146. * @param ray defines the ray to test
  23147. * @param positions defines mesh's positions array
  23148. * @param indices defines mesh's indices array
  23149. * @param fastCheck defines if only bounding info should be used
  23150. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23151. * @returns intersection info or null if no intersection
  23152. */
  23153. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23154. /** @hidden */
  23155. private _intersectLines;
  23156. /** @hidden */
  23157. private _intersectTriangles;
  23158. /** @hidden */
  23159. _rebuild(): void;
  23160. /**
  23161. * Creates a new submesh from the passed mesh
  23162. * @param newMesh defines the new hosting mesh
  23163. * @param newRenderingMesh defines an optional rendering mesh
  23164. * @returns the new submesh
  23165. */
  23166. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23167. /**
  23168. * Release associated resources
  23169. */
  23170. dispose(): void;
  23171. /**
  23172. * Gets the class name
  23173. * @returns the string "SubMesh".
  23174. */
  23175. getClassName(): string;
  23176. /**
  23177. * Creates a new submesh from indices data
  23178. * @param materialIndex the index of the main mesh material
  23179. * @param startIndex the index where to start the copy in the mesh indices array
  23180. * @param indexCount the number of indices to copy then from the startIndex
  23181. * @param mesh the main mesh to create the submesh from
  23182. * @param renderingMesh the optional rendering mesh
  23183. * @returns a new submesh
  23184. */
  23185. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23186. }
  23187. }
  23188. declare module "babylonjs/Meshes/geometry" {
  23189. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23190. import { Scene } from "babylonjs/scene";
  23191. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23192. import { Engine } from "babylonjs/Engines/engine";
  23193. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23194. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23195. import { Effect } from "babylonjs/Materials/effect";
  23196. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23197. import { Mesh } from "babylonjs/Meshes/mesh";
  23198. /**
  23199. * Class used to store geometry data (vertex buffers + index buffer)
  23200. */
  23201. export class Geometry implements IGetSetVerticesData {
  23202. /**
  23203. * Gets or sets the ID of the geometry
  23204. */
  23205. id: string;
  23206. /**
  23207. * Gets or sets the unique ID of the geometry
  23208. */
  23209. uniqueId: number;
  23210. /**
  23211. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23212. */
  23213. delayLoadState: number;
  23214. /**
  23215. * Gets the file containing the data to load when running in delay load state
  23216. */
  23217. delayLoadingFile: Nullable<string>;
  23218. /**
  23219. * Callback called when the geometry is updated
  23220. */
  23221. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23222. private _scene;
  23223. private _engine;
  23224. private _meshes;
  23225. private _totalVertices;
  23226. /** @hidden */
  23227. _indices: IndicesArray;
  23228. /** @hidden */
  23229. _vertexBuffers: {
  23230. [key: string]: VertexBuffer;
  23231. };
  23232. private _isDisposed;
  23233. private _extend;
  23234. private _boundingBias;
  23235. /** @hidden */
  23236. _delayInfo: Array<string>;
  23237. private _indexBuffer;
  23238. private _indexBufferIsUpdatable;
  23239. /** @hidden */
  23240. _boundingInfo: Nullable<BoundingInfo>;
  23241. /** @hidden */
  23242. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23243. /** @hidden */
  23244. _softwareSkinningFrameId: number;
  23245. private _vertexArrayObjects;
  23246. private _updatable;
  23247. /** @hidden */
  23248. _positions: Nullable<Vector3[]>;
  23249. /**
  23250. * 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
  23251. */
  23252. /**
  23253. * 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
  23254. */
  23255. boundingBias: Vector2;
  23256. /**
  23257. * Static function used to attach a new empty geometry to a mesh
  23258. * @param mesh defines the mesh to attach the geometry to
  23259. * @returns the new Geometry
  23260. */
  23261. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23262. /**
  23263. * Creates a new geometry
  23264. * @param id defines the unique ID
  23265. * @param scene defines the hosting scene
  23266. * @param vertexData defines the VertexData used to get geometry data
  23267. * @param updatable defines if geometry must be updatable (false by default)
  23268. * @param mesh defines the mesh that will be associated with the geometry
  23269. */
  23270. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23271. /**
  23272. * Gets the current extend of the geometry
  23273. */
  23274. readonly extend: {
  23275. minimum: Vector3;
  23276. maximum: Vector3;
  23277. };
  23278. /**
  23279. * Gets the hosting scene
  23280. * @returns the hosting Scene
  23281. */
  23282. getScene(): Scene;
  23283. /**
  23284. * Gets the hosting engine
  23285. * @returns the hosting Engine
  23286. */
  23287. getEngine(): Engine;
  23288. /**
  23289. * Defines if the geometry is ready to use
  23290. * @returns true if the geometry is ready to be used
  23291. */
  23292. isReady(): boolean;
  23293. /**
  23294. * Gets a value indicating that the geometry should not be serialized
  23295. */
  23296. readonly doNotSerialize: boolean;
  23297. /** @hidden */
  23298. _rebuild(): void;
  23299. /**
  23300. * Affects all geometry data in one call
  23301. * @param vertexData defines the geometry data
  23302. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23303. */
  23304. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23305. /**
  23306. * Set specific vertex data
  23307. * @param kind defines the data kind (Position, normal, etc...)
  23308. * @param data defines the vertex data to use
  23309. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23310. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23311. */
  23312. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23313. /**
  23314. * Removes a specific vertex data
  23315. * @param kind defines the data kind (Position, normal, etc...)
  23316. */
  23317. removeVerticesData(kind: string): void;
  23318. /**
  23319. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23320. * @param buffer defines the vertex buffer to use
  23321. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23322. */
  23323. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23324. /**
  23325. * Update a specific vertex buffer
  23326. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23327. * It will do nothing if the buffer is not updatable
  23328. * @param kind defines the data kind (Position, normal, etc...)
  23329. * @param data defines the data to use
  23330. * @param offset defines the offset in the target buffer where to store the data
  23331. * @param useBytes set to true if the offset is in bytes
  23332. */
  23333. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23334. /**
  23335. * Update a specific vertex buffer
  23336. * This function will create a new buffer if the current one is not updatable
  23337. * @param kind defines the data kind (Position, normal, etc...)
  23338. * @param data defines the data to use
  23339. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23340. */
  23341. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23342. private _updateBoundingInfo;
  23343. /** @hidden */
  23344. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23345. /**
  23346. * Gets total number of vertices
  23347. * @returns the total number of vertices
  23348. */
  23349. getTotalVertices(): number;
  23350. /**
  23351. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23352. * @param kind defines the data kind (Position, normal, etc...)
  23353. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23354. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23355. * @returns a float array containing vertex data
  23356. */
  23357. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23358. /**
  23359. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23360. * @param kind defines the data kind (Position, normal, etc...)
  23361. * @returns true if the vertex buffer with the specified kind is updatable
  23362. */
  23363. isVertexBufferUpdatable(kind: string): boolean;
  23364. /**
  23365. * Gets a specific vertex buffer
  23366. * @param kind defines the data kind (Position, normal, etc...)
  23367. * @returns a VertexBuffer
  23368. */
  23369. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23370. /**
  23371. * Returns all vertex buffers
  23372. * @return an object holding all vertex buffers indexed by kind
  23373. */
  23374. getVertexBuffers(): Nullable<{
  23375. [key: string]: VertexBuffer;
  23376. }>;
  23377. /**
  23378. * Gets a boolean indicating if specific vertex buffer is present
  23379. * @param kind defines the data kind (Position, normal, etc...)
  23380. * @returns true if data is present
  23381. */
  23382. isVerticesDataPresent(kind: string): boolean;
  23383. /**
  23384. * Gets a list of all attached data kinds (Position, normal, etc...)
  23385. * @returns a list of string containing all kinds
  23386. */
  23387. getVerticesDataKinds(): string[];
  23388. /**
  23389. * Update index buffer
  23390. * @param indices defines the indices to store in the index buffer
  23391. * @param offset defines the offset in the target buffer where to store the data
  23392. * @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)
  23393. */
  23394. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23395. /**
  23396. * Creates a new index buffer
  23397. * @param indices defines the indices to store in the index buffer
  23398. * @param totalVertices defines the total number of vertices (could be null)
  23399. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23400. */
  23401. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23402. /**
  23403. * Return the total number of indices
  23404. * @returns the total number of indices
  23405. */
  23406. getTotalIndices(): number;
  23407. /**
  23408. * Gets the index buffer array
  23409. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23410. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23411. * @returns the index buffer array
  23412. */
  23413. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23414. /**
  23415. * Gets the index buffer
  23416. * @return the index buffer
  23417. */
  23418. getIndexBuffer(): Nullable<WebGLBuffer>;
  23419. /** @hidden */
  23420. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23421. /**
  23422. * Release the associated resources for a specific mesh
  23423. * @param mesh defines the source mesh
  23424. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23425. */
  23426. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23427. /**
  23428. * Apply current geometry to a given mesh
  23429. * @param mesh defines the mesh to apply geometry to
  23430. */
  23431. applyToMesh(mesh: Mesh): void;
  23432. private _updateExtend;
  23433. private _applyToMesh;
  23434. private notifyUpdate;
  23435. /**
  23436. * Load the geometry if it was flagged as delay loaded
  23437. * @param scene defines the hosting scene
  23438. * @param onLoaded defines a callback called when the geometry is loaded
  23439. */
  23440. load(scene: Scene, onLoaded?: () => void): void;
  23441. private _queueLoad;
  23442. /**
  23443. * Invert the geometry to move from a right handed system to a left handed one.
  23444. */
  23445. toLeftHanded(): void;
  23446. /** @hidden */
  23447. _resetPointsArrayCache(): void;
  23448. /** @hidden */
  23449. _generatePointsArray(): boolean;
  23450. /**
  23451. * Gets a value indicating if the geometry is disposed
  23452. * @returns true if the geometry was disposed
  23453. */
  23454. isDisposed(): boolean;
  23455. private _disposeVertexArrayObjects;
  23456. /**
  23457. * Free all associated resources
  23458. */
  23459. dispose(): void;
  23460. /**
  23461. * Clone the current geometry into a new geometry
  23462. * @param id defines the unique ID of the new geometry
  23463. * @returns a new geometry object
  23464. */
  23465. copy(id: string): Geometry;
  23466. /**
  23467. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23468. * @return a JSON representation of the current geometry data (without the vertices data)
  23469. */
  23470. serialize(): any;
  23471. private toNumberArray;
  23472. /**
  23473. * Serialize all vertices data into a JSON oject
  23474. * @returns a JSON representation of the current geometry data
  23475. */
  23476. serializeVerticeData(): any;
  23477. /**
  23478. * Extracts a clone of a mesh geometry
  23479. * @param mesh defines the source mesh
  23480. * @param id defines the unique ID of the new geometry object
  23481. * @returns the new geometry object
  23482. */
  23483. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23484. /**
  23485. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23486. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23487. * Be aware Math.random() could cause collisions, but:
  23488. * "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"
  23489. * @returns a string containing a new GUID
  23490. */
  23491. static RandomId(): string;
  23492. /** @hidden */
  23493. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23494. private static _CleanMatricesWeights;
  23495. /**
  23496. * Create a new geometry from persisted data (Using .babylon file format)
  23497. * @param parsedVertexData defines the persisted data
  23498. * @param scene defines the hosting scene
  23499. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23500. * @returns the new geometry object
  23501. */
  23502. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23503. }
  23504. }
  23505. declare module "babylonjs/Meshes/mesh.vertexData" {
  23506. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23507. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23508. import { Geometry } from "babylonjs/Meshes/geometry";
  23509. import { Mesh } from "babylonjs/Meshes/mesh";
  23510. /**
  23511. * Define an interface for all classes that will get and set the data on vertices
  23512. */
  23513. export interface IGetSetVerticesData {
  23514. /**
  23515. * Gets a boolean indicating if specific vertex data is present
  23516. * @param kind defines the vertex data kind to use
  23517. * @returns true is data kind is present
  23518. */
  23519. isVerticesDataPresent(kind: string): boolean;
  23520. /**
  23521. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23522. * @param kind defines the data kind (Position, normal, etc...)
  23523. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23524. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23525. * @returns a float array containing vertex data
  23526. */
  23527. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23528. /**
  23529. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23530. * @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.
  23531. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23532. * @returns the indices array or an empty array if the mesh has no geometry
  23533. */
  23534. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23535. /**
  23536. * Set specific vertex data
  23537. * @param kind defines the data kind (Position, normal, etc...)
  23538. * @param data defines the vertex data to use
  23539. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23540. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23541. */
  23542. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23543. /**
  23544. * Update a specific associated vertex buffer
  23545. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23546. * - VertexBuffer.PositionKind
  23547. * - VertexBuffer.UVKind
  23548. * - VertexBuffer.UV2Kind
  23549. * - VertexBuffer.UV3Kind
  23550. * - VertexBuffer.UV4Kind
  23551. * - VertexBuffer.UV5Kind
  23552. * - VertexBuffer.UV6Kind
  23553. * - VertexBuffer.ColorKind
  23554. * - VertexBuffer.MatricesIndicesKind
  23555. * - VertexBuffer.MatricesIndicesExtraKind
  23556. * - VertexBuffer.MatricesWeightsKind
  23557. * - VertexBuffer.MatricesWeightsExtraKind
  23558. * @param data defines the data source
  23559. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23560. * @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)
  23561. */
  23562. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23563. /**
  23564. * Creates a new index buffer
  23565. * @param indices defines the indices to store in the index buffer
  23566. * @param totalVertices defines the total number of vertices (could be null)
  23567. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23568. */
  23569. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23570. }
  23571. /**
  23572. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23573. */
  23574. export class VertexData {
  23575. /**
  23576. * Mesh side orientation : usually the external or front surface
  23577. */
  23578. static readonly FRONTSIDE: number;
  23579. /**
  23580. * Mesh side orientation : usually the internal or back surface
  23581. */
  23582. static readonly BACKSIDE: number;
  23583. /**
  23584. * Mesh side orientation : both internal and external or front and back surfaces
  23585. */
  23586. static readonly DOUBLESIDE: number;
  23587. /**
  23588. * Mesh side orientation : by default, `FRONTSIDE`
  23589. */
  23590. static readonly DEFAULTSIDE: number;
  23591. /**
  23592. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23593. */
  23594. positions: Nullable<FloatArray>;
  23595. /**
  23596. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23597. */
  23598. normals: Nullable<FloatArray>;
  23599. /**
  23600. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23601. */
  23602. tangents: Nullable<FloatArray>;
  23603. /**
  23604. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23605. */
  23606. uvs: Nullable<FloatArray>;
  23607. /**
  23608. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23609. */
  23610. uvs2: Nullable<FloatArray>;
  23611. /**
  23612. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23613. */
  23614. uvs3: Nullable<FloatArray>;
  23615. /**
  23616. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23617. */
  23618. uvs4: Nullable<FloatArray>;
  23619. /**
  23620. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23621. */
  23622. uvs5: Nullable<FloatArray>;
  23623. /**
  23624. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23625. */
  23626. uvs6: Nullable<FloatArray>;
  23627. /**
  23628. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23629. */
  23630. colors: Nullable<FloatArray>;
  23631. /**
  23632. * 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).
  23633. */
  23634. matricesIndices: Nullable<FloatArray>;
  23635. /**
  23636. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23637. */
  23638. matricesWeights: Nullable<FloatArray>;
  23639. /**
  23640. * An array extending the number of possible indices
  23641. */
  23642. matricesIndicesExtra: Nullable<FloatArray>;
  23643. /**
  23644. * An array extending the number of possible weights when the number of indices is extended
  23645. */
  23646. matricesWeightsExtra: Nullable<FloatArray>;
  23647. /**
  23648. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23649. */
  23650. indices: Nullable<IndicesArray>;
  23651. /**
  23652. * Uses the passed data array to set the set the values for the specified kind of data
  23653. * @param data a linear array of floating numbers
  23654. * @param kind the type of data that is being set, eg positions, colors etc
  23655. */
  23656. set(data: FloatArray, kind: string): void;
  23657. /**
  23658. * Associates the vertexData to the passed Mesh.
  23659. * Sets it as updatable or not (default `false`)
  23660. * @param mesh the mesh the vertexData is applied to
  23661. * @param updatable when used and having the value true allows new data to update the vertexData
  23662. * @returns the VertexData
  23663. */
  23664. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23665. /**
  23666. * Associates the vertexData to the passed Geometry.
  23667. * Sets it as updatable or not (default `false`)
  23668. * @param geometry the geometry the vertexData is applied to
  23669. * @param updatable when used and having the value true allows new data to update the vertexData
  23670. * @returns VertexData
  23671. */
  23672. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23673. /**
  23674. * Updates the associated mesh
  23675. * @param mesh the mesh to be updated
  23676. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23677. * @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
  23678. * @returns VertexData
  23679. */
  23680. updateMesh(mesh: Mesh): VertexData;
  23681. /**
  23682. * Updates the associated geometry
  23683. * @param geometry the geometry to be updated
  23684. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23685. * @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
  23686. * @returns VertexData.
  23687. */
  23688. updateGeometry(geometry: Geometry): VertexData;
  23689. private _applyTo;
  23690. private _update;
  23691. /**
  23692. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23693. * @param matrix the transforming matrix
  23694. * @returns the VertexData
  23695. */
  23696. transform(matrix: Matrix): VertexData;
  23697. /**
  23698. * Merges the passed VertexData into the current one
  23699. * @param other the VertexData to be merged into the current one
  23700. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23701. * @returns the modified VertexData
  23702. */
  23703. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23704. private _mergeElement;
  23705. private _validate;
  23706. /**
  23707. * Serializes the VertexData
  23708. * @returns a serialized object
  23709. */
  23710. serialize(): any;
  23711. /**
  23712. * Extracts the vertexData from a mesh
  23713. * @param mesh the mesh from which to extract the VertexData
  23714. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23715. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23716. * @returns the object VertexData associated to the passed mesh
  23717. */
  23718. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23719. /**
  23720. * Extracts the vertexData from the geometry
  23721. * @param geometry the geometry from which to extract the VertexData
  23722. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23723. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23724. * @returns the object VertexData associated to the passed mesh
  23725. */
  23726. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23727. private static _ExtractFrom;
  23728. /**
  23729. * Creates the VertexData for a Ribbon
  23730. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23731. * * pathArray array of paths, each of which an array of successive Vector3
  23732. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23733. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23734. * * 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
  23735. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23736. * * 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)
  23737. * * 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)
  23738. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23739. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23740. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23741. * @returns the VertexData of the ribbon
  23742. */
  23743. static CreateRibbon(options: {
  23744. pathArray: Vector3[][];
  23745. closeArray?: boolean;
  23746. closePath?: boolean;
  23747. offset?: number;
  23748. sideOrientation?: number;
  23749. frontUVs?: Vector4;
  23750. backUVs?: Vector4;
  23751. invertUV?: boolean;
  23752. uvs?: Vector2[];
  23753. colors?: Color4[];
  23754. }): VertexData;
  23755. /**
  23756. * Creates the VertexData for a box
  23757. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23758. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23759. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23760. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23761. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23762. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23763. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23764. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23765. * * 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)
  23766. * * 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)
  23767. * @returns the VertexData of the box
  23768. */
  23769. static CreateBox(options: {
  23770. size?: number;
  23771. width?: number;
  23772. height?: number;
  23773. depth?: number;
  23774. faceUV?: Vector4[];
  23775. faceColors?: Color4[];
  23776. sideOrientation?: number;
  23777. frontUVs?: Vector4;
  23778. backUVs?: Vector4;
  23779. }): VertexData;
  23780. /**
  23781. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23782. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23783. * * segments sets the number of horizontal strips optional, default 32
  23784. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23785. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23786. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23787. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23788. * * 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
  23789. * * 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
  23790. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23791. * * 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)
  23792. * * 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)
  23793. * @returns the VertexData of the ellipsoid
  23794. */
  23795. static CreateSphere(options: {
  23796. segments?: number;
  23797. diameter?: number;
  23798. diameterX?: number;
  23799. diameterY?: number;
  23800. diameterZ?: number;
  23801. arc?: number;
  23802. slice?: number;
  23803. sideOrientation?: number;
  23804. frontUVs?: Vector4;
  23805. backUVs?: Vector4;
  23806. }): VertexData;
  23807. /**
  23808. * Creates the VertexData for a cylinder, cone or prism
  23809. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23810. * * height sets the height (y direction) of the cylinder, optional, default 2
  23811. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23812. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23813. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23814. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23815. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23816. * * 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
  23817. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23818. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23819. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23820. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23821. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23822. * * 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)
  23823. * * 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)
  23824. * @returns the VertexData of the cylinder, cone or prism
  23825. */
  23826. static CreateCylinder(options: {
  23827. height?: number;
  23828. diameterTop?: number;
  23829. diameterBottom?: number;
  23830. diameter?: number;
  23831. tessellation?: number;
  23832. subdivisions?: number;
  23833. arc?: number;
  23834. faceColors?: Color4[];
  23835. faceUV?: Vector4[];
  23836. hasRings?: boolean;
  23837. enclose?: boolean;
  23838. sideOrientation?: number;
  23839. frontUVs?: Vector4;
  23840. backUVs?: Vector4;
  23841. }): VertexData;
  23842. /**
  23843. * Creates the VertexData for a torus
  23844. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23845. * * diameter the diameter of the torus, optional default 1
  23846. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23847. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23848. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23849. * * 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)
  23850. * * 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)
  23851. * @returns the VertexData of the torus
  23852. */
  23853. static CreateTorus(options: {
  23854. diameter?: number;
  23855. thickness?: number;
  23856. tessellation?: number;
  23857. sideOrientation?: number;
  23858. frontUVs?: Vector4;
  23859. backUVs?: Vector4;
  23860. }): VertexData;
  23861. /**
  23862. * Creates the VertexData of the LineSystem
  23863. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23864. * - lines an array of lines, each line being an array of successive Vector3
  23865. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23866. * @returns the VertexData of the LineSystem
  23867. */
  23868. static CreateLineSystem(options: {
  23869. lines: Vector3[][];
  23870. colors?: Nullable<Color4[][]>;
  23871. }): VertexData;
  23872. /**
  23873. * Create the VertexData for a DashedLines
  23874. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23875. * - points an array successive Vector3
  23876. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23877. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23878. * - dashNb the intended total number of dashes, optional, default 200
  23879. * @returns the VertexData for the DashedLines
  23880. */
  23881. static CreateDashedLines(options: {
  23882. points: Vector3[];
  23883. dashSize?: number;
  23884. gapSize?: number;
  23885. dashNb?: number;
  23886. }): VertexData;
  23887. /**
  23888. * Creates the VertexData for a Ground
  23889. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23890. * - width the width (x direction) of the ground, optional, default 1
  23891. * - height the height (z direction) of the ground, optional, default 1
  23892. * - subdivisions the number of subdivisions per side, optional, default 1
  23893. * @returns the VertexData of the Ground
  23894. */
  23895. static CreateGround(options: {
  23896. width?: number;
  23897. height?: number;
  23898. subdivisions?: number;
  23899. subdivisionsX?: number;
  23900. subdivisionsY?: number;
  23901. }): VertexData;
  23902. /**
  23903. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23904. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23905. * * xmin the ground minimum X coordinate, optional, default -1
  23906. * * zmin the ground minimum Z coordinate, optional, default -1
  23907. * * xmax the ground maximum X coordinate, optional, default 1
  23908. * * zmax the ground maximum Z coordinate, optional, default 1
  23909. * * 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}
  23910. * * 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}
  23911. * @returns the VertexData of the TiledGround
  23912. */
  23913. static CreateTiledGround(options: {
  23914. xmin: number;
  23915. zmin: number;
  23916. xmax: number;
  23917. zmax: number;
  23918. subdivisions?: {
  23919. w: number;
  23920. h: number;
  23921. };
  23922. precision?: {
  23923. w: number;
  23924. h: number;
  23925. };
  23926. }): VertexData;
  23927. /**
  23928. * Creates the VertexData of the Ground designed from a heightmap
  23929. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23930. * * width the width (x direction) of the ground
  23931. * * height the height (z direction) of the ground
  23932. * * subdivisions the number of subdivisions per side
  23933. * * minHeight the minimum altitude on the ground, optional, default 0
  23934. * * maxHeight the maximum altitude on the ground, optional default 1
  23935. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23936. * * buffer the array holding the image color data
  23937. * * bufferWidth the width of image
  23938. * * bufferHeight the height of image
  23939. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23940. * @returns the VertexData of the Ground designed from a heightmap
  23941. */
  23942. static CreateGroundFromHeightMap(options: {
  23943. width: number;
  23944. height: number;
  23945. subdivisions: number;
  23946. minHeight: number;
  23947. maxHeight: number;
  23948. colorFilter: Color3;
  23949. buffer: Uint8Array;
  23950. bufferWidth: number;
  23951. bufferHeight: number;
  23952. alphaFilter: number;
  23953. }): VertexData;
  23954. /**
  23955. * Creates the VertexData for a Plane
  23956. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23957. * * size sets the width and height of the plane to the value of size, optional default 1
  23958. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23959. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23960. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23961. * * 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)
  23962. * * 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)
  23963. * @returns the VertexData of the box
  23964. */
  23965. static CreatePlane(options: {
  23966. size?: number;
  23967. width?: number;
  23968. height?: number;
  23969. sideOrientation?: number;
  23970. frontUVs?: Vector4;
  23971. backUVs?: Vector4;
  23972. }): VertexData;
  23973. /**
  23974. * Creates the VertexData of the Disc or regular Polygon
  23975. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23976. * * radius the radius of the disc, optional default 0.5
  23977. * * tessellation the number of polygon sides, optional, default 64
  23978. * * 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
  23979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23980. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23981. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23982. * @returns the VertexData of the box
  23983. */
  23984. static CreateDisc(options: {
  23985. radius?: number;
  23986. tessellation?: number;
  23987. arc?: number;
  23988. sideOrientation?: number;
  23989. frontUVs?: Vector4;
  23990. backUVs?: Vector4;
  23991. }): VertexData;
  23992. /**
  23993. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23994. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23995. * @param polygon a mesh built from polygonTriangulation.build()
  23996. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23997. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23998. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23999. * @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)
  24000. * @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)
  24001. * @returns the VertexData of the Polygon
  24002. */
  24003. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24004. /**
  24005. * Creates the VertexData of the IcoSphere
  24006. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24007. * * radius the radius of the IcoSphere, optional default 1
  24008. * * radiusX allows stretching in the x direction, optional, default radius
  24009. * * radiusY allows stretching in the y direction, optional, default radius
  24010. * * radiusZ allows stretching in the z direction, optional, default radius
  24011. * * flat when true creates a flat shaded mesh, optional, default true
  24012. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24014. * * 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)
  24015. * * 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)
  24016. * @returns the VertexData of the IcoSphere
  24017. */
  24018. static CreateIcoSphere(options: {
  24019. radius?: number;
  24020. radiusX?: number;
  24021. radiusY?: number;
  24022. radiusZ?: number;
  24023. flat?: boolean;
  24024. subdivisions?: number;
  24025. sideOrientation?: number;
  24026. frontUVs?: Vector4;
  24027. backUVs?: Vector4;
  24028. }): VertexData;
  24029. /**
  24030. * Creates the VertexData for a Polyhedron
  24031. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24032. * * type provided types are:
  24033. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24034. * * 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)
  24035. * * size the size of the IcoSphere, optional default 1
  24036. * * sizeX allows stretching in the x direction, optional, default size
  24037. * * sizeY allows stretching in the y direction, optional, default size
  24038. * * sizeZ allows stretching in the z direction, optional, default size
  24039. * * 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
  24040. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24041. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24042. * * flat when true creates a flat shaded mesh, optional, default true
  24043. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24044. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24045. * * 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)
  24046. * * 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)
  24047. * @returns the VertexData of the Polyhedron
  24048. */
  24049. static CreatePolyhedron(options: {
  24050. type?: number;
  24051. size?: number;
  24052. sizeX?: number;
  24053. sizeY?: number;
  24054. sizeZ?: number;
  24055. custom?: any;
  24056. faceUV?: Vector4[];
  24057. faceColors?: Color4[];
  24058. flat?: boolean;
  24059. sideOrientation?: number;
  24060. frontUVs?: Vector4;
  24061. backUVs?: Vector4;
  24062. }): VertexData;
  24063. /**
  24064. * Creates the VertexData for a TorusKnot
  24065. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24066. * * radius the radius of the torus knot, optional, default 2
  24067. * * tube the thickness of the tube, optional, default 0.5
  24068. * * radialSegments the number of sides on each tube segments, optional, default 32
  24069. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24070. * * p the number of windings around the z axis, optional, default 2
  24071. * * q the number of windings around the x axis, optional, default 3
  24072. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24073. * * 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)
  24074. * * 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)
  24075. * @returns the VertexData of the Torus Knot
  24076. */
  24077. static CreateTorusKnot(options: {
  24078. radius?: number;
  24079. tube?: number;
  24080. radialSegments?: number;
  24081. tubularSegments?: number;
  24082. p?: number;
  24083. q?: number;
  24084. sideOrientation?: number;
  24085. frontUVs?: Vector4;
  24086. backUVs?: Vector4;
  24087. }): VertexData;
  24088. /**
  24089. * Compute normals for given positions and indices
  24090. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24091. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24092. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24093. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24094. * * facetNormals : optional array of facet normals (vector3)
  24095. * * facetPositions : optional array of facet positions (vector3)
  24096. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24097. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24098. * * bInfo : optional bounding info, required for facetPartitioning computation
  24099. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24100. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24101. * * useRightHandedSystem: optional boolean to for right handed system computation
  24102. * * depthSort : optional boolean to enable the facet depth sort computation
  24103. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24104. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24105. */
  24106. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24107. facetNormals?: any;
  24108. facetPositions?: any;
  24109. facetPartitioning?: any;
  24110. ratio?: number;
  24111. bInfo?: any;
  24112. bbSize?: Vector3;
  24113. subDiv?: any;
  24114. useRightHandedSystem?: boolean;
  24115. depthSort?: boolean;
  24116. distanceTo?: Vector3;
  24117. depthSortedFacets?: any;
  24118. }): void;
  24119. /** @hidden */
  24120. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24121. /**
  24122. * Applies VertexData created from the imported parameters to the geometry
  24123. * @param parsedVertexData the parsed data from an imported file
  24124. * @param geometry the geometry to apply the VertexData to
  24125. */
  24126. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24127. }
  24128. }
  24129. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24130. import { Nullable } from "babylonjs/types";
  24131. import { Scene } from "babylonjs/scene";
  24132. import { Vector4 } from "babylonjs/Maths/math";
  24133. import { Mesh } from "babylonjs/Meshes/mesh";
  24134. /**
  24135. * Class containing static functions to help procedurally build meshes
  24136. */
  24137. export class DiscBuilder {
  24138. /**
  24139. * Creates a plane polygonal mesh. By default, this is a disc
  24140. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24141. * * 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
  24142. * * 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
  24143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24146. * @param name defines the name of the mesh
  24147. * @param options defines the options used to create the mesh
  24148. * @param scene defines the hosting scene
  24149. * @returns the plane polygonal mesh
  24150. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24151. */
  24152. static CreateDisc(name: string, options: {
  24153. radius?: number;
  24154. tessellation?: number;
  24155. arc?: number;
  24156. updatable?: boolean;
  24157. sideOrientation?: number;
  24158. frontUVs?: Vector4;
  24159. backUVs?: Vector4;
  24160. }, scene?: Nullable<Scene>): Mesh;
  24161. }
  24162. }
  24163. declare module "babylonjs/Particles/solidParticleSystem" {
  24164. import { Vector3 } from "babylonjs/Maths/math";
  24165. import { Mesh } from "babylonjs/Meshes/mesh";
  24166. import { Scene, IDisposable } from "babylonjs/scene";
  24167. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24168. /**
  24169. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24170. *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.
  24171. * The SPS is also a particle system. It provides some methods to manage the particles.
  24172. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24173. *
  24174. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24175. */
  24176. export class SolidParticleSystem implements IDisposable {
  24177. /**
  24178. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24179. * Example : var p = SPS.particles[i];
  24180. */
  24181. particles: SolidParticle[];
  24182. /**
  24183. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24184. */
  24185. nbParticles: number;
  24186. /**
  24187. * If the particles must ever face the camera (default false). Useful for planar particles.
  24188. */
  24189. billboard: boolean;
  24190. /**
  24191. * Recompute normals when adding a shape
  24192. */
  24193. recomputeNormals: boolean;
  24194. /**
  24195. * This a counter ofr your own usage. It's not set by any SPS functions.
  24196. */
  24197. counter: number;
  24198. /**
  24199. * The SPS name. This name is also given to the underlying mesh.
  24200. */
  24201. name: string;
  24202. /**
  24203. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24204. */
  24205. mesh: Mesh;
  24206. /**
  24207. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24208. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24209. */
  24210. vars: any;
  24211. /**
  24212. * This array is populated when the SPS is set as 'pickable'.
  24213. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24214. * Each element of this array is an object `{idx: int, faceId: int}`.
  24215. * `idx` is the picked particle index in the `SPS.particles` array
  24216. * `faceId` is the picked face index counted within this particle.
  24217. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24218. */
  24219. pickedParticles: {
  24220. idx: number;
  24221. faceId: number;
  24222. }[];
  24223. /**
  24224. * This array is populated when `enableDepthSort` is set to true.
  24225. * Each element of this array is an instance of the class DepthSortedParticle.
  24226. */
  24227. depthSortedParticles: DepthSortedParticle[];
  24228. /**
  24229. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24230. * @hidden
  24231. */
  24232. _bSphereOnly: boolean;
  24233. /**
  24234. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24235. * @hidden
  24236. */
  24237. _bSphereRadiusFactor: number;
  24238. private _scene;
  24239. private _positions;
  24240. private _indices;
  24241. private _normals;
  24242. private _colors;
  24243. private _uvs;
  24244. private _indices32;
  24245. private _positions32;
  24246. private _normals32;
  24247. private _fixedNormal32;
  24248. private _colors32;
  24249. private _uvs32;
  24250. private _index;
  24251. private _updatable;
  24252. private _pickable;
  24253. private _isVisibilityBoxLocked;
  24254. private _alwaysVisible;
  24255. private _depthSort;
  24256. private _shapeCounter;
  24257. private _copy;
  24258. private _color;
  24259. private _computeParticleColor;
  24260. private _computeParticleTexture;
  24261. private _computeParticleRotation;
  24262. private _computeParticleVertex;
  24263. private _computeBoundingBox;
  24264. private _depthSortParticles;
  24265. private _camera;
  24266. private _mustUnrotateFixedNormals;
  24267. private _particlesIntersect;
  24268. private _needs32Bits;
  24269. /**
  24270. * Creates a SPS (Solid Particle System) object.
  24271. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24272. * @param scene (Scene) is the scene in which the SPS is added.
  24273. * @param options defines the options of the sps e.g.
  24274. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24275. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24276. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24277. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24278. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24279. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24280. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24281. */
  24282. constructor(name: string, scene: Scene, options?: {
  24283. updatable?: boolean;
  24284. isPickable?: boolean;
  24285. enableDepthSort?: boolean;
  24286. particleIntersection?: boolean;
  24287. boundingSphereOnly?: boolean;
  24288. bSphereRadiusFactor?: number;
  24289. });
  24290. /**
  24291. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24292. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24293. * @returns the created mesh
  24294. */
  24295. buildMesh(): Mesh;
  24296. /**
  24297. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24298. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24299. * Thus the particles generated from `digest()` have their property `position` set yet.
  24300. * @param mesh ( Mesh ) is the mesh to be digested
  24301. * @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
  24302. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24303. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24304. * @returns the current SPS
  24305. */
  24306. digest(mesh: Mesh, options?: {
  24307. facetNb?: number;
  24308. number?: number;
  24309. delta?: number;
  24310. }): SolidParticleSystem;
  24311. private _unrotateFixedNormals;
  24312. private _resetCopy;
  24313. private _meshBuilder;
  24314. private _posToShape;
  24315. private _uvsToShapeUV;
  24316. private _addParticle;
  24317. /**
  24318. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24319. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24320. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24321. * @param nb (positive integer) the number of particles to be created from this model
  24322. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24323. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24324. * @returns the number of shapes in the system
  24325. */
  24326. addShape(mesh: Mesh, nb: number, options?: {
  24327. positionFunction?: any;
  24328. vertexFunction?: any;
  24329. }): number;
  24330. private _rebuildParticle;
  24331. /**
  24332. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24333. * @returns the SPS.
  24334. */
  24335. rebuildMesh(): SolidParticleSystem;
  24336. /**
  24337. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24338. * This method calls `updateParticle()` for each particle of the SPS.
  24339. * For an animated SPS, it is usually called within the render loop.
  24340. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24341. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24342. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24343. * @returns the SPS.
  24344. */
  24345. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24346. /**
  24347. * Disposes the SPS.
  24348. */
  24349. dispose(): void;
  24350. /**
  24351. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24352. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24353. * @returns the SPS.
  24354. */
  24355. refreshVisibleSize(): SolidParticleSystem;
  24356. /**
  24357. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24358. * @param size the size (float) of the visibility box
  24359. * note : this doesn't lock the SPS mesh bounding box.
  24360. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24361. */
  24362. setVisibilityBox(size: number): void;
  24363. /**
  24364. * Gets whether the SPS as always visible or not
  24365. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24366. */
  24367. /**
  24368. * Sets the SPS as always visible or not
  24369. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24370. */
  24371. isAlwaysVisible: boolean;
  24372. /**
  24373. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24374. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24375. */
  24376. /**
  24377. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24378. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24379. */
  24380. isVisibilityBoxLocked: boolean;
  24381. /**
  24382. * Tells to `setParticles()` to compute the particle rotations or not.
  24383. * Default value : true. The SPS is faster when it's set to false.
  24384. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24385. */
  24386. /**
  24387. * Gets if `setParticles()` computes the particle rotations or not.
  24388. * Default value : true. The SPS is faster when it's set to false.
  24389. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24390. */
  24391. computeParticleRotation: boolean;
  24392. /**
  24393. * Tells to `setParticles()` to compute the particle colors or not.
  24394. * Default value : true. The SPS is faster when it's set to false.
  24395. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24396. */
  24397. /**
  24398. * Gets if `setParticles()` computes the particle colors or not.
  24399. * Default value : true. The SPS is faster when it's set to false.
  24400. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24401. */
  24402. computeParticleColor: boolean;
  24403. /**
  24404. * Gets if `setParticles()` computes the particle textures or not.
  24405. * Default value : true. The SPS is faster when it's set to false.
  24406. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24407. */
  24408. computeParticleTexture: boolean;
  24409. /**
  24410. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24411. * Default value : false. The SPS is faster when it's set to false.
  24412. * Note : the particle custom vertex positions aren't stored values.
  24413. */
  24414. /**
  24415. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24416. * Default value : false. The SPS is faster when it's set to false.
  24417. * Note : the particle custom vertex positions aren't stored values.
  24418. */
  24419. computeParticleVertex: boolean;
  24420. /**
  24421. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24422. */
  24423. /**
  24424. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24425. */
  24426. computeBoundingBox: boolean;
  24427. /**
  24428. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24429. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24430. * Default : `true`
  24431. */
  24432. /**
  24433. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24434. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24435. * Default : `true`
  24436. */
  24437. depthSortParticles: boolean;
  24438. /**
  24439. * This function does nothing. It may be overwritten to set all the particle first values.
  24440. * The SPS doesn't call this function, you may have to call it by your own.
  24441. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24442. */
  24443. initParticles(): void;
  24444. /**
  24445. * This function does nothing. It may be overwritten to recycle a particle.
  24446. * The SPS doesn't call this function, you may have to call it by your own.
  24447. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24448. * @param particle The particle to recycle
  24449. * @returns the recycled particle
  24450. */
  24451. recycleParticle(particle: SolidParticle): SolidParticle;
  24452. /**
  24453. * Updates a particle : this function should be overwritten by the user.
  24454. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24455. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24456. * @example : just set a particle position or velocity and recycle conditions
  24457. * @param particle The particle to update
  24458. * @returns the updated particle
  24459. */
  24460. updateParticle(particle: SolidParticle): SolidParticle;
  24461. /**
  24462. * Updates a vertex of a particle : it can be overwritten by the user.
  24463. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24464. * @param particle the current particle
  24465. * @param vertex the current index of the current particle
  24466. * @param pt the index of the current vertex in the particle shape
  24467. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24468. * @example : just set a vertex particle position
  24469. * @returns the updated vertex
  24470. */
  24471. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24472. /**
  24473. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24474. * This does nothing and may be overwritten by the user.
  24475. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24476. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24477. * @param update the boolean update value actually passed to setParticles()
  24478. */
  24479. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24480. /**
  24481. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24482. * This will be passed three parameters.
  24483. * This does nothing and may be overwritten by the user.
  24484. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24485. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24486. * @param update the boolean update value actually passed to setParticles()
  24487. */
  24488. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24489. }
  24490. }
  24491. declare module "babylonjs/Particles/solidParticle" {
  24492. import { Nullable } from "babylonjs/types";
  24493. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24494. import { Mesh } from "babylonjs/Meshes/mesh";
  24495. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24496. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24497. /**
  24498. * Represents one particle of a solid particle system.
  24499. */
  24500. export class SolidParticle {
  24501. /**
  24502. * particle global index
  24503. */
  24504. idx: number;
  24505. /**
  24506. * The color of the particle
  24507. */
  24508. color: Nullable<Color4>;
  24509. /**
  24510. * The world space position of the particle.
  24511. */
  24512. position: Vector3;
  24513. /**
  24514. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24515. */
  24516. rotation: Vector3;
  24517. /**
  24518. * The world space rotation quaternion of the particle.
  24519. */
  24520. rotationQuaternion: Nullable<Quaternion>;
  24521. /**
  24522. * The scaling of the particle.
  24523. */
  24524. scaling: Vector3;
  24525. /**
  24526. * The uvs of the particle.
  24527. */
  24528. uvs: Vector4;
  24529. /**
  24530. * The current speed of the particle.
  24531. */
  24532. velocity: Vector3;
  24533. /**
  24534. * The pivot point in the particle local space.
  24535. */
  24536. pivot: Vector3;
  24537. /**
  24538. * Must the particle be translated from its pivot point in its local space ?
  24539. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24540. * Default : false
  24541. */
  24542. translateFromPivot: boolean;
  24543. /**
  24544. * Is the particle active or not ?
  24545. */
  24546. alive: boolean;
  24547. /**
  24548. * Is the particle visible or not ?
  24549. */
  24550. isVisible: boolean;
  24551. /**
  24552. * Index of this particle in the global "positions" array (Internal use)
  24553. * @hidden
  24554. */
  24555. _pos: number;
  24556. /**
  24557. * @hidden Index of this particle in the global "indices" array (Internal use)
  24558. */
  24559. _ind: number;
  24560. /**
  24561. * @hidden ModelShape of this particle (Internal use)
  24562. */
  24563. _model: ModelShape;
  24564. /**
  24565. * ModelShape id of this particle
  24566. */
  24567. shapeId: number;
  24568. /**
  24569. * Index of the particle in its shape id (Internal use)
  24570. */
  24571. idxInShape: number;
  24572. /**
  24573. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24574. */
  24575. _modelBoundingInfo: BoundingInfo;
  24576. /**
  24577. * @hidden Particle BoundingInfo object (Internal use)
  24578. */
  24579. _boundingInfo: BoundingInfo;
  24580. /**
  24581. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24582. */
  24583. _sps: SolidParticleSystem;
  24584. /**
  24585. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24586. */
  24587. _stillInvisible: boolean;
  24588. /**
  24589. * @hidden Last computed particle rotation matrix
  24590. */
  24591. _rotationMatrix: number[];
  24592. /**
  24593. * Parent particle Id, if any.
  24594. * Default null.
  24595. */
  24596. parentId: Nullable<number>;
  24597. /**
  24598. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24599. * The possible values are :
  24600. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24601. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24602. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24603. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24604. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24605. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24606. * */
  24607. cullingStrategy: number;
  24608. /**
  24609. * @hidden Internal global position in the SPS.
  24610. */
  24611. _globalPosition: Vector3;
  24612. /**
  24613. * Creates a Solid Particle object.
  24614. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24615. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24616. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24617. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24618. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24619. * @param shapeId (integer) is the model shape identifier in the SPS.
  24620. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24621. * @param sps defines the sps it is associated to
  24622. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24623. */
  24624. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24625. /**
  24626. * Legacy support, changed scale to scaling
  24627. */
  24628. /**
  24629. * Legacy support, changed scale to scaling
  24630. */
  24631. scale: Vector3;
  24632. /**
  24633. * Legacy support, changed quaternion to rotationQuaternion
  24634. */
  24635. /**
  24636. * Legacy support, changed quaternion to rotationQuaternion
  24637. */
  24638. quaternion: Nullable<Quaternion>;
  24639. /**
  24640. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24641. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24642. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24643. * @returns true if it intersects
  24644. */
  24645. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24646. /**
  24647. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24648. * A particle is in the frustum if its bounding box intersects the frustum
  24649. * @param frustumPlanes defines the frustum to test
  24650. * @returns true if the particle is in the frustum planes
  24651. */
  24652. isInFrustum(frustumPlanes: Plane[]): boolean;
  24653. /**
  24654. * get the rotation matrix of the particle
  24655. * @hidden
  24656. */
  24657. getRotationMatrix(m: Matrix): void;
  24658. }
  24659. /**
  24660. * Represents the shape of the model used by one particle of a solid particle system.
  24661. * SPS internal tool, don't use it manually.
  24662. */
  24663. export class ModelShape {
  24664. /**
  24665. * The shape id
  24666. * @hidden
  24667. */
  24668. shapeID: number;
  24669. /**
  24670. * flat array of model positions (internal use)
  24671. * @hidden
  24672. */
  24673. _shape: Vector3[];
  24674. /**
  24675. * flat array of model UVs (internal use)
  24676. * @hidden
  24677. */
  24678. _shapeUV: number[];
  24679. /**
  24680. * length of the shape in the model indices array (internal use)
  24681. * @hidden
  24682. */
  24683. _indicesLength: number;
  24684. /**
  24685. * Custom position function (internal use)
  24686. * @hidden
  24687. */
  24688. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24689. /**
  24690. * Custom vertex function (internal use)
  24691. * @hidden
  24692. */
  24693. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24694. /**
  24695. * 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.
  24696. * SPS internal tool, don't use it manually.
  24697. * @hidden
  24698. */
  24699. 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>);
  24700. }
  24701. /**
  24702. * Represents a Depth Sorted Particle in the solid particle system.
  24703. */
  24704. export class DepthSortedParticle {
  24705. /**
  24706. * Index of the particle in the "indices" array
  24707. */
  24708. ind: number;
  24709. /**
  24710. * Length of the particle shape in the "indices" array
  24711. */
  24712. indicesLength: number;
  24713. /**
  24714. * Squared distance from the particle to the camera
  24715. */
  24716. sqDistance: number;
  24717. }
  24718. }
  24719. declare module "babylonjs/Meshes/abstractMesh" {
  24720. import { Observable } from "babylonjs/Misc/observable";
  24721. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24722. import { Camera } from "babylonjs/Cameras/camera";
  24723. import { Scene, IDisposable } from "babylonjs/scene";
  24724. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24725. import { Node } from "babylonjs/node";
  24726. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24727. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24728. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24729. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24730. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24731. import { Material } from "babylonjs/Materials/material";
  24732. import { Light } from "babylonjs/Lights/light";
  24733. import { Skeleton } from "babylonjs/Bones/skeleton";
  24734. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24735. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24736. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24737. import { Ray } from "babylonjs/Culling/ray";
  24738. import { Collider } from "babylonjs/Collisions/collider";
  24739. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24740. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24741. /**
  24742. * Class used to store all common mesh properties
  24743. */
  24744. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24745. /** No occlusion */
  24746. static OCCLUSION_TYPE_NONE: number;
  24747. /** Occlusion set to optimisitic */
  24748. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24749. /** Occlusion set to strict */
  24750. static OCCLUSION_TYPE_STRICT: number;
  24751. /** Use an accurante occlusion algorithm */
  24752. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24753. /** Use a conservative occlusion algorithm */
  24754. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24755. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24756. * Test order :
  24757. * Is the bounding sphere outside the frustum ?
  24758. * If not, are the bounding box vertices outside the frustum ?
  24759. * It not, then the cullable object is in the frustum.
  24760. */
  24761. static readonly CULLINGSTRATEGY_STANDARD: number;
  24762. /** Culling strategy : Bounding Sphere Only.
  24763. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24764. * It's also less accurate than the standard because some not visible objects can still be selected.
  24765. * Test : is the bounding sphere outside the frustum ?
  24766. * If not, then the cullable object is in the frustum.
  24767. */
  24768. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24769. /** Culling strategy : Optimistic Inclusion.
  24770. * This in an inclusion test first, then the standard exclusion test.
  24771. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24772. * 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.
  24773. * Anyway, it's as accurate as the standard strategy.
  24774. * Test :
  24775. * Is the cullable object bounding sphere center in the frustum ?
  24776. * If not, apply the default culling strategy.
  24777. */
  24778. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24779. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24780. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24781. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24782. * 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.
  24783. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24784. * Test :
  24785. * Is the cullable object bounding sphere center in the frustum ?
  24786. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24787. */
  24788. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24789. /**
  24790. * No billboard
  24791. */
  24792. static readonly BILLBOARDMODE_NONE: number;
  24793. /** Billboard on X axis */
  24794. static readonly BILLBOARDMODE_X: number;
  24795. /** Billboard on Y axis */
  24796. static readonly BILLBOARDMODE_Y: number;
  24797. /** Billboard on Z axis */
  24798. static readonly BILLBOARDMODE_Z: number;
  24799. /** Billboard on all axes */
  24800. static readonly BILLBOARDMODE_ALL: number;
  24801. private _facetData;
  24802. /**
  24803. * The culling strategy to use to check whether the mesh must be rendered or not.
  24804. * This value can be changed at any time and will be used on the next render mesh selection.
  24805. * The possible values are :
  24806. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24807. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24808. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24809. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24810. * Please read each static variable documentation to get details about the culling process.
  24811. * */
  24812. cullingStrategy: number;
  24813. /**
  24814. * Gets the number of facets in the mesh
  24815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24816. */
  24817. readonly facetNb: number;
  24818. /**
  24819. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24821. */
  24822. partitioningSubdivisions: number;
  24823. /**
  24824. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24825. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24827. */
  24828. partitioningBBoxRatio: number;
  24829. /**
  24830. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24831. * Works only for updatable meshes.
  24832. * Doesn't work with multi-materials
  24833. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24834. */
  24835. mustDepthSortFacets: boolean;
  24836. /**
  24837. * The location (Vector3) where the facet depth sort must be computed from.
  24838. * By default, the active camera position.
  24839. * Used only when facet depth sort is enabled
  24840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24841. */
  24842. facetDepthSortFrom: Vector3;
  24843. /**
  24844. * gets a boolean indicating if facetData is enabled
  24845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24846. */
  24847. readonly isFacetDataEnabled: boolean;
  24848. /** @hidden */
  24849. _updateNonUniformScalingState(value: boolean): boolean;
  24850. /**
  24851. * An event triggered when this mesh collides with another one
  24852. */
  24853. onCollideObservable: Observable<AbstractMesh>;
  24854. private _onCollideObserver;
  24855. /** Set a function to call when this mesh collides with another one */
  24856. onCollide: () => void;
  24857. /**
  24858. * An event triggered when the collision's position changes
  24859. */
  24860. onCollisionPositionChangeObservable: Observable<Vector3>;
  24861. private _onCollisionPositionChangeObserver;
  24862. /** Set a function to call when the collision's position changes */
  24863. onCollisionPositionChange: () => void;
  24864. /**
  24865. * An event triggered when material is changed
  24866. */
  24867. onMaterialChangedObservable: Observable<AbstractMesh>;
  24868. /**
  24869. * Gets or sets the orientation for POV movement & rotation
  24870. */
  24871. definedFacingForward: boolean;
  24872. /** @hidden */
  24873. _occlusionQuery: Nullable<WebGLQuery>;
  24874. private _visibility;
  24875. /** @hidden */
  24876. _isActive: boolean;
  24877. /** @hidden */
  24878. _renderingGroup: Nullable<RenderingGroup>;
  24879. /**
  24880. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24881. */
  24882. /**
  24883. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24884. */
  24885. visibility: number;
  24886. /** Gets or sets the alpha index used to sort transparent meshes
  24887. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24888. */
  24889. alphaIndex: number;
  24890. /**
  24891. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24892. */
  24893. isVisible: boolean;
  24894. /**
  24895. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24896. */
  24897. isPickable: boolean;
  24898. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24899. showSubMeshesBoundingBox: boolean;
  24900. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24901. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24902. */
  24903. isBlocker: boolean;
  24904. /**
  24905. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24906. */
  24907. enablePointerMoveEvents: boolean;
  24908. /**
  24909. * Specifies the rendering group id for this mesh (0 by default)
  24910. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24911. */
  24912. renderingGroupId: number;
  24913. private _material;
  24914. /** Gets or sets current material */
  24915. material: Nullable<Material>;
  24916. private _receiveShadows;
  24917. /**
  24918. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24919. * @see http://doc.babylonjs.com/babylon101/shadows
  24920. */
  24921. receiveShadows: boolean;
  24922. /** Defines color to use when rendering outline */
  24923. outlineColor: Color3;
  24924. /** Define width to use when rendering outline */
  24925. outlineWidth: number;
  24926. /** Defines color to use when rendering overlay */
  24927. overlayColor: Color3;
  24928. /** Defines alpha to use when rendering overlay */
  24929. overlayAlpha: number;
  24930. private _hasVertexAlpha;
  24931. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24932. hasVertexAlpha: boolean;
  24933. private _useVertexColors;
  24934. /** 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) */
  24935. useVertexColors: boolean;
  24936. private _computeBonesUsingShaders;
  24937. /**
  24938. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24939. */
  24940. computeBonesUsingShaders: boolean;
  24941. private _numBoneInfluencers;
  24942. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24943. numBoneInfluencers: number;
  24944. private _applyFog;
  24945. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24946. applyFog: boolean;
  24947. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24948. useOctreeForRenderingSelection: boolean;
  24949. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24950. useOctreeForPicking: boolean;
  24951. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24952. useOctreeForCollisions: boolean;
  24953. private _layerMask;
  24954. /**
  24955. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24956. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24957. */
  24958. layerMask: number;
  24959. /**
  24960. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24961. */
  24962. alwaysSelectAsActiveMesh: boolean;
  24963. /**
  24964. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24965. */
  24966. doNotSyncBoundingInfo: boolean;
  24967. /**
  24968. * Gets or sets the current action manager
  24969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24970. */
  24971. actionManager: Nullable<AbstractActionManager>;
  24972. private _checkCollisions;
  24973. private _collisionMask;
  24974. private _collisionGroup;
  24975. /**
  24976. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24977. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24978. */
  24979. ellipsoid: Vector3;
  24980. /**
  24981. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24982. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24983. */
  24984. ellipsoidOffset: Vector3;
  24985. private _collider;
  24986. private _oldPositionForCollisions;
  24987. private _diffPositionForCollisions;
  24988. /**
  24989. * Gets or sets a collision mask used to mask collisions (default is -1).
  24990. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24991. */
  24992. collisionMask: number;
  24993. /**
  24994. * Gets or sets the current collision group mask (-1 by default).
  24995. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24996. */
  24997. collisionGroup: number;
  24998. /**
  24999. * Defines edge width used when edgesRenderer is enabled
  25000. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25001. */
  25002. edgesWidth: number;
  25003. /**
  25004. * Defines edge color used when edgesRenderer is enabled
  25005. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25006. */
  25007. edgesColor: Color4;
  25008. /** @hidden */
  25009. _edgesRenderer: Nullable<IEdgesRenderer>;
  25010. /** @hidden */
  25011. _masterMesh: Nullable<AbstractMesh>;
  25012. /** @hidden */
  25013. _boundingInfo: Nullable<BoundingInfo>;
  25014. /** @hidden */
  25015. _renderId: number;
  25016. /**
  25017. * Gets or sets the list of subMeshes
  25018. * @see http://doc.babylonjs.com/how_to/multi_materials
  25019. */
  25020. subMeshes: SubMesh[];
  25021. /** @hidden */
  25022. _intersectionsInProgress: AbstractMesh[];
  25023. /** @hidden */
  25024. _unIndexed: boolean;
  25025. /** @hidden */
  25026. _lightSources: Light[];
  25027. /** @hidden */
  25028. readonly _positions: Nullable<Vector3[]>;
  25029. /** @hidden */
  25030. _waitingActions: Nullable<any>;
  25031. /** @hidden */
  25032. _waitingFreezeWorldMatrix: Nullable<boolean>;
  25033. private _skeleton;
  25034. /** @hidden */
  25035. _bonesTransformMatrices: Nullable<Float32Array>;
  25036. /**
  25037. * Gets or sets a skeleton to apply skining transformations
  25038. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25039. */
  25040. skeleton: Nullable<Skeleton>;
  25041. /**
  25042. * An event triggered when the mesh is rebuilt.
  25043. */
  25044. onRebuildObservable: Observable<AbstractMesh>;
  25045. /**
  25046. * Creates a new AbstractMesh
  25047. * @param name defines the name of the mesh
  25048. * @param scene defines the hosting scene
  25049. */
  25050. constructor(name: string, scene?: Nullable<Scene>);
  25051. /**
  25052. * Returns the string "AbstractMesh"
  25053. * @returns "AbstractMesh"
  25054. */
  25055. getClassName(): string;
  25056. /**
  25057. * Gets a string representation of the current mesh
  25058. * @param fullDetails defines a boolean indicating if full details must be included
  25059. * @returns a string representation of the current mesh
  25060. */
  25061. toString(fullDetails?: boolean): string;
  25062. /**
  25063. * @hidden
  25064. */
  25065. protected _getEffectiveParent(): Nullable<Node>;
  25066. /** @hidden */
  25067. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25068. /** @hidden */
  25069. _rebuild(): void;
  25070. /** @hidden */
  25071. _resyncLightSources(): void;
  25072. /** @hidden */
  25073. _resyncLighSource(light: Light): void;
  25074. /** @hidden */
  25075. _unBindEffect(): void;
  25076. /** @hidden */
  25077. _removeLightSource(light: Light): void;
  25078. private _markSubMeshesAsDirty;
  25079. /** @hidden */
  25080. _markSubMeshesAsLightDirty(): void;
  25081. /** @hidden */
  25082. _markSubMeshesAsAttributesDirty(): void;
  25083. /** @hidden */
  25084. _markSubMeshesAsMiscDirty(): void;
  25085. /**
  25086. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25087. */
  25088. scaling: Vector3;
  25089. /**
  25090. * Returns true if the mesh is blocked. Implemented by child classes
  25091. */
  25092. readonly isBlocked: boolean;
  25093. /**
  25094. * Returns the mesh itself by default. Implemented by child classes
  25095. * @param camera defines the camera to use to pick the right LOD level
  25096. * @returns the currentAbstractMesh
  25097. */
  25098. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25099. /**
  25100. * Returns 0 by default. Implemented by child classes
  25101. * @returns an integer
  25102. */
  25103. getTotalVertices(): number;
  25104. /**
  25105. * Returns a positive integer : the total number of indices in this mesh geometry.
  25106. * @returns the numner of indices or zero if the mesh has no geometry.
  25107. */
  25108. getTotalIndices(): number;
  25109. /**
  25110. * Returns null by default. Implemented by child classes
  25111. * @returns null
  25112. */
  25113. getIndices(): Nullable<IndicesArray>;
  25114. /**
  25115. * Returns the array of the requested vertex data kind. Implemented by child classes
  25116. * @param kind defines the vertex data kind to use
  25117. * @returns null
  25118. */
  25119. getVerticesData(kind: string): Nullable<FloatArray>;
  25120. /**
  25121. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25122. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25123. * Note that a new underlying VertexBuffer object is created each call.
  25124. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25125. * @param kind defines vertex data kind:
  25126. * * VertexBuffer.PositionKind
  25127. * * VertexBuffer.UVKind
  25128. * * VertexBuffer.UV2Kind
  25129. * * VertexBuffer.UV3Kind
  25130. * * VertexBuffer.UV4Kind
  25131. * * VertexBuffer.UV5Kind
  25132. * * VertexBuffer.UV6Kind
  25133. * * VertexBuffer.ColorKind
  25134. * * VertexBuffer.MatricesIndicesKind
  25135. * * VertexBuffer.MatricesIndicesExtraKind
  25136. * * VertexBuffer.MatricesWeightsKind
  25137. * * VertexBuffer.MatricesWeightsExtraKind
  25138. * @param data defines the data source
  25139. * @param updatable defines if the data must be flagged as updatable (or static)
  25140. * @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
  25141. * @returns the current mesh
  25142. */
  25143. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25144. /**
  25145. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25146. * If the mesh has no geometry, it is simply returned as it is.
  25147. * @param kind defines vertex data kind:
  25148. * * VertexBuffer.PositionKind
  25149. * * VertexBuffer.UVKind
  25150. * * VertexBuffer.UV2Kind
  25151. * * VertexBuffer.UV3Kind
  25152. * * VertexBuffer.UV4Kind
  25153. * * VertexBuffer.UV5Kind
  25154. * * VertexBuffer.UV6Kind
  25155. * * VertexBuffer.ColorKind
  25156. * * VertexBuffer.MatricesIndicesKind
  25157. * * VertexBuffer.MatricesIndicesExtraKind
  25158. * * VertexBuffer.MatricesWeightsKind
  25159. * * VertexBuffer.MatricesWeightsExtraKind
  25160. * @param data defines the data source
  25161. * @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
  25162. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25163. * @returns the current mesh
  25164. */
  25165. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25166. /**
  25167. * Sets the mesh indices,
  25168. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25169. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25170. * @param totalVertices Defines the total number of vertices
  25171. * @returns the current mesh
  25172. */
  25173. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25174. /**
  25175. * Gets a boolean indicating if specific vertex data is present
  25176. * @param kind defines the vertex data kind to use
  25177. * @returns true is data kind is present
  25178. */
  25179. isVerticesDataPresent(kind: string): boolean;
  25180. /**
  25181. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25182. * @returns a BoundingInfo
  25183. */
  25184. getBoundingInfo(): BoundingInfo;
  25185. /**
  25186. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25187. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25188. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25189. * @returns the current mesh
  25190. */
  25191. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25192. /**
  25193. * Overwrite the current bounding info
  25194. * @param boundingInfo defines the new bounding info
  25195. * @returns the current mesh
  25196. */
  25197. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25198. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25199. readonly useBones: boolean;
  25200. /** @hidden */
  25201. _preActivate(): void;
  25202. /** @hidden */
  25203. _preActivateForIntermediateRendering(renderId: number): void;
  25204. /** @hidden */
  25205. _activate(renderId: number): boolean;
  25206. /** @hidden */
  25207. _freeze(): void;
  25208. /** @hidden */
  25209. _unFreeze(): void;
  25210. /**
  25211. * Gets the current world matrix
  25212. * @returns a Matrix
  25213. */
  25214. getWorldMatrix(): Matrix;
  25215. /** @hidden */
  25216. _getWorldMatrixDeterminant(): number;
  25217. /**
  25218. * Perform relative position change from the point of view of behind the front of the mesh.
  25219. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25220. * Supports definition of mesh facing forward or backward
  25221. * @param amountRight defines the distance on the right axis
  25222. * @param amountUp defines the distance on the up axis
  25223. * @param amountForward defines the distance on the forward axis
  25224. * @returns the current mesh
  25225. */
  25226. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25227. /**
  25228. * Calculate relative position change from the point of view of behind the front of the mesh.
  25229. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25230. * Supports definition of mesh facing forward or backward
  25231. * @param amountRight defines the distance on the right axis
  25232. * @param amountUp defines the distance on the up axis
  25233. * @param amountForward defines the distance on the forward axis
  25234. * @returns the new displacement vector
  25235. */
  25236. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25237. /**
  25238. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25239. * Supports definition of mesh facing forward or backward
  25240. * @param flipBack defines the flip
  25241. * @param twirlClockwise defines the twirl
  25242. * @param tiltRight defines the tilt
  25243. * @returns the current mesh
  25244. */
  25245. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25246. /**
  25247. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25248. * Supports definition of mesh facing forward or backward.
  25249. * @param flipBack defines the flip
  25250. * @param twirlClockwise defines the twirl
  25251. * @param tiltRight defines the tilt
  25252. * @returns the new rotation vector
  25253. */
  25254. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25255. /**
  25256. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25257. * This means the mesh underlying bounding box and sphere are recomputed.
  25258. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25259. * @returns the current mesh
  25260. */
  25261. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25262. /** @hidden */
  25263. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25264. /** @hidden */
  25265. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25266. /** @hidden */
  25267. _updateBoundingInfo(): AbstractMesh;
  25268. /** @hidden */
  25269. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25270. /** @hidden */
  25271. protected _afterComputeWorldMatrix(): void;
  25272. /** @hidden */
  25273. readonly _effectiveMesh: AbstractMesh;
  25274. /**
  25275. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25276. * A mesh is in the frustum if its bounding box intersects the frustum
  25277. * @param frustumPlanes defines the frustum to test
  25278. * @returns true if the mesh is in the frustum planes
  25279. */
  25280. isInFrustum(frustumPlanes: Plane[]): boolean;
  25281. /**
  25282. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25283. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25284. * @param frustumPlanes defines the frustum to test
  25285. * @returns true if the mesh is completely in the frustum planes
  25286. */
  25287. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25288. /**
  25289. * True if the mesh intersects another mesh or a SolidParticle object
  25290. * @param mesh defines a target mesh or SolidParticle to test
  25291. * @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)
  25292. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25293. * @returns true if there is an intersection
  25294. */
  25295. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25296. /**
  25297. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25298. * @param point defines the point to test
  25299. * @returns true if there is an intersection
  25300. */
  25301. intersectsPoint(point: Vector3): boolean;
  25302. /**
  25303. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25304. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25305. */
  25306. checkCollisions: boolean;
  25307. /**
  25308. * Gets Collider object used to compute collisions (not physics)
  25309. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25310. */
  25311. readonly collider: Nullable<Collider>;
  25312. /**
  25313. * Move the mesh using collision engine
  25314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25315. * @param displacement defines the requested displacement vector
  25316. * @returns the current mesh
  25317. */
  25318. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25319. private _onCollisionPositionChange;
  25320. /** @hidden */
  25321. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25322. /** @hidden */
  25323. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25324. /** @hidden */
  25325. _checkCollision(collider: Collider): AbstractMesh;
  25326. /** @hidden */
  25327. _generatePointsArray(): boolean;
  25328. /**
  25329. * Checks if the passed Ray intersects with the mesh
  25330. * @param ray defines the ray to use
  25331. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25332. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25333. * @returns the picking info
  25334. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25335. */
  25336. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25337. /**
  25338. * Clones the current mesh
  25339. * @param name defines the mesh name
  25340. * @param newParent defines the new mesh parent
  25341. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25342. * @returns the new mesh
  25343. */
  25344. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25345. /**
  25346. * Disposes all the submeshes of the current meshnp
  25347. * @returns the current mesh
  25348. */
  25349. releaseSubMeshes(): AbstractMesh;
  25350. /**
  25351. * Releases resources associated with this abstract mesh.
  25352. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25353. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25354. */
  25355. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25356. /**
  25357. * Adds the passed mesh as a child to the current mesh
  25358. * @param mesh defines the child mesh
  25359. * @returns the current mesh
  25360. */
  25361. addChild(mesh: AbstractMesh): AbstractMesh;
  25362. /**
  25363. * Removes the passed mesh from the current mesh children list
  25364. * @param mesh defines the child mesh
  25365. * @returns the current mesh
  25366. */
  25367. removeChild(mesh: AbstractMesh): AbstractMesh;
  25368. /** @hidden */
  25369. private _initFacetData;
  25370. /**
  25371. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25372. * This method can be called within the render loop.
  25373. * 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
  25374. * @returns the current mesh
  25375. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25376. */
  25377. updateFacetData(): AbstractMesh;
  25378. /**
  25379. * Returns the facetLocalNormals array.
  25380. * The normals are expressed in the mesh local spac
  25381. * @returns an array of Vector3
  25382. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25383. */
  25384. getFacetLocalNormals(): Vector3[];
  25385. /**
  25386. * Returns the facetLocalPositions array.
  25387. * The facet positions are expressed in the mesh local space
  25388. * @returns an array of Vector3
  25389. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25390. */
  25391. getFacetLocalPositions(): Vector3[];
  25392. /**
  25393. * Returns the facetLocalPartioning array
  25394. * @returns an array of array of numbers
  25395. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25396. */
  25397. getFacetLocalPartitioning(): number[][];
  25398. /**
  25399. * Returns the i-th facet position in the world system.
  25400. * This method allocates a new Vector3 per call
  25401. * @param i defines the facet index
  25402. * @returns a new Vector3
  25403. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25404. */
  25405. getFacetPosition(i: number): Vector3;
  25406. /**
  25407. * Sets the reference Vector3 with the i-th facet position in the world system
  25408. * @param i defines the facet index
  25409. * @param ref defines the target vector
  25410. * @returns the current mesh
  25411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25412. */
  25413. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25414. /**
  25415. * Returns the i-th facet normal in the world system.
  25416. * This method allocates a new Vector3 per call
  25417. * @param i defines the facet index
  25418. * @returns a new Vector3
  25419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25420. */
  25421. getFacetNormal(i: number): Vector3;
  25422. /**
  25423. * Sets the reference Vector3 with the i-th facet normal in the world system
  25424. * @param i defines the facet index
  25425. * @param ref defines the target vector
  25426. * @returns the current mesh
  25427. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25428. */
  25429. getFacetNormalToRef(i: number, ref: Vector3): this;
  25430. /**
  25431. * 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)
  25432. * @param x defines x coordinate
  25433. * @param y defines y coordinate
  25434. * @param z defines z coordinate
  25435. * @returns the array of facet indexes
  25436. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25437. */
  25438. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25439. /**
  25440. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25441. * @param projected sets as the (x,y,z) world projection on the facet
  25442. * @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
  25443. * @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
  25444. * @param x defines x coordinate
  25445. * @param y defines y coordinate
  25446. * @param z defines z coordinate
  25447. * @returns the face index if found (or null instead)
  25448. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25449. */
  25450. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25451. /**
  25452. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25453. * @param projected sets as the (x,y,z) local projection on the facet
  25454. * @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
  25455. * @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
  25456. * @param x defines x coordinate
  25457. * @param y defines y coordinate
  25458. * @param z defines z coordinate
  25459. * @returns the face index if found (or null instead)
  25460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25461. */
  25462. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25463. /**
  25464. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25465. * @returns the parameters
  25466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25467. */
  25468. getFacetDataParameters(): any;
  25469. /**
  25470. * Disables the feature FacetData and frees the related memory
  25471. * @returns the current mesh
  25472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25473. */
  25474. disableFacetData(): AbstractMesh;
  25475. /**
  25476. * Updates the AbstractMesh indices array
  25477. * @param indices defines the data source
  25478. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25479. * @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)
  25480. * @returns the current mesh
  25481. */
  25482. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25483. /**
  25484. * Creates new normals data for the mesh
  25485. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25486. * @returns the current mesh
  25487. */
  25488. createNormals(updatable: boolean): AbstractMesh;
  25489. /**
  25490. * Align the mesh with a normal
  25491. * @param normal defines the normal to use
  25492. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25493. * @returns the current mesh
  25494. */
  25495. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25496. /** @hidden */
  25497. _checkOcclusionQuery(): boolean;
  25498. }
  25499. }
  25500. declare module "babylonjs/Actions/actionEvent" {
  25501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25502. import { Nullable } from "babylonjs/types";
  25503. import { Sprite } from "babylonjs/Sprites/sprite";
  25504. import { Scene } from "babylonjs/scene";
  25505. import { Vector2 } from "babylonjs/Maths/math";
  25506. /**
  25507. * Interface used to define ActionEvent
  25508. */
  25509. export interface IActionEvent {
  25510. /** The mesh or sprite that triggered the action */
  25511. source: any;
  25512. /** The X mouse cursor position at the time of the event */
  25513. pointerX: number;
  25514. /** The Y mouse cursor position at the time of the event */
  25515. pointerY: number;
  25516. /** The mesh that is currently pointed at (can be null) */
  25517. meshUnderPointer: Nullable<AbstractMesh>;
  25518. /** the original (browser) event that triggered the ActionEvent */
  25519. sourceEvent?: any;
  25520. /** additional data for the event */
  25521. additionalData?: any;
  25522. }
  25523. /**
  25524. * ActionEvent is the event being sent when an action is triggered.
  25525. */
  25526. export class ActionEvent implements IActionEvent {
  25527. /** The mesh or sprite that triggered the action */
  25528. source: any;
  25529. /** The X mouse cursor position at the time of the event */
  25530. pointerX: number;
  25531. /** The Y mouse cursor position at the time of the event */
  25532. pointerY: number;
  25533. /** The mesh that is currently pointed at (can be null) */
  25534. meshUnderPointer: Nullable<AbstractMesh>;
  25535. /** the original (browser) event that triggered the ActionEvent */
  25536. sourceEvent?: any;
  25537. /** additional data for the event */
  25538. additionalData?: any;
  25539. /**
  25540. * Creates a new ActionEvent
  25541. * @param source The mesh or sprite that triggered the action
  25542. * @param pointerX The X mouse cursor position at the time of the event
  25543. * @param pointerY The Y mouse cursor position at the time of the event
  25544. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25545. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25546. * @param additionalData additional data for the event
  25547. */
  25548. constructor(
  25549. /** The mesh or sprite that triggered the action */
  25550. source: any,
  25551. /** The X mouse cursor position at the time of the event */
  25552. pointerX: number,
  25553. /** The Y mouse cursor position at the time of the event */
  25554. pointerY: number,
  25555. /** The mesh that is currently pointed at (can be null) */
  25556. meshUnderPointer: Nullable<AbstractMesh>,
  25557. /** the original (browser) event that triggered the ActionEvent */
  25558. sourceEvent?: any,
  25559. /** additional data for the event */
  25560. additionalData?: any);
  25561. /**
  25562. * Helper function to auto-create an ActionEvent from a source mesh.
  25563. * @param source The source mesh that triggered the event
  25564. * @param evt The original (browser) event
  25565. * @param additionalData additional data for the event
  25566. * @returns the new ActionEvent
  25567. */
  25568. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25569. /**
  25570. * Helper function to auto-create an ActionEvent from a source sprite
  25571. * @param source The source sprite that triggered the event
  25572. * @param scene Scene associated with the sprite
  25573. * @param evt The original (browser) event
  25574. * @param additionalData additional data for the event
  25575. * @returns the new ActionEvent
  25576. */
  25577. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25578. /**
  25579. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25580. * @param scene the scene where the event occurred
  25581. * @param evt The original (browser) event
  25582. * @returns the new ActionEvent
  25583. */
  25584. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25585. /**
  25586. * Helper function to auto-create an ActionEvent from a primitive
  25587. * @param prim defines the target primitive
  25588. * @param pointerPos defines the pointer position
  25589. * @param evt The original (browser) event
  25590. * @param additionalData additional data for the event
  25591. * @returns the new ActionEvent
  25592. */
  25593. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25594. }
  25595. }
  25596. declare module "babylonjs/Actions/abstractActionManager" {
  25597. import { IDisposable } from "babylonjs/scene";
  25598. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25599. import { IAction } from "babylonjs/Actions/action";
  25600. import { Nullable } from "babylonjs/types";
  25601. /**
  25602. * Abstract class used to decouple action Manager from scene and meshes.
  25603. * Do not instantiate.
  25604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25605. */
  25606. export abstract class AbstractActionManager implements IDisposable {
  25607. /** Gets the list of active triggers */
  25608. static Triggers: {
  25609. [key: string]: number;
  25610. };
  25611. /** Gets the cursor to use when hovering items */
  25612. hoverCursor: string;
  25613. /** Gets the list of actions */
  25614. actions: IAction[];
  25615. /**
  25616. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25617. */
  25618. isRecursive: boolean;
  25619. /**
  25620. * Releases all associated resources
  25621. */
  25622. abstract dispose(): void;
  25623. /**
  25624. * Does this action manager has pointer triggers
  25625. */
  25626. abstract readonly hasPointerTriggers: boolean;
  25627. /**
  25628. * Does this action manager has pick triggers
  25629. */
  25630. abstract readonly hasPickTriggers: boolean;
  25631. /**
  25632. * Process a specific trigger
  25633. * @param trigger defines the trigger to process
  25634. * @param evt defines the event details to be processed
  25635. */
  25636. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25637. /**
  25638. * Does this action manager handles actions of any of the given triggers
  25639. * @param triggers defines the triggers to be tested
  25640. * @return a boolean indicating whether one (or more) of the triggers is handled
  25641. */
  25642. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25643. /**
  25644. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25645. * speed.
  25646. * @param triggerA defines the trigger to be tested
  25647. * @param triggerB defines the trigger to be tested
  25648. * @return a boolean indicating whether one (or more) of the triggers is handled
  25649. */
  25650. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25651. /**
  25652. * Does this action manager handles actions of a given trigger
  25653. * @param trigger defines the trigger to be tested
  25654. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25655. * @return whether the trigger is handled
  25656. */
  25657. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25658. /**
  25659. * Serialize this manager to a JSON object
  25660. * @param name defines the property name to store this manager
  25661. * @returns a JSON representation of this manager
  25662. */
  25663. abstract serialize(name: string): any;
  25664. /**
  25665. * Registers an action to this action manager
  25666. * @param action defines the action to be registered
  25667. * @return the action amended (prepared) after registration
  25668. */
  25669. abstract registerAction(action: IAction): Nullable<IAction>;
  25670. /**
  25671. * Unregisters an action to this action manager
  25672. * @param action defines the action to be unregistered
  25673. * @return a boolean indicating whether the action has been unregistered
  25674. */
  25675. abstract unregisterAction(action: IAction): Boolean;
  25676. /**
  25677. * Does exist one action manager with at least one trigger
  25678. **/
  25679. static readonly HasTriggers: boolean;
  25680. /**
  25681. * Does exist one action manager with at least one pick trigger
  25682. **/
  25683. static readonly HasPickTriggers: boolean;
  25684. /**
  25685. * Does exist one action manager that handles actions of a given trigger
  25686. * @param trigger defines the trigger to be tested
  25687. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25688. **/
  25689. static HasSpecificTrigger(trigger: number): boolean;
  25690. }
  25691. }
  25692. declare module "babylonjs/node" {
  25693. import { Scene } from "babylonjs/scene";
  25694. import { Nullable } from "babylonjs/types";
  25695. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25696. import { Engine } from "babylonjs/Engines/engine";
  25697. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25698. import { Observable } from "babylonjs/Misc/observable";
  25699. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25700. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25701. import { Animatable } from "babylonjs/Animations/animatable";
  25702. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25703. import { Animation } from "babylonjs/Animations/animation";
  25704. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25706. /**
  25707. * Defines how a node can be built from a string name.
  25708. */
  25709. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25710. /**
  25711. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25712. */
  25713. export class Node implements IBehaviorAware<Node> {
  25714. /** @hidden */
  25715. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25716. private static _NodeConstructors;
  25717. /**
  25718. * Add a new node constructor
  25719. * @param type defines the type name of the node to construct
  25720. * @param constructorFunc defines the constructor function
  25721. */
  25722. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25723. /**
  25724. * Returns a node constructor based on type name
  25725. * @param type defines the type name
  25726. * @param name defines the new node name
  25727. * @param scene defines the hosting scene
  25728. * @param options defines optional options to transmit to constructors
  25729. * @returns the new constructor or null
  25730. */
  25731. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25732. /**
  25733. * Gets or sets the name of the node
  25734. */
  25735. name: string;
  25736. /**
  25737. * Gets or sets the id of the node
  25738. */
  25739. id: string;
  25740. /**
  25741. * Gets or sets the unique id of the node
  25742. */
  25743. uniqueId: number;
  25744. /**
  25745. * Gets or sets a string used to store user defined state for the node
  25746. */
  25747. state: string;
  25748. /**
  25749. * Gets or sets an object used to store user defined information for the node
  25750. */
  25751. metadata: any;
  25752. /**
  25753. * For internal use only. Please do not use.
  25754. */
  25755. reservedDataStore: any;
  25756. /**
  25757. * List of inspectable custom properties (used by the Inspector)
  25758. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25759. */
  25760. inspectableCustomProperties: IInspectable[];
  25761. /**
  25762. * Gets or sets a boolean used to define if the node must be serialized
  25763. */
  25764. doNotSerialize: boolean;
  25765. /** @hidden */
  25766. _isDisposed: boolean;
  25767. /**
  25768. * Gets a list of Animations associated with the node
  25769. */
  25770. animations: import("babylonjs/Animations/animation").Animation[];
  25771. protected _ranges: {
  25772. [name: string]: Nullable<AnimationRange>;
  25773. };
  25774. /**
  25775. * Callback raised when the node is ready to be used
  25776. */
  25777. onReady: Nullable<(node: Node) => void>;
  25778. private _isEnabled;
  25779. private _isParentEnabled;
  25780. private _isReady;
  25781. /** @hidden */
  25782. _currentRenderId: number;
  25783. private _parentUpdateId;
  25784. /** @hidden */
  25785. _childUpdateId: number;
  25786. /** @hidden */
  25787. _waitingParentId: Nullable<string>;
  25788. /** @hidden */
  25789. _scene: Scene;
  25790. /** @hidden */
  25791. _cache: any;
  25792. private _parentNode;
  25793. private _children;
  25794. /** @hidden */
  25795. _worldMatrix: Matrix;
  25796. /** @hidden */
  25797. _worldMatrixDeterminant: number;
  25798. /** @hidden */
  25799. _worldMatrixDeterminantIsDirty: boolean;
  25800. /** @hidden */
  25801. private _sceneRootNodesIndex;
  25802. /**
  25803. * Gets a boolean indicating if the node has been disposed
  25804. * @returns true if the node was disposed
  25805. */
  25806. isDisposed(): boolean;
  25807. /**
  25808. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25809. * @see https://doc.babylonjs.com/how_to/parenting
  25810. */
  25811. parent: Nullable<Node>;
  25812. private addToSceneRootNodes;
  25813. private removeFromSceneRootNodes;
  25814. private _animationPropertiesOverride;
  25815. /**
  25816. * Gets or sets the animation properties override
  25817. */
  25818. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25819. /**
  25820. * Gets a string idenfifying the name of the class
  25821. * @returns "Node" string
  25822. */
  25823. getClassName(): string;
  25824. /** @hidden */
  25825. readonly _isNode: boolean;
  25826. /**
  25827. * An event triggered when the mesh is disposed
  25828. */
  25829. onDisposeObservable: Observable<Node>;
  25830. private _onDisposeObserver;
  25831. /**
  25832. * Sets a callback that will be raised when the node will be disposed
  25833. */
  25834. onDispose: () => void;
  25835. /**
  25836. * Creates a new Node
  25837. * @param name the name and id to be given to this node
  25838. * @param scene the scene this node will be added to
  25839. * @param addToRootNodes the node will be added to scene.rootNodes
  25840. */
  25841. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25842. /**
  25843. * Gets the scene of the node
  25844. * @returns a scene
  25845. */
  25846. getScene(): Scene;
  25847. /**
  25848. * Gets the engine of the node
  25849. * @returns a Engine
  25850. */
  25851. getEngine(): Engine;
  25852. private _behaviors;
  25853. /**
  25854. * Attach a behavior to the node
  25855. * @see http://doc.babylonjs.com/features/behaviour
  25856. * @param behavior defines the behavior to attach
  25857. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25858. * @returns the current Node
  25859. */
  25860. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25861. /**
  25862. * Remove an attached behavior
  25863. * @see http://doc.babylonjs.com/features/behaviour
  25864. * @param behavior defines the behavior to attach
  25865. * @returns the current Node
  25866. */
  25867. removeBehavior(behavior: Behavior<Node>): Node;
  25868. /**
  25869. * Gets the list of attached behaviors
  25870. * @see http://doc.babylonjs.com/features/behaviour
  25871. */
  25872. readonly behaviors: Behavior<Node>[];
  25873. /**
  25874. * Gets an attached behavior by name
  25875. * @param name defines the name of the behavior to look for
  25876. * @see http://doc.babylonjs.com/features/behaviour
  25877. * @returns null if behavior was not found else the requested behavior
  25878. */
  25879. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25880. /**
  25881. * Returns the latest update of the World matrix
  25882. * @returns a Matrix
  25883. */
  25884. getWorldMatrix(): Matrix;
  25885. /** @hidden */
  25886. _getWorldMatrixDeterminant(): number;
  25887. /**
  25888. * Returns directly the latest state of the mesh World matrix.
  25889. * A Matrix is returned.
  25890. */
  25891. readonly worldMatrixFromCache: Matrix;
  25892. /** @hidden */
  25893. _initCache(): void;
  25894. /** @hidden */
  25895. updateCache(force?: boolean): void;
  25896. /** @hidden */
  25897. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25898. /** @hidden */
  25899. _updateCache(ignoreParentClass?: boolean): void;
  25900. /** @hidden */
  25901. _isSynchronized(): boolean;
  25902. /** @hidden */
  25903. _markSyncedWithParent(): void;
  25904. /** @hidden */
  25905. isSynchronizedWithParent(): boolean;
  25906. /** @hidden */
  25907. isSynchronized(): boolean;
  25908. /**
  25909. * Is this node ready to be used/rendered
  25910. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25911. * @return true if the node is ready
  25912. */
  25913. isReady(completeCheck?: boolean): boolean;
  25914. /**
  25915. * Is this node enabled?
  25916. * 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
  25917. * @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
  25918. * @return whether this node (and its parent) is enabled
  25919. */
  25920. isEnabled(checkAncestors?: boolean): boolean;
  25921. /** @hidden */
  25922. protected _syncParentEnabledState(): void;
  25923. /**
  25924. * Set the enabled state of this node
  25925. * @param value defines the new enabled state
  25926. */
  25927. setEnabled(value: boolean): void;
  25928. /**
  25929. * Is this node a descendant of the given node?
  25930. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25931. * @param ancestor defines the parent node to inspect
  25932. * @returns a boolean indicating if this node is a descendant of the given node
  25933. */
  25934. isDescendantOf(ancestor: Node): boolean;
  25935. /** @hidden */
  25936. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25937. /**
  25938. * Will return all nodes that have this node as ascendant
  25939. * @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
  25940. * @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
  25941. * @return all children nodes of all types
  25942. */
  25943. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25944. /**
  25945. * Get all child-meshes of this node
  25946. * @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)
  25947. * @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
  25948. * @returns an array of AbstractMesh
  25949. */
  25950. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25951. /**
  25952. * Get all direct children of this node
  25953. * @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
  25954. * @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)
  25955. * @returns an array of Node
  25956. */
  25957. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25958. /** @hidden */
  25959. _setReady(state: boolean): void;
  25960. /**
  25961. * Get an animation by name
  25962. * @param name defines the name of the animation to look for
  25963. * @returns null if not found else the requested animation
  25964. */
  25965. getAnimationByName(name: string): Nullable<Animation>;
  25966. /**
  25967. * Creates an animation range for this node
  25968. * @param name defines the name of the range
  25969. * @param from defines the starting key
  25970. * @param to defines the end key
  25971. */
  25972. createAnimationRange(name: string, from: number, to: number): void;
  25973. /**
  25974. * Delete a specific animation range
  25975. * @param name defines the name of the range to delete
  25976. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25977. */
  25978. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25979. /**
  25980. * Get an animation range by name
  25981. * @param name defines the name of the animation range to look for
  25982. * @returns null if not found else the requested animation range
  25983. */
  25984. getAnimationRange(name: string): Nullable<AnimationRange>;
  25985. /**
  25986. * Gets the list of all animation ranges defined on this node
  25987. * @returns an array
  25988. */
  25989. getAnimationRanges(): Nullable<AnimationRange>[];
  25990. /**
  25991. * Will start the animation sequence
  25992. * @param name defines the range frames for animation sequence
  25993. * @param loop defines if the animation should loop (false by default)
  25994. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25995. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25996. * @returns the object created for this animation. If range does not exist, it will return null
  25997. */
  25998. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25999. /**
  26000. * Serialize animation ranges into a JSON compatible object
  26001. * @returns serialization object
  26002. */
  26003. serializeAnimationRanges(): any;
  26004. /**
  26005. * Computes the world matrix of the node
  26006. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26007. * @returns the world matrix
  26008. */
  26009. computeWorldMatrix(force?: boolean): Matrix;
  26010. /**
  26011. * Releases resources associated with this node.
  26012. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26013. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26014. */
  26015. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26016. /**
  26017. * Parse animation range data from a serialization object and store them into a given node
  26018. * @param node defines where to store the animation ranges
  26019. * @param parsedNode defines the serialization object to read data from
  26020. * @param scene defines the hosting scene
  26021. */
  26022. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26023. /**
  26024. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26025. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26026. * @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
  26027. * @returns the new bounding vectors
  26028. */
  26029. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26030. min: Vector3;
  26031. max: Vector3;
  26032. };
  26033. }
  26034. }
  26035. declare module "babylonjs/Animations/animation" {
  26036. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26037. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26038. import { Nullable } from "babylonjs/types";
  26039. import { Scene } from "babylonjs/scene";
  26040. import { IAnimatable } from "babylonjs/Misc/tools";
  26041. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26042. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26043. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26044. import { Node } from "babylonjs/node";
  26045. import { Animatable } from "babylonjs/Animations/animatable";
  26046. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26047. /**
  26048. * @hidden
  26049. */
  26050. export class _IAnimationState {
  26051. key: number;
  26052. repeatCount: number;
  26053. workValue?: any;
  26054. loopMode?: number;
  26055. offsetValue?: any;
  26056. highLimitValue?: any;
  26057. }
  26058. /**
  26059. * Class used to store any kind of animation
  26060. */
  26061. export class Animation {
  26062. /**Name of the animation */
  26063. name: string;
  26064. /**Property to animate */
  26065. targetProperty: string;
  26066. /**The frames per second of the animation */
  26067. framePerSecond: number;
  26068. /**The data type of the animation */
  26069. dataType: number;
  26070. /**The loop mode of the animation */
  26071. loopMode?: number | undefined;
  26072. /**Specifies if blending should be enabled */
  26073. enableBlending?: boolean | undefined;
  26074. /**
  26075. * Use matrix interpolation instead of using direct key value when animating matrices
  26076. */
  26077. static AllowMatricesInterpolation: boolean;
  26078. /**
  26079. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26080. */
  26081. static AllowMatrixDecomposeForInterpolation: boolean;
  26082. /**
  26083. * Stores the key frames of the animation
  26084. */
  26085. private _keys;
  26086. /**
  26087. * Stores the easing function of the animation
  26088. */
  26089. private _easingFunction;
  26090. /**
  26091. * @hidden Internal use only
  26092. */
  26093. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26094. /**
  26095. * The set of event that will be linked to this animation
  26096. */
  26097. private _events;
  26098. /**
  26099. * Stores an array of target property paths
  26100. */
  26101. targetPropertyPath: string[];
  26102. /**
  26103. * Stores the blending speed of the animation
  26104. */
  26105. blendingSpeed: number;
  26106. /**
  26107. * Stores the animation ranges for the animation
  26108. */
  26109. private _ranges;
  26110. /**
  26111. * @hidden Internal use
  26112. */
  26113. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26114. /**
  26115. * Sets up an animation
  26116. * @param property The property to animate
  26117. * @param animationType The animation type to apply
  26118. * @param framePerSecond The frames per second of the animation
  26119. * @param easingFunction The easing function used in the animation
  26120. * @returns The created animation
  26121. */
  26122. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26123. /**
  26124. * Create and start an animation on a node
  26125. * @param name defines the name of the global animation that will be run on all nodes
  26126. * @param node defines the root node where the animation will take place
  26127. * @param targetProperty defines property to animate
  26128. * @param framePerSecond defines the number of frame per second yo use
  26129. * @param totalFrame defines the number of frames in total
  26130. * @param from defines the initial value
  26131. * @param to defines the final value
  26132. * @param loopMode defines which loop mode you want to use (off by default)
  26133. * @param easingFunction defines the easing function to use (linear by default)
  26134. * @param onAnimationEnd defines the callback to call when animation end
  26135. * @returns the animatable created for this animation
  26136. */
  26137. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26138. /**
  26139. * Create and start an animation on a node and its descendants
  26140. * @param name defines the name of the global animation that will be run on all nodes
  26141. * @param node defines the root node where the animation will take place
  26142. * @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
  26143. * @param targetProperty defines property to animate
  26144. * @param framePerSecond defines the number of frame per second to use
  26145. * @param totalFrame defines the number of frames in total
  26146. * @param from defines the initial value
  26147. * @param to defines the final value
  26148. * @param loopMode defines which loop mode you want to use (off by default)
  26149. * @param easingFunction defines the easing function to use (linear by default)
  26150. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26151. * @returns the list of animatables created for all nodes
  26152. * @example https://www.babylonjs-playground.com/#MH0VLI
  26153. */
  26154. 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[]>;
  26155. /**
  26156. * Creates a new animation, merges it with the existing animations and starts it
  26157. * @param name Name of the animation
  26158. * @param node Node which contains the scene that begins the animations
  26159. * @param targetProperty Specifies which property to animate
  26160. * @param framePerSecond The frames per second of the animation
  26161. * @param totalFrame The total number of frames
  26162. * @param from The frame at the beginning of the animation
  26163. * @param to The frame at the end of the animation
  26164. * @param loopMode Specifies the loop mode of the animation
  26165. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26166. * @param onAnimationEnd Callback to run once the animation is complete
  26167. * @returns Nullable animation
  26168. */
  26169. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26170. /**
  26171. * Transition property of an host to the target Value
  26172. * @param property The property to transition
  26173. * @param targetValue The target Value of the property
  26174. * @param host The object where the property to animate belongs
  26175. * @param scene Scene used to run the animation
  26176. * @param frameRate Framerate (in frame/s) to use
  26177. * @param transition The transition type we want to use
  26178. * @param duration The duration of the animation, in milliseconds
  26179. * @param onAnimationEnd Callback trigger at the end of the animation
  26180. * @returns Nullable animation
  26181. */
  26182. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26183. /**
  26184. * Return the array of runtime animations currently using this animation
  26185. */
  26186. readonly runtimeAnimations: RuntimeAnimation[];
  26187. /**
  26188. * Specifies if any of the runtime animations are currently running
  26189. */
  26190. readonly hasRunningRuntimeAnimations: boolean;
  26191. /**
  26192. * Initializes the animation
  26193. * @param name Name of the animation
  26194. * @param targetProperty Property to animate
  26195. * @param framePerSecond The frames per second of the animation
  26196. * @param dataType The data type of the animation
  26197. * @param loopMode The loop mode of the animation
  26198. * @param enableBlending Specifies if blending should be enabled
  26199. */
  26200. constructor(
  26201. /**Name of the animation */
  26202. name: string,
  26203. /**Property to animate */
  26204. targetProperty: string,
  26205. /**The frames per second of the animation */
  26206. framePerSecond: number,
  26207. /**The data type of the animation */
  26208. dataType: number,
  26209. /**The loop mode of the animation */
  26210. loopMode?: number | undefined,
  26211. /**Specifies if blending should be enabled */
  26212. enableBlending?: boolean | undefined);
  26213. /**
  26214. * Converts the animation to a string
  26215. * @param fullDetails support for multiple levels of logging within scene loading
  26216. * @returns String form of the animation
  26217. */
  26218. toString(fullDetails?: boolean): string;
  26219. /**
  26220. * Add an event to this animation
  26221. * @param event Event to add
  26222. */
  26223. addEvent(event: AnimationEvent): void;
  26224. /**
  26225. * Remove all events found at the given frame
  26226. * @param frame The frame to remove events from
  26227. */
  26228. removeEvents(frame: number): void;
  26229. /**
  26230. * Retrieves all the events from the animation
  26231. * @returns Events from the animation
  26232. */
  26233. getEvents(): AnimationEvent[];
  26234. /**
  26235. * Creates an animation range
  26236. * @param name Name of the animation range
  26237. * @param from Starting frame of the animation range
  26238. * @param to Ending frame of the animation
  26239. */
  26240. createRange(name: string, from: number, to: number): void;
  26241. /**
  26242. * Deletes an animation range by name
  26243. * @param name Name of the animation range to delete
  26244. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26245. */
  26246. deleteRange(name: string, deleteFrames?: boolean): void;
  26247. /**
  26248. * Gets the animation range by name, or null if not defined
  26249. * @param name Name of the animation range
  26250. * @returns Nullable animation range
  26251. */
  26252. getRange(name: string): Nullable<AnimationRange>;
  26253. /**
  26254. * Gets the key frames from the animation
  26255. * @returns The key frames of the animation
  26256. */
  26257. getKeys(): Array<IAnimationKey>;
  26258. /**
  26259. * Gets the highest frame rate of the animation
  26260. * @returns Highest frame rate of the animation
  26261. */
  26262. getHighestFrame(): number;
  26263. /**
  26264. * Gets the easing function of the animation
  26265. * @returns Easing function of the animation
  26266. */
  26267. getEasingFunction(): IEasingFunction;
  26268. /**
  26269. * Sets the easing function of the animation
  26270. * @param easingFunction A custom mathematical formula for animation
  26271. */
  26272. setEasingFunction(easingFunction: EasingFunction): void;
  26273. /**
  26274. * Interpolates a scalar linearly
  26275. * @param startValue Start value of the animation curve
  26276. * @param endValue End value of the animation curve
  26277. * @param gradient Scalar amount to interpolate
  26278. * @returns Interpolated scalar value
  26279. */
  26280. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26281. /**
  26282. * Interpolates a scalar cubically
  26283. * @param startValue Start value of the animation curve
  26284. * @param outTangent End tangent of the animation
  26285. * @param endValue End value of the animation curve
  26286. * @param inTangent Start tangent of the animation curve
  26287. * @param gradient Scalar amount to interpolate
  26288. * @returns Interpolated scalar value
  26289. */
  26290. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26291. /**
  26292. * Interpolates a quaternion using a spherical linear interpolation
  26293. * @param startValue Start value of the animation curve
  26294. * @param endValue End value of the animation curve
  26295. * @param gradient Scalar amount to interpolate
  26296. * @returns Interpolated quaternion value
  26297. */
  26298. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26299. /**
  26300. * Interpolates a quaternion cubically
  26301. * @param startValue Start value of the animation curve
  26302. * @param outTangent End tangent of the animation curve
  26303. * @param endValue End value of the animation curve
  26304. * @param inTangent Start tangent of the animation curve
  26305. * @param gradient Scalar amount to interpolate
  26306. * @returns Interpolated quaternion value
  26307. */
  26308. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26309. /**
  26310. * Interpolates a Vector3 linearl
  26311. * @param startValue Start value of the animation curve
  26312. * @param endValue End value of the animation curve
  26313. * @param gradient Scalar amount to interpolate
  26314. * @returns Interpolated scalar value
  26315. */
  26316. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26317. /**
  26318. * Interpolates a Vector3 cubically
  26319. * @param startValue Start value of the animation curve
  26320. * @param outTangent End tangent of the animation
  26321. * @param endValue End value of the animation curve
  26322. * @param inTangent Start tangent of the animation curve
  26323. * @param gradient Scalar amount to interpolate
  26324. * @returns InterpolatedVector3 value
  26325. */
  26326. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26327. /**
  26328. * Interpolates a Vector2 linearly
  26329. * @param startValue Start value of the animation curve
  26330. * @param endValue End value of the animation curve
  26331. * @param gradient Scalar amount to interpolate
  26332. * @returns Interpolated Vector2 value
  26333. */
  26334. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26335. /**
  26336. * Interpolates a Vector2 cubically
  26337. * @param startValue Start value of the animation curve
  26338. * @param outTangent End tangent of the animation
  26339. * @param endValue End value of the animation curve
  26340. * @param inTangent Start tangent of the animation curve
  26341. * @param gradient Scalar amount to interpolate
  26342. * @returns Interpolated Vector2 value
  26343. */
  26344. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26345. /**
  26346. * Interpolates a size linearly
  26347. * @param startValue Start value of the animation curve
  26348. * @param endValue End value of the animation curve
  26349. * @param gradient Scalar amount to interpolate
  26350. * @returns Interpolated Size value
  26351. */
  26352. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26353. /**
  26354. * Interpolates a Color3 linearly
  26355. * @param startValue Start value of the animation curve
  26356. * @param endValue End value of the animation curve
  26357. * @param gradient Scalar amount to interpolate
  26358. * @returns Interpolated Color3 value
  26359. */
  26360. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26361. /**
  26362. * @hidden Internal use only
  26363. */
  26364. _getKeyValue(value: any): any;
  26365. /**
  26366. * @hidden Internal use only
  26367. */
  26368. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26369. /**
  26370. * Defines the function to use to interpolate matrices
  26371. * @param startValue defines the start matrix
  26372. * @param endValue defines the end matrix
  26373. * @param gradient defines the gradient between both matrices
  26374. * @param result defines an optional target matrix where to store the interpolation
  26375. * @returns the interpolated matrix
  26376. */
  26377. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26378. /**
  26379. * Makes a copy of the animation
  26380. * @returns Cloned animation
  26381. */
  26382. clone(): Animation;
  26383. /**
  26384. * Sets the key frames of the animation
  26385. * @param values The animation key frames to set
  26386. */
  26387. setKeys(values: Array<IAnimationKey>): void;
  26388. /**
  26389. * Serializes the animation to an object
  26390. * @returns Serialized object
  26391. */
  26392. serialize(): any;
  26393. /**
  26394. * Float animation type
  26395. */
  26396. private static _ANIMATIONTYPE_FLOAT;
  26397. /**
  26398. * Vector3 animation type
  26399. */
  26400. private static _ANIMATIONTYPE_VECTOR3;
  26401. /**
  26402. * Quaternion animation type
  26403. */
  26404. private static _ANIMATIONTYPE_QUATERNION;
  26405. /**
  26406. * Matrix animation type
  26407. */
  26408. private static _ANIMATIONTYPE_MATRIX;
  26409. /**
  26410. * Color3 animation type
  26411. */
  26412. private static _ANIMATIONTYPE_COLOR3;
  26413. /**
  26414. * Vector2 animation type
  26415. */
  26416. private static _ANIMATIONTYPE_VECTOR2;
  26417. /**
  26418. * Size animation type
  26419. */
  26420. private static _ANIMATIONTYPE_SIZE;
  26421. /**
  26422. * Relative Loop Mode
  26423. */
  26424. private static _ANIMATIONLOOPMODE_RELATIVE;
  26425. /**
  26426. * Cycle Loop Mode
  26427. */
  26428. private static _ANIMATIONLOOPMODE_CYCLE;
  26429. /**
  26430. * Constant Loop Mode
  26431. */
  26432. private static _ANIMATIONLOOPMODE_CONSTANT;
  26433. /**
  26434. * Get the float animation type
  26435. */
  26436. static readonly ANIMATIONTYPE_FLOAT: number;
  26437. /**
  26438. * Get the Vector3 animation type
  26439. */
  26440. static readonly ANIMATIONTYPE_VECTOR3: number;
  26441. /**
  26442. * Get the Vector2 animation type
  26443. */
  26444. static readonly ANIMATIONTYPE_VECTOR2: number;
  26445. /**
  26446. * Get the Size animation type
  26447. */
  26448. static readonly ANIMATIONTYPE_SIZE: number;
  26449. /**
  26450. * Get the Quaternion animation type
  26451. */
  26452. static readonly ANIMATIONTYPE_QUATERNION: number;
  26453. /**
  26454. * Get the Matrix animation type
  26455. */
  26456. static readonly ANIMATIONTYPE_MATRIX: number;
  26457. /**
  26458. * Get the Color3 animation type
  26459. */
  26460. static readonly ANIMATIONTYPE_COLOR3: number;
  26461. /**
  26462. * Get the Relative Loop Mode
  26463. */
  26464. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26465. /**
  26466. * Get the Cycle Loop Mode
  26467. */
  26468. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26469. /**
  26470. * Get the Constant Loop Mode
  26471. */
  26472. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26473. /** @hidden */
  26474. static _UniversalLerp(left: any, right: any, amount: number): any;
  26475. /**
  26476. * Parses an animation object and creates an animation
  26477. * @param parsedAnimation Parsed animation object
  26478. * @returns Animation object
  26479. */
  26480. static Parse(parsedAnimation: any): Animation;
  26481. /**
  26482. * Appends the serialized animations from the source animations
  26483. * @param source Source containing the animations
  26484. * @param destination Target to store the animations
  26485. */
  26486. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26487. }
  26488. }
  26489. declare module "babylonjs/Materials/Textures/baseTexture" {
  26490. import { Observable } from "babylonjs/Misc/observable";
  26491. import { IAnimatable } from "babylonjs/Misc/tools";
  26492. import { Nullable } from "babylonjs/types";
  26493. import { Scene } from "babylonjs/scene";
  26494. import { Matrix, ISize } from "babylonjs/Maths/math";
  26495. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26497. /**
  26498. * Base class of all the textures in babylon.
  26499. * It groups all the common properties the materials, post process, lights... might need
  26500. * in order to make a correct use of the texture.
  26501. */
  26502. export class BaseTexture implements IAnimatable {
  26503. /**
  26504. * Default anisotropic filtering level for the application.
  26505. * It is set to 4 as a good tradeoff between perf and quality.
  26506. */
  26507. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26508. /**
  26509. * Gets or sets the unique id of the texture
  26510. */
  26511. uniqueId: number;
  26512. /**
  26513. * Define the name of the texture.
  26514. */
  26515. name: string;
  26516. /**
  26517. * Gets or sets an object used to store user defined information.
  26518. */
  26519. metadata: any;
  26520. /**
  26521. * For internal use only. Please do not use.
  26522. */
  26523. reservedDataStore: any;
  26524. private _hasAlpha;
  26525. /**
  26526. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26527. */
  26528. hasAlpha: boolean;
  26529. /**
  26530. * Defines if the alpha value should be determined via the rgb values.
  26531. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26532. */
  26533. getAlphaFromRGB: boolean;
  26534. /**
  26535. * Intensity or strength of the texture.
  26536. * It is commonly used by materials to fine tune the intensity of the texture
  26537. */
  26538. level: number;
  26539. /**
  26540. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26541. * This is part of the texture as textures usually maps to one uv set.
  26542. */
  26543. coordinatesIndex: number;
  26544. private _coordinatesMode;
  26545. /**
  26546. * How a texture is mapped.
  26547. *
  26548. * | Value | Type | Description |
  26549. * | ----- | ----------------------------------- | ----------- |
  26550. * | 0 | EXPLICIT_MODE | |
  26551. * | 1 | SPHERICAL_MODE | |
  26552. * | 2 | PLANAR_MODE | |
  26553. * | 3 | CUBIC_MODE | |
  26554. * | 4 | PROJECTION_MODE | |
  26555. * | 5 | SKYBOX_MODE | |
  26556. * | 6 | INVCUBIC_MODE | |
  26557. * | 7 | EQUIRECTANGULAR_MODE | |
  26558. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26559. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26560. */
  26561. coordinatesMode: number;
  26562. /**
  26563. * | Value | Type | Description |
  26564. * | ----- | ------------------ | ----------- |
  26565. * | 0 | CLAMP_ADDRESSMODE | |
  26566. * | 1 | WRAP_ADDRESSMODE | |
  26567. * | 2 | MIRROR_ADDRESSMODE | |
  26568. */
  26569. wrapU: number;
  26570. /**
  26571. * | Value | Type | Description |
  26572. * | ----- | ------------------ | ----------- |
  26573. * | 0 | CLAMP_ADDRESSMODE | |
  26574. * | 1 | WRAP_ADDRESSMODE | |
  26575. * | 2 | MIRROR_ADDRESSMODE | |
  26576. */
  26577. wrapV: number;
  26578. /**
  26579. * | Value | Type | Description |
  26580. * | ----- | ------------------ | ----------- |
  26581. * | 0 | CLAMP_ADDRESSMODE | |
  26582. * | 1 | WRAP_ADDRESSMODE | |
  26583. * | 2 | MIRROR_ADDRESSMODE | |
  26584. */
  26585. wrapR: number;
  26586. /**
  26587. * With compliant hardware and browser (supporting anisotropic filtering)
  26588. * this defines the level of anisotropic filtering in the texture.
  26589. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26590. */
  26591. anisotropicFilteringLevel: number;
  26592. /**
  26593. * Define if the texture is a cube texture or if false a 2d texture.
  26594. */
  26595. isCube: boolean;
  26596. /**
  26597. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26598. */
  26599. is3D: boolean;
  26600. /**
  26601. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26602. * HDR texture are usually stored in linear space.
  26603. * This only impacts the PBR and Background materials
  26604. */
  26605. gammaSpace: boolean;
  26606. /**
  26607. * Gets whether or not the texture contains RGBD data.
  26608. */
  26609. readonly isRGBD: boolean;
  26610. /**
  26611. * Is Z inverted in the texture (useful in a cube texture).
  26612. */
  26613. invertZ: boolean;
  26614. /**
  26615. * Are mip maps generated for this texture or not.
  26616. */
  26617. readonly noMipmap: boolean;
  26618. /**
  26619. * @hidden
  26620. */
  26621. lodLevelInAlpha: boolean;
  26622. /**
  26623. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26624. */
  26625. lodGenerationOffset: number;
  26626. /**
  26627. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26628. */
  26629. lodGenerationScale: number;
  26630. /**
  26631. * Define if the texture is a render target.
  26632. */
  26633. isRenderTarget: boolean;
  26634. /**
  26635. * Define the unique id of the texture in the scene.
  26636. */
  26637. readonly uid: string;
  26638. /**
  26639. * Return a string representation of the texture.
  26640. * @returns the texture as a string
  26641. */
  26642. toString(): string;
  26643. /**
  26644. * Get the class name of the texture.
  26645. * @returns "BaseTexture"
  26646. */
  26647. getClassName(): string;
  26648. /**
  26649. * Define the list of animation attached to the texture.
  26650. */
  26651. animations: import("babylonjs/Animations/animation").Animation[];
  26652. /**
  26653. * An event triggered when the texture is disposed.
  26654. */
  26655. onDisposeObservable: Observable<BaseTexture>;
  26656. private _onDisposeObserver;
  26657. /**
  26658. * Callback triggered when the texture has been disposed.
  26659. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26660. */
  26661. onDispose: () => void;
  26662. /**
  26663. * Define the current state of the loading sequence when in delayed load mode.
  26664. */
  26665. delayLoadState: number;
  26666. private _scene;
  26667. /** @hidden */
  26668. _texture: Nullable<InternalTexture>;
  26669. private _uid;
  26670. /**
  26671. * Define if the texture is preventinga material to render or not.
  26672. * If not and the texture is not ready, the engine will use a default black texture instead.
  26673. */
  26674. readonly isBlocking: boolean;
  26675. /**
  26676. * Instantiates a new BaseTexture.
  26677. * Base class of all the textures in babylon.
  26678. * It groups all the common properties the materials, post process, lights... might need
  26679. * in order to make a correct use of the texture.
  26680. * @param scene Define the scene the texture blongs to
  26681. */
  26682. constructor(scene: Nullable<Scene>);
  26683. /**
  26684. * Get the scene the texture belongs to.
  26685. * @returns the scene or null if undefined
  26686. */
  26687. getScene(): Nullable<Scene>;
  26688. /**
  26689. * Get the texture transform matrix used to offset tile the texture for istance.
  26690. * @returns the transformation matrix
  26691. */
  26692. getTextureMatrix(): Matrix;
  26693. /**
  26694. * Get the texture reflection matrix used to rotate/transform the reflection.
  26695. * @returns the reflection matrix
  26696. */
  26697. getReflectionTextureMatrix(): Matrix;
  26698. /**
  26699. * Get the underlying lower level texture from Babylon.
  26700. * @returns the insternal texture
  26701. */
  26702. getInternalTexture(): Nullable<InternalTexture>;
  26703. /**
  26704. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26705. * @returns true if ready or not blocking
  26706. */
  26707. isReadyOrNotBlocking(): boolean;
  26708. /**
  26709. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26710. * @returns true if fully ready
  26711. */
  26712. isReady(): boolean;
  26713. private _cachedSize;
  26714. /**
  26715. * Get the size of the texture.
  26716. * @returns the texture size.
  26717. */
  26718. getSize(): ISize;
  26719. /**
  26720. * Get the base size of the texture.
  26721. * It can be different from the size if the texture has been resized for POT for instance
  26722. * @returns the base size
  26723. */
  26724. getBaseSize(): ISize;
  26725. /**
  26726. * Update the sampling mode of the texture.
  26727. * Default is Trilinear mode.
  26728. *
  26729. * | Value | Type | Description |
  26730. * | ----- | ------------------ | ----------- |
  26731. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26732. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26733. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26734. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26735. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26736. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26737. * | 7 | NEAREST_LINEAR | |
  26738. * | 8 | NEAREST_NEAREST | |
  26739. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26740. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26741. * | 11 | LINEAR_LINEAR | |
  26742. * | 12 | LINEAR_NEAREST | |
  26743. *
  26744. * > _mag_: magnification filter (close to the viewer)
  26745. * > _min_: minification filter (far from the viewer)
  26746. * > _mip_: filter used between mip map levels
  26747. *@param samplingMode Define the new sampling mode of the texture
  26748. */
  26749. updateSamplingMode(samplingMode: number): void;
  26750. /**
  26751. * Scales the texture if is `canRescale()`
  26752. * @param ratio the resize factor we want to use to rescale
  26753. */
  26754. scale(ratio: number): void;
  26755. /**
  26756. * Get if the texture can rescale.
  26757. */
  26758. readonly canRescale: boolean;
  26759. /** @hidden */
  26760. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26761. /** @hidden */
  26762. _rebuild(): void;
  26763. /**
  26764. * Triggers the load sequence in delayed load mode.
  26765. */
  26766. delayLoad(): void;
  26767. /**
  26768. * Clones the texture.
  26769. * @returns the cloned texture
  26770. */
  26771. clone(): Nullable<BaseTexture>;
  26772. /**
  26773. * Get the texture underlying type (INT, FLOAT...)
  26774. */
  26775. readonly textureType: number;
  26776. /**
  26777. * Get the texture underlying format (RGB, RGBA...)
  26778. */
  26779. readonly textureFormat: number;
  26780. /**
  26781. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26782. * This will returns an RGBA array buffer containing either in values (0-255) or
  26783. * float values (0-1) depending of the underlying buffer type.
  26784. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26785. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26786. * @param buffer defines a user defined buffer to fill with data (can be null)
  26787. * @returns The Array buffer containing the pixels data.
  26788. */
  26789. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26790. /**
  26791. * Release and destroy the underlying lower level texture aka internalTexture.
  26792. */
  26793. releaseInternalTexture(): void;
  26794. /**
  26795. * Get the polynomial representation of the texture data.
  26796. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26797. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26798. */
  26799. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26800. /** @hidden */
  26801. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26802. /** @hidden */
  26803. readonly _lodTextureMid: Nullable<BaseTexture>;
  26804. /** @hidden */
  26805. readonly _lodTextureLow: Nullable<BaseTexture>;
  26806. /**
  26807. * Dispose the texture and release its associated resources.
  26808. */
  26809. dispose(): void;
  26810. /**
  26811. * Serialize the texture into a JSON representation that can be parsed later on.
  26812. * @returns the JSON representation of the texture
  26813. */
  26814. serialize(): any;
  26815. /**
  26816. * Helper function to be called back once a list of texture contains only ready textures.
  26817. * @param textures Define the list of textures to wait for
  26818. * @param callback Define the callback triggered once the entire list will be ready
  26819. */
  26820. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26821. }
  26822. }
  26823. declare module "babylonjs/Materials/uniformBuffer" {
  26824. import { Nullable, FloatArray } from "babylonjs/types";
  26825. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26826. import { Engine } from "babylonjs/Engines/engine";
  26827. import { Effect } from "babylonjs/Materials/effect";
  26828. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26829. /**
  26830. * Uniform buffer objects.
  26831. *
  26832. * Handles blocks of uniform on the GPU.
  26833. *
  26834. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26835. *
  26836. * For more information, please refer to :
  26837. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26838. */
  26839. export class UniformBuffer {
  26840. private _engine;
  26841. private _buffer;
  26842. private _data;
  26843. private _bufferData;
  26844. private _dynamic?;
  26845. private _uniformLocations;
  26846. private _uniformSizes;
  26847. private _uniformLocationPointer;
  26848. private _needSync;
  26849. private _noUBO;
  26850. private _currentEffect;
  26851. private static _MAX_UNIFORM_SIZE;
  26852. private static _tempBuffer;
  26853. /**
  26854. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26855. * This is dynamic to allow compat with webgl 1 and 2.
  26856. * You will need to pass the name of the uniform as well as the value.
  26857. */
  26858. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26859. /**
  26860. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26861. * This is dynamic to allow compat with webgl 1 and 2.
  26862. * You will need to pass the name of the uniform as well as the value.
  26863. */
  26864. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26865. /**
  26866. * Lambda to Update a single float in a uniform buffer.
  26867. * This is dynamic to allow compat with webgl 1 and 2.
  26868. * You will need to pass the name of the uniform as well as the value.
  26869. */
  26870. updateFloat: (name: string, x: number) => void;
  26871. /**
  26872. * Lambda to Update a vec2 of float in a uniform buffer.
  26873. * This is dynamic to allow compat with webgl 1 and 2.
  26874. * You will need to pass the name of the uniform as well as the value.
  26875. */
  26876. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26877. /**
  26878. * Lambda to Update a vec3 of float in a uniform buffer.
  26879. * This is dynamic to allow compat with webgl 1 and 2.
  26880. * You will need to pass the name of the uniform as well as the value.
  26881. */
  26882. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26883. /**
  26884. * Lambda to Update a vec4 of float in a uniform buffer.
  26885. * This is dynamic to allow compat with webgl 1 and 2.
  26886. * You will need to pass the name of the uniform as well as the value.
  26887. */
  26888. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26889. /**
  26890. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26891. * This is dynamic to allow compat with webgl 1 and 2.
  26892. * You will need to pass the name of the uniform as well as the value.
  26893. */
  26894. updateMatrix: (name: string, mat: Matrix) => void;
  26895. /**
  26896. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26897. * This is dynamic to allow compat with webgl 1 and 2.
  26898. * You will need to pass the name of the uniform as well as the value.
  26899. */
  26900. updateVector3: (name: string, vector: Vector3) => void;
  26901. /**
  26902. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26903. * This is dynamic to allow compat with webgl 1 and 2.
  26904. * You will need to pass the name of the uniform as well as the value.
  26905. */
  26906. updateVector4: (name: string, vector: Vector4) => void;
  26907. /**
  26908. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26909. * This is dynamic to allow compat with webgl 1 and 2.
  26910. * You will need to pass the name of the uniform as well as the value.
  26911. */
  26912. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26913. /**
  26914. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26915. * This is dynamic to allow compat with webgl 1 and 2.
  26916. * You will need to pass the name of the uniform as well as the value.
  26917. */
  26918. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26919. /**
  26920. * Instantiates a new Uniform buffer objects.
  26921. *
  26922. * Handles blocks of uniform on the GPU.
  26923. *
  26924. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26925. *
  26926. * For more information, please refer to :
  26927. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26928. * @param engine Define the engine the buffer is associated with
  26929. * @param data Define the data contained in the buffer
  26930. * @param dynamic Define if the buffer is updatable
  26931. */
  26932. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26933. /**
  26934. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26935. * or just falling back on setUniformXXX calls.
  26936. */
  26937. readonly useUbo: boolean;
  26938. /**
  26939. * Indicates if the WebGL underlying uniform buffer is in sync
  26940. * with the javascript cache data.
  26941. */
  26942. readonly isSync: boolean;
  26943. /**
  26944. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26945. * Also, a dynamic UniformBuffer will disable cache verification and always
  26946. * update the underlying WebGL uniform buffer to the GPU.
  26947. * @returns if Dynamic, otherwise false
  26948. */
  26949. isDynamic(): boolean;
  26950. /**
  26951. * The data cache on JS side.
  26952. * @returns the underlying data as a float array
  26953. */
  26954. getData(): Float32Array;
  26955. /**
  26956. * The underlying WebGL Uniform buffer.
  26957. * @returns the webgl buffer
  26958. */
  26959. getBuffer(): Nullable<WebGLBuffer>;
  26960. /**
  26961. * std140 layout specifies how to align data within an UBO structure.
  26962. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26963. * for specs.
  26964. */
  26965. private _fillAlignment;
  26966. /**
  26967. * Adds an uniform in the buffer.
  26968. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26969. * for the layout to be correct !
  26970. * @param name Name of the uniform, as used in the uniform block in the shader.
  26971. * @param size Data size, or data directly.
  26972. */
  26973. addUniform(name: string, size: number | number[]): void;
  26974. /**
  26975. * Adds a Matrix 4x4 to the uniform buffer.
  26976. * @param name Name of the uniform, as used in the uniform block in the shader.
  26977. * @param mat A 4x4 matrix.
  26978. */
  26979. addMatrix(name: string, mat: Matrix): void;
  26980. /**
  26981. * Adds a vec2 to the uniform buffer.
  26982. * @param name Name of the uniform, as used in the uniform block in the shader.
  26983. * @param x Define the x component value of the vec2
  26984. * @param y Define the y component value of the vec2
  26985. */
  26986. addFloat2(name: string, x: number, y: number): void;
  26987. /**
  26988. * Adds a vec3 to the uniform buffer.
  26989. * @param name Name of the uniform, as used in the uniform block in the shader.
  26990. * @param x Define the x component value of the vec3
  26991. * @param y Define the y component value of the vec3
  26992. * @param z Define the z component value of the vec3
  26993. */
  26994. addFloat3(name: string, x: number, y: number, z: number): void;
  26995. /**
  26996. * Adds a vec3 to the uniform buffer.
  26997. * @param name Name of the uniform, as used in the uniform block in the shader.
  26998. * @param color Define the vec3 from a Color
  26999. */
  27000. addColor3(name: string, color: Color3): void;
  27001. /**
  27002. * Adds a vec4 to the uniform buffer.
  27003. * @param name Name of the uniform, as used in the uniform block in the shader.
  27004. * @param color Define the rgb components from a Color
  27005. * @param alpha Define the a component of the vec4
  27006. */
  27007. addColor4(name: string, color: Color3, alpha: number): void;
  27008. /**
  27009. * Adds a vec3 to the uniform buffer.
  27010. * @param name Name of the uniform, as used in the uniform block in the shader.
  27011. * @param vector Define the vec3 components from a Vector
  27012. */
  27013. addVector3(name: string, vector: Vector3): void;
  27014. /**
  27015. * Adds a Matrix 3x3 to the uniform buffer.
  27016. * @param name Name of the uniform, as used in the uniform block in the shader.
  27017. */
  27018. addMatrix3x3(name: string): void;
  27019. /**
  27020. * Adds a Matrix 2x2 to the uniform buffer.
  27021. * @param name Name of the uniform, as used in the uniform block in the shader.
  27022. */
  27023. addMatrix2x2(name: string): void;
  27024. /**
  27025. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27026. */
  27027. create(): void;
  27028. /** @hidden */
  27029. _rebuild(): void;
  27030. /**
  27031. * Updates the WebGL Uniform Buffer on the GPU.
  27032. * If the `dynamic` flag is set to true, no cache comparison is done.
  27033. * Otherwise, the buffer will be updated only if the cache differs.
  27034. */
  27035. update(): void;
  27036. /**
  27037. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27038. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27039. * @param data Define the flattened data
  27040. * @param size Define the size of the data.
  27041. */
  27042. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27043. private _updateMatrix3x3ForUniform;
  27044. private _updateMatrix3x3ForEffect;
  27045. private _updateMatrix2x2ForEffect;
  27046. private _updateMatrix2x2ForUniform;
  27047. private _updateFloatForEffect;
  27048. private _updateFloatForUniform;
  27049. private _updateFloat2ForEffect;
  27050. private _updateFloat2ForUniform;
  27051. private _updateFloat3ForEffect;
  27052. private _updateFloat3ForUniform;
  27053. private _updateFloat4ForEffect;
  27054. private _updateFloat4ForUniform;
  27055. private _updateMatrixForEffect;
  27056. private _updateMatrixForUniform;
  27057. private _updateVector3ForEffect;
  27058. private _updateVector3ForUniform;
  27059. private _updateVector4ForEffect;
  27060. private _updateVector4ForUniform;
  27061. private _updateColor3ForEffect;
  27062. private _updateColor3ForUniform;
  27063. private _updateColor4ForEffect;
  27064. private _updateColor4ForUniform;
  27065. /**
  27066. * Sets a sampler uniform on the effect.
  27067. * @param name Define the name of the sampler.
  27068. * @param texture Define the texture to set in the sampler
  27069. */
  27070. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27071. /**
  27072. * Directly updates the value of the uniform in the cache AND on the GPU.
  27073. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27074. * @param data Define the flattened data
  27075. */
  27076. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27077. /**
  27078. * Binds this uniform buffer to an effect.
  27079. * @param effect Define the effect to bind the buffer to
  27080. * @param name Name of the uniform block in the shader.
  27081. */
  27082. bindToEffect(effect: Effect, name: string): void;
  27083. /**
  27084. * Disposes the uniform buffer.
  27085. */
  27086. dispose(): void;
  27087. }
  27088. }
  27089. declare module "babylonjs/Audio/analyser" {
  27090. import { Scene } from "babylonjs/scene";
  27091. /**
  27092. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27094. */
  27095. export class Analyser {
  27096. /**
  27097. * Gets or sets the smoothing
  27098. * @ignorenaming
  27099. */
  27100. SMOOTHING: number;
  27101. /**
  27102. * Gets or sets the FFT table size
  27103. * @ignorenaming
  27104. */
  27105. FFT_SIZE: number;
  27106. /**
  27107. * Gets or sets the bar graph amplitude
  27108. * @ignorenaming
  27109. */
  27110. BARGRAPHAMPLITUDE: number;
  27111. /**
  27112. * Gets or sets the position of the debug canvas
  27113. * @ignorenaming
  27114. */
  27115. DEBUGCANVASPOS: {
  27116. x: number;
  27117. y: number;
  27118. };
  27119. /**
  27120. * Gets or sets the debug canvas size
  27121. * @ignorenaming
  27122. */
  27123. DEBUGCANVASSIZE: {
  27124. width: number;
  27125. height: number;
  27126. };
  27127. private _byteFreqs;
  27128. private _byteTime;
  27129. private _floatFreqs;
  27130. private _webAudioAnalyser;
  27131. private _debugCanvas;
  27132. private _debugCanvasContext;
  27133. private _scene;
  27134. private _registerFunc;
  27135. private _audioEngine;
  27136. /**
  27137. * Creates a new analyser
  27138. * @param scene defines hosting scene
  27139. */
  27140. constructor(scene: Scene);
  27141. /**
  27142. * Get the number of data values you will have to play with for the visualization
  27143. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27144. * @returns a number
  27145. */
  27146. getFrequencyBinCount(): number;
  27147. /**
  27148. * Gets the current frequency data as a byte array
  27149. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27150. * @returns a Uint8Array
  27151. */
  27152. getByteFrequencyData(): Uint8Array;
  27153. /**
  27154. * Gets the current waveform as a byte array
  27155. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27156. * @returns a Uint8Array
  27157. */
  27158. getByteTimeDomainData(): Uint8Array;
  27159. /**
  27160. * Gets the current frequency data as a float array
  27161. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27162. * @returns a Float32Array
  27163. */
  27164. getFloatFrequencyData(): Float32Array;
  27165. /**
  27166. * Renders the debug canvas
  27167. */
  27168. drawDebugCanvas(): void;
  27169. /**
  27170. * Stops rendering the debug canvas and removes it
  27171. */
  27172. stopDebugCanvas(): void;
  27173. /**
  27174. * Connects two audio nodes
  27175. * @param inputAudioNode defines first node to connect
  27176. * @param outputAudioNode defines second node to connect
  27177. */
  27178. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27179. /**
  27180. * Releases all associated resources
  27181. */
  27182. dispose(): void;
  27183. }
  27184. }
  27185. declare module "babylonjs/Audio/audioEngine" {
  27186. import { IDisposable } from "babylonjs/scene";
  27187. import { Analyser } from "babylonjs/Audio/analyser";
  27188. import { Nullable } from "babylonjs/types";
  27189. import { Observable } from "babylonjs/Misc/observable";
  27190. /**
  27191. * This represents an audio engine and it is responsible
  27192. * to play, synchronize and analyse sounds throughout the application.
  27193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27194. */
  27195. export interface IAudioEngine extends IDisposable {
  27196. /**
  27197. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27198. */
  27199. readonly canUseWebAudio: boolean;
  27200. /**
  27201. * Gets the current AudioContext if available.
  27202. */
  27203. readonly audioContext: Nullable<AudioContext>;
  27204. /**
  27205. * The master gain node defines the global audio volume of your audio engine.
  27206. */
  27207. readonly masterGain: GainNode;
  27208. /**
  27209. * Gets whether or not mp3 are supported by your browser.
  27210. */
  27211. readonly isMP3supported: boolean;
  27212. /**
  27213. * Gets whether or not ogg are supported by your browser.
  27214. */
  27215. readonly isOGGsupported: boolean;
  27216. /**
  27217. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27218. * @ignoreNaming
  27219. */
  27220. WarnedWebAudioUnsupported: boolean;
  27221. /**
  27222. * Defines if the audio engine relies on a custom unlocked button.
  27223. * In this case, the embedded button will not be displayed.
  27224. */
  27225. useCustomUnlockedButton: boolean;
  27226. /**
  27227. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27228. */
  27229. readonly unlocked: boolean;
  27230. /**
  27231. * Event raised when audio has been unlocked on the browser.
  27232. */
  27233. onAudioUnlockedObservable: Observable<AudioEngine>;
  27234. /**
  27235. * Event raised when audio has been locked on the browser.
  27236. */
  27237. onAudioLockedObservable: Observable<AudioEngine>;
  27238. /**
  27239. * Flags the audio engine in Locked state.
  27240. * This happens due to new browser policies preventing audio to autoplay.
  27241. */
  27242. lock(): void;
  27243. /**
  27244. * Unlocks the audio engine once a user action has been done on the dom.
  27245. * This is helpful to resume play once browser policies have been satisfied.
  27246. */
  27247. unlock(): void;
  27248. }
  27249. /**
  27250. * This represents the default audio engine used in babylon.
  27251. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27253. */
  27254. export class AudioEngine implements IAudioEngine {
  27255. private _audioContext;
  27256. private _audioContextInitialized;
  27257. private _muteButton;
  27258. private _hostElement;
  27259. /**
  27260. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27261. */
  27262. canUseWebAudio: boolean;
  27263. /**
  27264. * The master gain node defines the global audio volume of your audio engine.
  27265. */
  27266. masterGain: GainNode;
  27267. /**
  27268. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27269. * @ignoreNaming
  27270. */
  27271. WarnedWebAudioUnsupported: boolean;
  27272. /**
  27273. * Gets whether or not mp3 are supported by your browser.
  27274. */
  27275. isMP3supported: boolean;
  27276. /**
  27277. * Gets whether or not ogg are supported by your browser.
  27278. */
  27279. isOGGsupported: boolean;
  27280. /**
  27281. * Gets whether audio has been unlocked on the device.
  27282. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27283. * a user interaction has happened.
  27284. */
  27285. unlocked: boolean;
  27286. /**
  27287. * Defines if the audio engine relies on a custom unlocked button.
  27288. * In this case, the embedded button will not be displayed.
  27289. */
  27290. useCustomUnlockedButton: boolean;
  27291. /**
  27292. * Event raised when audio has been unlocked on the browser.
  27293. */
  27294. onAudioUnlockedObservable: Observable<AudioEngine>;
  27295. /**
  27296. * Event raised when audio has been locked on the browser.
  27297. */
  27298. onAudioLockedObservable: Observable<AudioEngine>;
  27299. /**
  27300. * Gets the current AudioContext if available.
  27301. */
  27302. readonly audioContext: Nullable<AudioContext>;
  27303. private _connectedAnalyser;
  27304. /**
  27305. * Instantiates a new audio engine.
  27306. *
  27307. * There should be only one per page as some browsers restrict the number
  27308. * of audio contexts you can create.
  27309. * @param hostElement defines the host element where to display the mute icon if necessary
  27310. */
  27311. constructor(hostElement?: Nullable<HTMLElement>);
  27312. /**
  27313. * Flags the audio engine in Locked state.
  27314. * This happens due to new browser policies preventing audio to autoplay.
  27315. */
  27316. lock(): void;
  27317. /**
  27318. * Unlocks the audio engine once a user action has been done on the dom.
  27319. * This is helpful to resume play once browser policies have been satisfied.
  27320. */
  27321. unlock(): void;
  27322. private _resumeAudioContext;
  27323. private _initializeAudioContext;
  27324. private _tryToRun;
  27325. private _triggerRunningState;
  27326. private _triggerSuspendedState;
  27327. private _displayMuteButton;
  27328. private _moveButtonToTopLeft;
  27329. private _onResize;
  27330. private _hideMuteButton;
  27331. /**
  27332. * Destroy and release the resources associated with the audio ccontext.
  27333. */
  27334. dispose(): void;
  27335. /**
  27336. * Gets the global volume sets on the master gain.
  27337. * @returns the global volume if set or -1 otherwise
  27338. */
  27339. getGlobalVolume(): number;
  27340. /**
  27341. * Sets the global volume of your experience (sets on the master gain).
  27342. * @param newVolume Defines the new global volume of the application
  27343. */
  27344. setGlobalVolume(newVolume: number): void;
  27345. /**
  27346. * Connect the audio engine to an audio analyser allowing some amazing
  27347. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27349. * @param analyser The analyser to connect to the engine
  27350. */
  27351. connectToAnalyser(analyser: Analyser): void;
  27352. }
  27353. }
  27354. declare module "babylonjs/Loading/loadingScreen" {
  27355. /**
  27356. * Interface used to present a loading screen while loading a scene
  27357. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27358. */
  27359. export interface ILoadingScreen {
  27360. /**
  27361. * Function called to display the loading screen
  27362. */
  27363. displayLoadingUI: () => void;
  27364. /**
  27365. * Function called to hide the loading screen
  27366. */
  27367. hideLoadingUI: () => void;
  27368. /**
  27369. * Gets or sets the color to use for the background
  27370. */
  27371. loadingUIBackgroundColor: string;
  27372. /**
  27373. * Gets or sets the text to display while loading
  27374. */
  27375. loadingUIText: string;
  27376. }
  27377. /**
  27378. * Class used for the default loading screen
  27379. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27380. */
  27381. export class DefaultLoadingScreen implements ILoadingScreen {
  27382. private _renderingCanvas;
  27383. private _loadingText;
  27384. private _loadingDivBackgroundColor;
  27385. private _loadingDiv;
  27386. private _loadingTextDiv;
  27387. /**
  27388. * Creates a new default loading screen
  27389. * @param _renderingCanvas defines the canvas used to render the scene
  27390. * @param _loadingText defines the default text to display
  27391. * @param _loadingDivBackgroundColor defines the default background color
  27392. */
  27393. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27394. /**
  27395. * Function called to display the loading screen
  27396. */
  27397. displayLoadingUI(): void;
  27398. /**
  27399. * Function called to hide the loading screen
  27400. */
  27401. hideLoadingUI(): void;
  27402. /**
  27403. * Gets or sets the text to display while loading
  27404. */
  27405. loadingUIText: string;
  27406. /**
  27407. * Gets or sets the color to use for the background
  27408. */
  27409. loadingUIBackgroundColor: string;
  27410. private _resizeLoadingUI;
  27411. }
  27412. }
  27413. declare module "babylonjs/Materials/Textures/videoTexture" {
  27414. import { Observable } from "babylonjs/Misc/observable";
  27415. import { Nullable } from "babylonjs/types";
  27416. import { Scene } from "babylonjs/scene";
  27417. import { Texture } from "babylonjs/Materials/Textures/texture";
  27418. /**
  27419. * Settings for finer control over video usage
  27420. */
  27421. export interface VideoTextureSettings {
  27422. /**
  27423. * Applies `autoplay` to video, if specified
  27424. */
  27425. autoPlay?: boolean;
  27426. /**
  27427. * Applies `loop` to video, if specified
  27428. */
  27429. loop?: boolean;
  27430. /**
  27431. * Automatically updates internal texture from video at every frame in the render loop
  27432. */
  27433. autoUpdateTexture: boolean;
  27434. /**
  27435. * Image src displayed during the video loading or until the user interacts with the video.
  27436. */
  27437. poster?: string;
  27438. }
  27439. /**
  27440. * If you want to display a video in your scene, this is the special texture for that.
  27441. * This special texture works similar to other textures, with the exception of a few parameters.
  27442. * @see https://doc.babylonjs.com/how_to/video_texture
  27443. */
  27444. export class VideoTexture extends Texture {
  27445. /**
  27446. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27447. */
  27448. readonly autoUpdateTexture: boolean;
  27449. /**
  27450. * The video instance used by the texture internally
  27451. */
  27452. readonly video: HTMLVideoElement;
  27453. private _onUserActionRequestedObservable;
  27454. /**
  27455. * Event triggerd when a dom action is required by the user to play the video.
  27456. * This happens due to recent changes in browser policies preventing video to auto start.
  27457. */
  27458. readonly onUserActionRequestedObservable: Observable<Texture>;
  27459. private _generateMipMaps;
  27460. private _engine;
  27461. private _stillImageCaptured;
  27462. private _displayingPosterTexture;
  27463. private _settings;
  27464. private _createInternalTextureOnEvent;
  27465. /**
  27466. * Creates a video texture.
  27467. * If you want to display a video in your scene, this is the special texture for that.
  27468. * This special texture works similar to other textures, with the exception of a few parameters.
  27469. * @see https://doc.babylonjs.com/how_to/video_texture
  27470. * @param name optional name, will detect from video source, if not defined
  27471. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27472. * @param scene is obviously the current scene.
  27473. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27474. * @param invertY is false by default but can be used to invert video on Y axis
  27475. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27476. * @param settings allows finer control over video usage
  27477. */
  27478. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27479. private _getName;
  27480. private _getVideo;
  27481. private _createInternalTexture;
  27482. private reset;
  27483. /**
  27484. * @hidden Internal method to initiate `update`.
  27485. */
  27486. _rebuild(): void;
  27487. /**
  27488. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27489. */
  27490. update(): void;
  27491. /**
  27492. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27493. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27494. */
  27495. updateTexture(isVisible: boolean): void;
  27496. protected _updateInternalTexture: () => void;
  27497. /**
  27498. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27499. * @param url New url.
  27500. */
  27501. updateURL(url: string): void;
  27502. /**
  27503. * Dispose the texture and release its associated resources.
  27504. */
  27505. dispose(): void;
  27506. /**
  27507. * Creates a video texture straight from a stream.
  27508. * @param scene Define the scene the texture should be created in
  27509. * @param stream Define the stream the texture should be created from
  27510. * @returns The created video texture as a promise
  27511. */
  27512. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27513. /**
  27514. * Creates a video texture straight from your WebCam video feed.
  27515. * @param scene Define the scene the texture should be created in
  27516. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27517. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27518. * @returns The created video texture as a promise
  27519. */
  27520. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27521. minWidth: number;
  27522. maxWidth: number;
  27523. minHeight: number;
  27524. maxHeight: number;
  27525. deviceId: string;
  27526. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27527. /**
  27528. * Creates a video texture straight from your WebCam video feed.
  27529. * @param scene Define the scene the texture should be created in
  27530. * @param onReady Define a callback to triggered once the texture will be ready
  27531. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27532. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27533. */
  27534. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27535. minWidth: number;
  27536. maxWidth: number;
  27537. minHeight: number;
  27538. maxHeight: number;
  27539. deviceId: string;
  27540. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27541. }
  27542. }
  27543. declare module "babylonjs/Engines/engine" {
  27544. import { Observable } from "babylonjs/Misc/observable";
  27545. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27546. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27547. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27548. import { Camera } from "babylonjs/Cameras/camera";
  27549. import { Scene } from "babylonjs/scene";
  27550. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27551. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27552. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27553. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27554. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27555. import { Material } from "babylonjs/Materials/material";
  27556. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27557. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27558. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27559. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27560. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27561. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27562. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27563. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27564. import { WebRequest } from "babylonjs/Misc/webRequest";
  27565. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27566. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27567. /**
  27568. * Interface for attribute information associated with buffer instanciation
  27569. */
  27570. export class InstancingAttributeInfo {
  27571. /**
  27572. * Index/offset of the attribute in the vertex shader
  27573. */
  27574. index: number;
  27575. /**
  27576. * size of the attribute, 1, 2, 3 or 4
  27577. */
  27578. attributeSize: number;
  27579. /**
  27580. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27581. * default is FLOAT
  27582. */
  27583. attribyteType: number;
  27584. /**
  27585. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27586. */
  27587. normalized: boolean;
  27588. /**
  27589. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27590. */
  27591. offset: number;
  27592. /**
  27593. * Name of the GLSL attribute, for debugging purpose only
  27594. */
  27595. attributeName: string;
  27596. }
  27597. /**
  27598. * Define options used to create a depth texture
  27599. */
  27600. export class DepthTextureCreationOptions {
  27601. /** Specifies whether or not a stencil should be allocated in the texture */
  27602. generateStencil?: boolean;
  27603. /** Specifies whether or not bilinear filtering is enable on the texture */
  27604. bilinearFiltering?: boolean;
  27605. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27606. comparisonFunction?: number;
  27607. /** Specifies if the created texture is a cube texture */
  27608. isCube?: boolean;
  27609. }
  27610. /**
  27611. * Class used to describe the capabilities of the engine relatively to the current browser
  27612. */
  27613. export class EngineCapabilities {
  27614. /** Maximum textures units per fragment shader */
  27615. maxTexturesImageUnits: number;
  27616. /** Maximum texture units per vertex shader */
  27617. maxVertexTextureImageUnits: number;
  27618. /** Maximum textures units in the entire pipeline */
  27619. maxCombinedTexturesImageUnits: number;
  27620. /** Maximum texture size */
  27621. maxTextureSize: number;
  27622. /** Maximum cube texture size */
  27623. maxCubemapTextureSize: number;
  27624. /** Maximum render texture size */
  27625. maxRenderTextureSize: number;
  27626. /** Maximum number of vertex attributes */
  27627. maxVertexAttribs: number;
  27628. /** Maximum number of varyings */
  27629. maxVaryingVectors: number;
  27630. /** Maximum number of uniforms per vertex shader */
  27631. maxVertexUniformVectors: number;
  27632. /** Maximum number of uniforms per fragment shader */
  27633. maxFragmentUniformVectors: number;
  27634. /** Defines if standard derivates (dx/dy) are supported */
  27635. standardDerivatives: boolean;
  27636. /** Defines if s3tc texture compression is supported */
  27637. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27638. /** Defines if pvrtc texture compression is supported */
  27639. pvrtc: any;
  27640. /** Defines if etc1 texture compression is supported */
  27641. etc1: any;
  27642. /** Defines if etc2 texture compression is supported */
  27643. etc2: any;
  27644. /** Defines if astc texture compression is supported */
  27645. astc: any;
  27646. /** Defines if float textures are supported */
  27647. textureFloat: boolean;
  27648. /** Defines if vertex array objects are supported */
  27649. vertexArrayObject: boolean;
  27650. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27651. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27652. /** Gets the maximum level of anisotropy supported */
  27653. maxAnisotropy: number;
  27654. /** Defines if instancing is supported */
  27655. instancedArrays: boolean;
  27656. /** Defines if 32 bits indices are supported */
  27657. uintIndices: boolean;
  27658. /** Defines if high precision shaders are supported */
  27659. highPrecisionShaderSupported: boolean;
  27660. /** Defines if depth reading in the fragment shader is supported */
  27661. fragmentDepthSupported: boolean;
  27662. /** Defines if float texture linear filtering is supported*/
  27663. textureFloatLinearFiltering: boolean;
  27664. /** Defines if rendering to float textures is supported */
  27665. textureFloatRender: boolean;
  27666. /** Defines if half float textures are supported*/
  27667. textureHalfFloat: boolean;
  27668. /** Defines if half float texture linear filtering is supported*/
  27669. textureHalfFloatLinearFiltering: boolean;
  27670. /** Defines if rendering to half float textures is supported */
  27671. textureHalfFloatRender: boolean;
  27672. /** Defines if textureLOD shader command is supported */
  27673. textureLOD: boolean;
  27674. /** Defines if draw buffers extension is supported */
  27675. drawBuffersExtension: boolean;
  27676. /** Defines if depth textures are supported */
  27677. depthTextureExtension: boolean;
  27678. /** Defines if float color buffer are supported */
  27679. colorBufferFloat: boolean;
  27680. /** Gets disjoint timer query extension (null if not supported) */
  27681. timerQuery: EXT_disjoint_timer_query;
  27682. /** Defines if timestamp can be used with timer query */
  27683. canUseTimestampForTimerQuery: boolean;
  27684. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27685. multiview: any;
  27686. /** Function used to let the system compiles shaders in background */
  27687. parallelShaderCompile: {
  27688. COMPLETION_STATUS_KHR: number;
  27689. };
  27690. }
  27691. /** Interface defining initialization parameters for Engine class */
  27692. export interface EngineOptions extends WebGLContextAttributes {
  27693. /**
  27694. * Defines if the engine should no exceed a specified device ratio
  27695. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27696. */
  27697. limitDeviceRatio?: number;
  27698. /**
  27699. * Defines if webvr should be enabled automatically
  27700. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27701. */
  27702. autoEnableWebVR?: boolean;
  27703. /**
  27704. * Defines if webgl2 should be turned off even if supported
  27705. * @see http://doc.babylonjs.com/features/webgl2
  27706. */
  27707. disableWebGL2Support?: boolean;
  27708. /**
  27709. * Defines if webaudio should be initialized as well
  27710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27711. */
  27712. audioEngine?: boolean;
  27713. /**
  27714. * Defines if animations should run using a deterministic lock step
  27715. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27716. */
  27717. deterministicLockstep?: boolean;
  27718. /** Defines the maximum steps to use with deterministic lock step mode */
  27719. lockstepMaxSteps?: number;
  27720. /**
  27721. * Defines that engine should ignore context lost events
  27722. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27723. */
  27724. doNotHandleContextLost?: boolean;
  27725. /**
  27726. * Defines that engine should ignore modifying touch action attribute and style
  27727. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27728. */
  27729. doNotHandleTouchAction?: boolean;
  27730. /**
  27731. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27732. */
  27733. useHighPrecisionFloats?: boolean;
  27734. }
  27735. /**
  27736. * Defines the interface used by display changed events
  27737. */
  27738. export interface IDisplayChangedEventArgs {
  27739. /** Gets the vrDisplay object (if any) */
  27740. vrDisplay: Nullable<any>;
  27741. /** Gets a boolean indicating if webVR is supported */
  27742. vrSupported: boolean;
  27743. }
  27744. /**
  27745. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27746. */
  27747. export class Engine {
  27748. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27749. static ExceptionList: ({
  27750. key: string;
  27751. capture: string;
  27752. captureConstraint: number;
  27753. targets: string[];
  27754. } | {
  27755. key: string;
  27756. capture: null;
  27757. captureConstraint: null;
  27758. targets: string[];
  27759. })[];
  27760. /** Gets the list of created engines */
  27761. static readonly Instances: Engine[];
  27762. /**
  27763. * Gets the latest created engine
  27764. */
  27765. static readonly LastCreatedEngine: Nullable<Engine>;
  27766. /**
  27767. * Gets the latest created scene
  27768. */
  27769. static readonly LastCreatedScene: Nullable<Scene>;
  27770. /**
  27771. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27772. * @param flag defines which part of the materials must be marked as dirty
  27773. * @param predicate defines a predicate used to filter which materials should be affected
  27774. */
  27775. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27776. /**
  27777. * Hidden
  27778. */
  27779. static _TextureLoaders: IInternalTextureLoader[];
  27780. /** Defines that alpha blending is disabled */
  27781. static readonly ALPHA_DISABLE: number;
  27782. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27783. static readonly ALPHA_ADD: number;
  27784. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27785. static readonly ALPHA_COMBINE: number;
  27786. /** Defines that alpha blending to DEST - SRC * DEST */
  27787. static readonly ALPHA_SUBTRACT: number;
  27788. /** Defines that alpha blending to SRC * DEST */
  27789. static readonly ALPHA_MULTIPLY: number;
  27790. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27791. static readonly ALPHA_MAXIMIZED: number;
  27792. /** Defines that alpha blending to SRC + DEST */
  27793. static readonly ALPHA_ONEONE: number;
  27794. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27795. static readonly ALPHA_PREMULTIPLIED: number;
  27796. /**
  27797. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27798. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27799. */
  27800. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27801. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27802. static readonly ALPHA_INTERPOLATE: number;
  27803. /**
  27804. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27805. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27806. */
  27807. static readonly ALPHA_SCREENMODE: number;
  27808. /** Defines that the ressource is not delayed*/
  27809. static readonly DELAYLOADSTATE_NONE: number;
  27810. /** Defines that the ressource was successfully delay loaded */
  27811. static readonly DELAYLOADSTATE_LOADED: number;
  27812. /** Defines that the ressource is currently delay loading */
  27813. static readonly DELAYLOADSTATE_LOADING: number;
  27814. /** Defines that the ressource is delayed and has not started loading */
  27815. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27816. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27817. static readonly NEVER: number;
  27818. /** 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 */
  27819. static readonly ALWAYS: number;
  27820. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27821. static readonly LESS: number;
  27822. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27823. static readonly EQUAL: number;
  27824. /** 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 */
  27825. static readonly LEQUAL: number;
  27826. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27827. static readonly GREATER: number;
  27828. /** 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 */
  27829. static readonly GEQUAL: number;
  27830. /** 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 */
  27831. static readonly NOTEQUAL: number;
  27832. /** Passed to stencilOperation to specify that stencil value must be kept */
  27833. static readonly KEEP: number;
  27834. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27835. static readonly REPLACE: number;
  27836. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27837. static readonly INCR: number;
  27838. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27839. static readonly DECR: number;
  27840. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27841. static readonly INVERT: number;
  27842. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27843. static readonly INCR_WRAP: number;
  27844. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27845. static readonly DECR_WRAP: number;
  27846. /** Texture is not repeating outside of 0..1 UVs */
  27847. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27848. /** Texture is repeating outside of 0..1 UVs */
  27849. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27850. /** Texture is repeating and mirrored */
  27851. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27852. /** ALPHA */
  27853. static readonly TEXTUREFORMAT_ALPHA: number;
  27854. /** LUMINANCE */
  27855. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27856. /** LUMINANCE_ALPHA */
  27857. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27858. /** RGB */
  27859. static readonly TEXTUREFORMAT_RGB: number;
  27860. /** RGBA */
  27861. static readonly TEXTUREFORMAT_RGBA: number;
  27862. /** RED */
  27863. static readonly TEXTUREFORMAT_RED: number;
  27864. /** RED (2nd reference) */
  27865. static readonly TEXTUREFORMAT_R: number;
  27866. /** RG */
  27867. static readonly TEXTUREFORMAT_RG: number;
  27868. /** RED_INTEGER */
  27869. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27870. /** RED_INTEGER (2nd reference) */
  27871. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27872. /** RG_INTEGER */
  27873. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27874. /** RGB_INTEGER */
  27875. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27876. /** RGBA_INTEGER */
  27877. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27878. /** UNSIGNED_BYTE */
  27879. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27880. /** UNSIGNED_BYTE (2nd reference) */
  27881. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27882. /** FLOAT */
  27883. static readonly TEXTURETYPE_FLOAT: number;
  27884. /** HALF_FLOAT */
  27885. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27886. /** BYTE */
  27887. static readonly TEXTURETYPE_BYTE: number;
  27888. /** SHORT */
  27889. static readonly TEXTURETYPE_SHORT: number;
  27890. /** UNSIGNED_SHORT */
  27891. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27892. /** INT */
  27893. static readonly TEXTURETYPE_INT: number;
  27894. /** UNSIGNED_INT */
  27895. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27896. /** UNSIGNED_SHORT_4_4_4_4 */
  27897. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27898. /** UNSIGNED_SHORT_5_5_5_1 */
  27899. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27900. /** UNSIGNED_SHORT_5_6_5 */
  27901. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27902. /** UNSIGNED_INT_2_10_10_10_REV */
  27903. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27904. /** UNSIGNED_INT_24_8 */
  27905. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27906. /** UNSIGNED_INT_10F_11F_11F_REV */
  27907. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27908. /** UNSIGNED_INT_5_9_9_9_REV */
  27909. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27910. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27911. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27912. /** nearest is mag = nearest and min = nearest and mip = linear */
  27913. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27914. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27915. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27916. /** Trilinear is mag = linear and min = linear and mip = linear */
  27917. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27918. /** nearest is mag = nearest and min = nearest and mip = linear */
  27919. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27920. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27921. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27922. /** Trilinear is mag = linear and min = linear and mip = linear */
  27923. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27924. /** mag = nearest and min = nearest and mip = nearest */
  27925. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27926. /** mag = nearest and min = linear and mip = nearest */
  27927. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27928. /** mag = nearest and min = linear and mip = linear */
  27929. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27930. /** mag = nearest and min = linear and mip = none */
  27931. static readonly TEXTURE_NEAREST_LINEAR: number;
  27932. /** mag = nearest and min = nearest and mip = none */
  27933. static readonly TEXTURE_NEAREST_NEAREST: number;
  27934. /** mag = linear and min = nearest and mip = nearest */
  27935. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27936. /** mag = linear and min = nearest and mip = linear */
  27937. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27938. /** mag = linear and min = linear and mip = none */
  27939. static readonly TEXTURE_LINEAR_LINEAR: number;
  27940. /** mag = linear and min = nearest and mip = none */
  27941. static readonly TEXTURE_LINEAR_NEAREST: number;
  27942. /** Explicit coordinates mode */
  27943. static readonly TEXTURE_EXPLICIT_MODE: number;
  27944. /** Spherical coordinates mode */
  27945. static readonly TEXTURE_SPHERICAL_MODE: number;
  27946. /** Planar coordinates mode */
  27947. static readonly TEXTURE_PLANAR_MODE: number;
  27948. /** Cubic coordinates mode */
  27949. static readonly TEXTURE_CUBIC_MODE: number;
  27950. /** Projection coordinates mode */
  27951. static readonly TEXTURE_PROJECTION_MODE: number;
  27952. /** Skybox coordinates mode */
  27953. static readonly TEXTURE_SKYBOX_MODE: number;
  27954. /** Inverse Cubic coordinates mode */
  27955. static readonly TEXTURE_INVCUBIC_MODE: number;
  27956. /** Equirectangular coordinates mode */
  27957. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27958. /** Equirectangular Fixed coordinates mode */
  27959. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27960. /** Equirectangular Fixed Mirrored coordinates mode */
  27961. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27962. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27963. static readonly SCALEMODE_FLOOR: number;
  27964. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27965. static readonly SCALEMODE_NEAREST: number;
  27966. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27967. static readonly SCALEMODE_CEILING: number;
  27968. /**
  27969. * Returns the current npm package of the sdk
  27970. */
  27971. static readonly NpmPackage: string;
  27972. /**
  27973. * Returns the current version of the framework
  27974. */
  27975. static readonly Version: string;
  27976. /**
  27977. * Returns a string describing the current engine
  27978. */
  27979. readonly description: string;
  27980. /**
  27981. * Gets or sets the epsilon value used by collision engine
  27982. */
  27983. static CollisionsEpsilon: number;
  27984. /**
  27985. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27986. */
  27987. static ShadersRepository: string;
  27988. /**
  27989. * Method called to create the default loading screen.
  27990. * This can be overriden in your own app.
  27991. * @param canvas The rendering canvas element
  27992. * @returns The loading screen
  27993. */
  27994. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27995. /**
  27996. * Method called to create the default rescale post process on each engine.
  27997. */
  27998. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27999. /**
  28000. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28001. */
  28002. forcePOTTextures: boolean;
  28003. /**
  28004. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28005. */
  28006. isFullscreen: boolean;
  28007. /**
  28008. * Gets a boolean indicating if the pointer is currently locked
  28009. */
  28010. isPointerLock: boolean;
  28011. /**
  28012. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28013. */
  28014. cullBackFaces: boolean;
  28015. /**
  28016. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28017. */
  28018. renderEvenInBackground: boolean;
  28019. /**
  28020. * Gets or sets a boolean indicating that cache can be kept between frames
  28021. */
  28022. preventCacheWipeBetweenFrames: boolean;
  28023. /**
  28024. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28025. **/
  28026. enableOfflineSupport: boolean;
  28027. /**
  28028. * 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)
  28029. **/
  28030. disableManifestCheck: boolean;
  28031. /**
  28032. * Gets the list of created scenes
  28033. */
  28034. scenes: Scene[];
  28035. /**
  28036. * Event raised when a new scene is created
  28037. */
  28038. onNewSceneAddedObservable: Observable<Scene>;
  28039. /**
  28040. * Gets the list of created postprocesses
  28041. */
  28042. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28043. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28044. validateShaderPrograms: boolean;
  28045. /**
  28046. * Observable event triggered each time the rendering canvas is resized
  28047. */
  28048. onResizeObservable: Observable<Engine>;
  28049. /**
  28050. * Observable event triggered each time the canvas loses focus
  28051. */
  28052. onCanvasBlurObservable: Observable<Engine>;
  28053. /**
  28054. * Observable event triggered each time the canvas gains focus
  28055. */
  28056. onCanvasFocusObservable: Observable<Engine>;
  28057. /**
  28058. * Observable event triggered each time the canvas receives pointerout event
  28059. */
  28060. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28061. /**
  28062. * Observable event triggered before each texture is initialized
  28063. */
  28064. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28065. private _vrDisplay;
  28066. private _vrSupported;
  28067. private _oldSize;
  28068. private _oldHardwareScaleFactor;
  28069. private _vrExclusivePointerMode;
  28070. private _webVRInitPromise;
  28071. /**
  28072. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28073. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28074. */
  28075. readonly isInVRExclusivePointerMode: boolean;
  28076. /**
  28077. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28078. */
  28079. disableUniformBuffers: boolean;
  28080. /** @hidden */
  28081. _uniformBuffers: UniformBuffer[];
  28082. /**
  28083. * Gets a boolean indicating that the engine supports uniform buffers
  28084. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28085. */
  28086. readonly supportsUniformBuffers: boolean;
  28087. /**
  28088. * Observable raised when the engine begins a new frame
  28089. */
  28090. onBeginFrameObservable: Observable<Engine>;
  28091. /**
  28092. * If set, will be used to request the next animation frame for the render loop
  28093. */
  28094. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28095. /**
  28096. * Observable raised when the engine ends the current frame
  28097. */
  28098. onEndFrameObservable: Observable<Engine>;
  28099. /**
  28100. * Observable raised when the engine is about to compile a shader
  28101. */
  28102. onBeforeShaderCompilationObservable: Observable<Engine>;
  28103. /**
  28104. * Observable raised when the engine has jsut compiled a shader
  28105. */
  28106. onAfterShaderCompilationObservable: Observable<Engine>;
  28107. /** @hidden */
  28108. _gl: WebGLRenderingContext;
  28109. private _renderingCanvas;
  28110. private _windowIsBackground;
  28111. private _webGLVersion;
  28112. protected _highPrecisionShadersAllowed: boolean;
  28113. /** @hidden */
  28114. readonly _shouldUseHighPrecisionShader: boolean;
  28115. /**
  28116. * Gets a boolean indicating that only power of 2 textures are supported
  28117. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28118. */
  28119. readonly needPOTTextures: boolean;
  28120. /** @hidden */
  28121. _badOS: boolean;
  28122. /** @hidden */
  28123. _badDesktopOS: boolean;
  28124. /**
  28125. * Gets the audio engine
  28126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28127. * @ignorenaming
  28128. */
  28129. static audioEngine: IAudioEngine;
  28130. /**
  28131. * Default AudioEngine factory responsible of creating the Audio Engine.
  28132. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28133. */
  28134. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28135. /**
  28136. * Default offline support factory responsible of creating a tool used to store data locally.
  28137. * By default, this will create a Database object if the workload has been embedded.
  28138. */
  28139. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28140. private _onFocus;
  28141. private _onBlur;
  28142. private _onCanvasPointerOut;
  28143. private _onCanvasBlur;
  28144. private _onCanvasFocus;
  28145. private _onFullscreenChange;
  28146. private _onPointerLockChange;
  28147. private _onVRDisplayPointerRestricted;
  28148. private _onVRDisplayPointerUnrestricted;
  28149. private _onVrDisplayConnect;
  28150. private _onVrDisplayDisconnect;
  28151. private _onVrDisplayPresentChange;
  28152. /**
  28153. * Observable signaled when VR display mode changes
  28154. */
  28155. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28156. /**
  28157. * Observable signaled when VR request present is complete
  28158. */
  28159. onVRRequestPresentComplete: Observable<boolean>;
  28160. /**
  28161. * Observable signaled when VR request present starts
  28162. */
  28163. onVRRequestPresentStart: Observable<Engine>;
  28164. private _hardwareScalingLevel;
  28165. /** @hidden */
  28166. _caps: EngineCapabilities;
  28167. private _pointerLockRequested;
  28168. private _isStencilEnable;
  28169. private _colorWrite;
  28170. private _loadingScreen;
  28171. /** @hidden */
  28172. _drawCalls: PerfCounter;
  28173. private _glVersion;
  28174. private _glRenderer;
  28175. private _glVendor;
  28176. private _videoTextureSupported;
  28177. private _renderingQueueLaunched;
  28178. private _activeRenderLoops;
  28179. private _deterministicLockstep;
  28180. private _lockstepMaxSteps;
  28181. /**
  28182. * Observable signaled when a context lost event is raised
  28183. */
  28184. onContextLostObservable: Observable<Engine>;
  28185. /**
  28186. * Observable signaled when a context restored event is raised
  28187. */
  28188. onContextRestoredObservable: Observable<Engine>;
  28189. private _onContextLost;
  28190. private _onContextRestored;
  28191. private _contextWasLost;
  28192. /** @hidden */
  28193. _doNotHandleContextLost: boolean;
  28194. /**
  28195. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28196. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28197. */
  28198. doNotHandleContextLost: boolean;
  28199. private _performanceMonitor;
  28200. private _fps;
  28201. private _deltaTime;
  28202. /**
  28203. * Turn this value on if you want to pause FPS computation when in background
  28204. */
  28205. disablePerformanceMonitorInBackground: boolean;
  28206. /**
  28207. * Gets the performance monitor attached to this engine
  28208. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28209. */
  28210. readonly performanceMonitor: PerformanceMonitor;
  28211. /**
  28212. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28213. */
  28214. disableVertexArrayObjects: boolean;
  28215. /** @hidden */
  28216. protected _depthCullingState: _DepthCullingState;
  28217. /** @hidden */
  28218. protected _stencilState: _StencilState;
  28219. /** @hidden */
  28220. protected _alphaState: _AlphaState;
  28221. /** @hidden */
  28222. protected _alphaMode: number;
  28223. /** @hidden */
  28224. _internalTexturesCache: InternalTexture[];
  28225. /** @hidden */
  28226. protected _activeChannel: number;
  28227. private _currentTextureChannel;
  28228. /** @hidden */
  28229. protected _boundTexturesCache: {
  28230. [key: string]: Nullable<InternalTexture>;
  28231. };
  28232. /** @hidden */
  28233. protected _currentEffect: Nullable<Effect>;
  28234. /** @hidden */
  28235. protected _currentProgram: Nullable<WebGLProgram>;
  28236. private _compiledEffects;
  28237. private _vertexAttribArraysEnabled;
  28238. /** @hidden */
  28239. protected _cachedViewport: Nullable<Viewport>;
  28240. private _cachedVertexArrayObject;
  28241. /** @hidden */
  28242. protected _cachedVertexBuffers: any;
  28243. /** @hidden */
  28244. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28245. /** @hidden */
  28246. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28247. /** @hidden */
  28248. _currentRenderTarget: Nullable<InternalTexture>;
  28249. private _uintIndicesCurrentlySet;
  28250. private _currentBoundBuffer;
  28251. /** @hidden */
  28252. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28253. private _currentBufferPointers;
  28254. private _currentInstanceLocations;
  28255. private _currentInstanceBuffers;
  28256. private _textureUnits;
  28257. /** @hidden */
  28258. _workingCanvas: Nullable<HTMLCanvasElement>;
  28259. /** @hidden */
  28260. _workingContext: Nullable<CanvasRenderingContext2D>;
  28261. private _rescalePostProcess;
  28262. private _dummyFramebuffer;
  28263. private _externalData;
  28264. private _bindedRenderFunction;
  28265. private _vaoRecordInProgress;
  28266. private _mustWipeVertexAttributes;
  28267. private _emptyTexture;
  28268. private _emptyCubeTexture;
  28269. private _emptyTexture3D;
  28270. /** @hidden */
  28271. _frameHandler: number;
  28272. private _nextFreeTextureSlots;
  28273. private _maxSimultaneousTextures;
  28274. private _activeRequests;
  28275. private _texturesSupported;
  28276. /** @hidden */
  28277. _textureFormatInUse: Nullable<string>;
  28278. /**
  28279. * Gets the list of texture formats supported
  28280. */
  28281. readonly texturesSupported: Array<string>;
  28282. /**
  28283. * Gets the list of texture formats in use
  28284. */
  28285. readonly textureFormatInUse: Nullable<string>;
  28286. /**
  28287. * Gets the current viewport
  28288. */
  28289. readonly currentViewport: Nullable<Viewport>;
  28290. /**
  28291. * Gets the default empty texture
  28292. */
  28293. readonly emptyTexture: InternalTexture;
  28294. /**
  28295. * Gets the default empty 3D texture
  28296. */
  28297. readonly emptyTexture3D: InternalTexture;
  28298. /**
  28299. * Gets the default empty cube texture
  28300. */
  28301. readonly emptyCubeTexture: InternalTexture;
  28302. /**
  28303. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28304. */
  28305. readonly premultipliedAlpha: boolean;
  28306. /**
  28307. * Creates a new engine
  28308. * @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
  28309. * @param antialias defines enable antialiasing (default: false)
  28310. * @param options defines further options to be sent to the getContext() function
  28311. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28312. */
  28313. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28314. private _disableTouchAction;
  28315. private _rebuildInternalTextures;
  28316. private _rebuildEffects;
  28317. /**
  28318. * Gets a boolean indicating if all created effects are ready
  28319. * @returns true if all effects are ready
  28320. */
  28321. areAllEffectsReady(): boolean;
  28322. private _rebuildBuffers;
  28323. private _initGLContext;
  28324. /**
  28325. * Gets version of the current webGL context
  28326. */
  28327. readonly webGLVersion: number;
  28328. /**
  28329. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28330. */
  28331. readonly isStencilEnable: boolean;
  28332. /** @hidden */
  28333. _prepareWorkingCanvas(): void;
  28334. /**
  28335. * Reset the texture cache to empty state
  28336. */
  28337. resetTextureCache(): void;
  28338. /**
  28339. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28340. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28341. * @returns true if engine is in deterministic lock step mode
  28342. */
  28343. isDeterministicLockStep(): boolean;
  28344. /**
  28345. * Gets the max steps when engine is running in deterministic lock step
  28346. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28347. * @returns the max steps
  28348. */
  28349. getLockstepMaxSteps(): number;
  28350. /**
  28351. * Gets an object containing information about the current webGL context
  28352. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28353. */
  28354. getGlInfo(): {
  28355. vendor: string;
  28356. renderer: string;
  28357. version: string;
  28358. };
  28359. /**
  28360. * Gets current aspect ratio
  28361. * @param camera defines the camera to use to get the aspect ratio
  28362. * @param useScreen defines if screen size must be used (or the current render target if any)
  28363. * @returns a number defining the aspect ratio
  28364. */
  28365. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28366. /**
  28367. * Gets current screen aspect ratio
  28368. * @returns a number defining the aspect ratio
  28369. */
  28370. getScreenAspectRatio(): number;
  28371. /**
  28372. * Gets the current render width
  28373. * @param useScreen defines if screen size must be used (or the current render target if any)
  28374. * @returns a number defining the current render width
  28375. */
  28376. getRenderWidth(useScreen?: boolean): number;
  28377. /**
  28378. * Gets the current render height
  28379. * @param useScreen defines if screen size must be used (or the current render target if any)
  28380. * @returns a number defining the current render height
  28381. */
  28382. getRenderHeight(useScreen?: boolean): number;
  28383. /**
  28384. * Gets the HTML canvas attached with the current webGL context
  28385. * @returns a HTML canvas
  28386. */
  28387. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28388. /**
  28389. * Gets the client rect of the HTML canvas attached with the current webGL context
  28390. * @returns a client rectanglee
  28391. */
  28392. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28393. /**
  28394. * Defines the hardware scaling level.
  28395. * By default the hardware scaling level is computed from the window device ratio.
  28396. * 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.
  28397. * @param level defines the level to use
  28398. */
  28399. setHardwareScalingLevel(level: number): void;
  28400. /**
  28401. * Gets the current hardware scaling level.
  28402. * By default the hardware scaling level is computed from the window device ratio.
  28403. * 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.
  28404. * @returns a number indicating the current hardware scaling level
  28405. */
  28406. getHardwareScalingLevel(): number;
  28407. /**
  28408. * Gets the list of loaded textures
  28409. * @returns an array containing all loaded textures
  28410. */
  28411. getLoadedTexturesCache(): InternalTexture[];
  28412. /**
  28413. * Gets the object containing all engine capabilities
  28414. * @returns the EngineCapabilities object
  28415. */
  28416. getCaps(): EngineCapabilities;
  28417. /**
  28418. * Gets the current depth function
  28419. * @returns a number defining the depth function
  28420. */
  28421. getDepthFunction(): Nullable<number>;
  28422. /**
  28423. * Sets the current depth function
  28424. * @param depthFunc defines the function to use
  28425. */
  28426. setDepthFunction(depthFunc: number): void;
  28427. /**
  28428. * Sets the current depth function to GREATER
  28429. */
  28430. setDepthFunctionToGreater(): void;
  28431. /**
  28432. * Sets the current depth function to GEQUAL
  28433. */
  28434. setDepthFunctionToGreaterOrEqual(): void;
  28435. /**
  28436. * Sets the current depth function to LESS
  28437. */
  28438. setDepthFunctionToLess(): void;
  28439. private _cachedStencilBuffer;
  28440. private _cachedStencilFunction;
  28441. private _cachedStencilMask;
  28442. private _cachedStencilOperationPass;
  28443. private _cachedStencilOperationFail;
  28444. private _cachedStencilOperationDepthFail;
  28445. private _cachedStencilReference;
  28446. /**
  28447. * Caches the the state of the stencil buffer
  28448. */
  28449. cacheStencilState(): void;
  28450. /**
  28451. * Restores the state of the stencil buffer
  28452. */
  28453. restoreStencilState(): void;
  28454. /**
  28455. * Sets the current depth function to LEQUAL
  28456. */
  28457. setDepthFunctionToLessOrEqual(): void;
  28458. /**
  28459. * Gets a boolean indicating if stencil buffer is enabled
  28460. * @returns the current stencil buffer state
  28461. */
  28462. getStencilBuffer(): boolean;
  28463. /**
  28464. * Enable or disable the stencil buffer
  28465. * @param enable defines if the stencil buffer must be enabled or disabled
  28466. */
  28467. setStencilBuffer(enable: boolean): void;
  28468. /**
  28469. * Gets the current stencil mask
  28470. * @returns a number defining the new stencil mask to use
  28471. */
  28472. getStencilMask(): number;
  28473. /**
  28474. * Sets the current stencil mask
  28475. * @param mask defines the new stencil mask to use
  28476. */
  28477. setStencilMask(mask: number): void;
  28478. /**
  28479. * Gets the current stencil function
  28480. * @returns a number defining the stencil function to use
  28481. */
  28482. getStencilFunction(): number;
  28483. /**
  28484. * Gets the current stencil reference value
  28485. * @returns a number defining the stencil reference value to use
  28486. */
  28487. getStencilFunctionReference(): number;
  28488. /**
  28489. * Gets the current stencil mask
  28490. * @returns a number defining the stencil mask to use
  28491. */
  28492. getStencilFunctionMask(): number;
  28493. /**
  28494. * Sets the current stencil function
  28495. * @param stencilFunc defines the new stencil function to use
  28496. */
  28497. setStencilFunction(stencilFunc: number): void;
  28498. /**
  28499. * Sets the current stencil reference
  28500. * @param reference defines the new stencil reference to use
  28501. */
  28502. setStencilFunctionReference(reference: number): void;
  28503. /**
  28504. * Sets the current stencil mask
  28505. * @param mask defines the new stencil mask to use
  28506. */
  28507. setStencilFunctionMask(mask: number): void;
  28508. /**
  28509. * Gets the current stencil operation when stencil fails
  28510. * @returns a number defining stencil operation to use when stencil fails
  28511. */
  28512. getStencilOperationFail(): number;
  28513. /**
  28514. * Gets the current stencil operation when depth fails
  28515. * @returns a number defining stencil operation to use when depth fails
  28516. */
  28517. getStencilOperationDepthFail(): number;
  28518. /**
  28519. * Gets the current stencil operation when stencil passes
  28520. * @returns a number defining stencil operation to use when stencil passes
  28521. */
  28522. getStencilOperationPass(): number;
  28523. /**
  28524. * Sets the stencil operation to use when stencil fails
  28525. * @param operation defines the stencil operation to use when stencil fails
  28526. */
  28527. setStencilOperationFail(operation: number): void;
  28528. /**
  28529. * Sets the stencil operation to use when depth fails
  28530. * @param operation defines the stencil operation to use when depth fails
  28531. */
  28532. setStencilOperationDepthFail(operation: number): void;
  28533. /**
  28534. * Sets the stencil operation to use when stencil passes
  28535. * @param operation defines the stencil operation to use when stencil passes
  28536. */
  28537. setStencilOperationPass(operation: number): void;
  28538. /**
  28539. * Sets a boolean indicating if the dithering state is enabled or disabled
  28540. * @param value defines the dithering state
  28541. */
  28542. setDitheringState(value: boolean): void;
  28543. /**
  28544. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28545. * @param value defines the rasterizer state
  28546. */
  28547. setRasterizerState(value: boolean): void;
  28548. /**
  28549. * stop executing a render loop function and remove it from the execution array
  28550. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28551. */
  28552. stopRenderLoop(renderFunction?: () => void): void;
  28553. /** @hidden */
  28554. _renderLoop(): void;
  28555. /**
  28556. * Register and execute a render loop. The engine can have more than one render function
  28557. * @param renderFunction defines the function to continuously execute
  28558. */
  28559. runRenderLoop(renderFunction: () => void): void;
  28560. /**
  28561. * Toggle full screen mode
  28562. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28563. */
  28564. switchFullscreen(requestPointerLock: boolean): void;
  28565. /**
  28566. * Enters full screen mode
  28567. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28568. */
  28569. enterFullscreen(requestPointerLock: boolean): void;
  28570. /**
  28571. * Exits full screen mode
  28572. */
  28573. exitFullscreen(): void;
  28574. /**
  28575. * Clear the current render buffer or the current render target (if any is set up)
  28576. * @param color defines the color to use
  28577. * @param backBuffer defines if the back buffer must be cleared
  28578. * @param depth defines if the depth buffer must be cleared
  28579. * @param stencil defines if the stencil buffer must be cleared
  28580. */
  28581. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28582. /**
  28583. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28584. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28585. * @param y defines the y-coordinate of the corner of the clear rectangle
  28586. * @param width defines the width of the clear rectangle
  28587. * @param height defines the height of the clear rectangle
  28588. * @param clearColor defines the clear color
  28589. */
  28590. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28591. /**
  28592. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28593. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28594. * @param y defines the y-coordinate of the corner of the clear rectangle
  28595. * @param width defines the width of the clear rectangle
  28596. * @param height defines the height of the clear rectangle
  28597. */
  28598. enableScissor(x: number, y: number, width: number, height: number): void;
  28599. /**
  28600. * Disable previously set scissor test rectangle
  28601. */
  28602. disableScissor(): void;
  28603. private _viewportCached;
  28604. /** @hidden */
  28605. _viewport(x: number, y: number, width: number, height: number): void;
  28606. /**
  28607. * Set the WebGL's viewport
  28608. * @param viewport defines the viewport element to be used
  28609. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28610. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28611. */
  28612. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28613. /**
  28614. * Directly set the WebGL Viewport
  28615. * @param x defines the x coordinate of the viewport (in screen space)
  28616. * @param y defines the y coordinate of the viewport (in screen space)
  28617. * @param width defines the width of the viewport (in screen space)
  28618. * @param height defines the height of the viewport (in screen space)
  28619. * @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
  28620. */
  28621. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28622. /**
  28623. * Begin a new frame
  28624. */
  28625. beginFrame(): void;
  28626. /**
  28627. * Enf the current frame
  28628. */
  28629. endFrame(): void;
  28630. /**
  28631. * Resize the view according to the canvas' size
  28632. */
  28633. resize(): void;
  28634. /**
  28635. * Force a specific size of the canvas
  28636. * @param width defines the new canvas' width
  28637. * @param height defines the new canvas' height
  28638. */
  28639. setSize(width: number, height: number): void;
  28640. /**
  28641. * Gets a boolean indicating if a webVR device was detected
  28642. * @returns true if a webVR device was detected
  28643. */
  28644. isVRDevicePresent(): boolean;
  28645. /**
  28646. * Gets the current webVR device
  28647. * @returns the current webVR device (or null)
  28648. */
  28649. getVRDevice(): any;
  28650. /**
  28651. * Initializes a webVR display and starts listening to display change events
  28652. * The onVRDisplayChangedObservable will be notified upon these changes
  28653. * @returns The onVRDisplayChangedObservable
  28654. */
  28655. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28656. /**
  28657. * Initializes a webVR display and starts listening to display change events
  28658. * The onVRDisplayChangedObservable will be notified upon these changes
  28659. * @returns A promise containing a VRDisplay and if vr is supported
  28660. */
  28661. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28662. /**
  28663. * Call this function to switch to webVR mode
  28664. * Will do nothing if webVR is not supported or if there is no webVR device
  28665. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28666. */
  28667. enableVR(): void;
  28668. /**
  28669. * Call this function to leave webVR mode
  28670. * Will do nothing if webVR is not supported or if there is no webVR device
  28671. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28672. */
  28673. disableVR(): void;
  28674. private _onVRFullScreenTriggered;
  28675. private _getVRDisplaysAsync;
  28676. /**
  28677. * Binds the frame buffer to the specified texture.
  28678. * @param texture The texture to render to or null for the default canvas
  28679. * @param faceIndex The face of the texture to render to in case of cube texture
  28680. * @param requiredWidth The width of the target to render to
  28681. * @param requiredHeight The height of the target to render to
  28682. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28683. * @param depthStencilTexture The depth stencil texture to use to render
  28684. * @param lodLevel defines le lod level to bind to the frame buffer
  28685. */
  28686. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28687. /** @hidden */
  28688. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28689. /**
  28690. * Unbind the current render target texture from the webGL context
  28691. * @param texture defines the render target texture to unbind
  28692. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28693. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28694. */
  28695. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28696. /**
  28697. * Force the mipmap generation for the given render target texture
  28698. * @param texture defines the render target texture to use
  28699. */
  28700. generateMipMapsForCubemap(texture: InternalTexture): void;
  28701. /**
  28702. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28703. */
  28704. flushFramebuffer(): void;
  28705. /**
  28706. * Unbind the current render target and bind the default framebuffer
  28707. */
  28708. restoreDefaultFramebuffer(): void;
  28709. /**
  28710. * Create an uniform buffer
  28711. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28712. * @param elements defines the content of the uniform buffer
  28713. * @returns the webGL uniform buffer
  28714. */
  28715. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28716. /**
  28717. * Create a dynamic uniform buffer
  28718. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28719. * @param elements defines the content of the uniform buffer
  28720. * @returns the webGL uniform buffer
  28721. */
  28722. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28723. /**
  28724. * Update an existing uniform buffer
  28725. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28726. * @param uniformBuffer defines the target uniform buffer
  28727. * @param elements defines the content to update
  28728. * @param offset defines the offset in the uniform buffer where update should start
  28729. * @param count defines the size of the data to update
  28730. */
  28731. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28732. private _resetVertexBufferBinding;
  28733. /**
  28734. * Creates a vertex buffer
  28735. * @param data the data for the vertex buffer
  28736. * @returns the new WebGL static buffer
  28737. */
  28738. createVertexBuffer(data: DataArray): WebGLBuffer;
  28739. /**
  28740. * Creates a dynamic vertex buffer
  28741. * @param data the data for the dynamic vertex buffer
  28742. * @returns the new WebGL dynamic buffer
  28743. */
  28744. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28745. /**
  28746. * Update a dynamic index buffer
  28747. * @param indexBuffer defines the target index buffer
  28748. * @param indices defines the data to update
  28749. * @param offset defines the offset in the target index buffer where update should start
  28750. */
  28751. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28752. /**
  28753. * Updates a dynamic vertex buffer.
  28754. * @param vertexBuffer the vertex buffer to update
  28755. * @param data the data used to update the vertex buffer
  28756. * @param byteOffset the byte offset of the data
  28757. * @param byteLength the byte length of the data
  28758. */
  28759. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28760. private _resetIndexBufferBinding;
  28761. /**
  28762. * Creates a new index buffer
  28763. * @param indices defines the content of the index buffer
  28764. * @param updatable defines if the index buffer must be updatable
  28765. * @returns a new webGL buffer
  28766. */
  28767. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28768. /**
  28769. * Bind a webGL buffer to the webGL context
  28770. * @param buffer defines the buffer to bind
  28771. */
  28772. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28773. /**
  28774. * Bind an uniform buffer to the current webGL context
  28775. * @param buffer defines the buffer to bind
  28776. */
  28777. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28778. /**
  28779. * Bind a buffer to the current webGL context at a given location
  28780. * @param buffer defines the buffer to bind
  28781. * @param location defines the index where to bind the buffer
  28782. */
  28783. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28784. /**
  28785. * Bind a specific block at a given index in a specific shader program
  28786. * @param shaderProgram defines the shader program
  28787. * @param blockName defines the block name
  28788. * @param index defines the index where to bind the block
  28789. */
  28790. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28791. private bindIndexBuffer;
  28792. private bindBuffer;
  28793. /**
  28794. * update the bound buffer with the given data
  28795. * @param data defines the data to update
  28796. */
  28797. updateArrayBuffer(data: Float32Array): void;
  28798. private _vertexAttribPointer;
  28799. private _bindIndexBufferWithCache;
  28800. private _bindVertexBuffersAttributes;
  28801. /**
  28802. * Records a vertex array object
  28803. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28804. * @param vertexBuffers defines the list of vertex buffers to store
  28805. * @param indexBuffer defines the index buffer to store
  28806. * @param effect defines the effect to store
  28807. * @returns the new vertex array object
  28808. */
  28809. recordVertexArrayObject(vertexBuffers: {
  28810. [key: string]: VertexBuffer;
  28811. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28812. /**
  28813. * Bind a specific vertex array object
  28814. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28815. * @param vertexArrayObject defines the vertex array object to bind
  28816. * @param indexBuffer defines the index buffer to bind
  28817. */
  28818. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28819. /**
  28820. * Bind webGl buffers directly to the webGL context
  28821. * @param vertexBuffer defines the vertex buffer to bind
  28822. * @param indexBuffer defines the index buffer to bind
  28823. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28824. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28825. * @param effect defines the effect associated with the vertex buffer
  28826. */
  28827. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28828. private _unbindVertexArrayObject;
  28829. /**
  28830. * Bind a list of vertex buffers to the webGL context
  28831. * @param vertexBuffers defines the list of vertex buffers to bind
  28832. * @param indexBuffer defines the index buffer to bind
  28833. * @param effect defines the effect associated with the vertex buffers
  28834. */
  28835. bindBuffers(vertexBuffers: {
  28836. [key: string]: Nullable<VertexBuffer>;
  28837. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28838. /**
  28839. * Unbind all instance attributes
  28840. */
  28841. unbindInstanceAttributes(): void;
  28842. /**
  28843. * Release and free the memory of a vertex array object
  28844. * @param vao defines the vertex array object to delete
  28845. */
  28846. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28847. /** @hidden */
  28848. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28849. /**
  28850. * Creates a webGL buffer to use with instanciation
  28851. * @param capacity defines the size of the buffer
  28852. * @returns the webGL buffer
  28853. */
  28854. createInstancesBuffer(capacity: number): WebGLBuffer;
  28855. /**
  28856. * Delete a webGL buffer used with instanciation
  28857. * @param buffer defines the webGL buffer to delete
  28858. */
  28859. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28860. /**
  28861. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28862. * @param instancesBuffer defines the webGL buffer to update and bind
  28863. * @param data defines the data to store in the buffer
  28864. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28865. */
  28866. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28867. /**
  28868. * Apply all cached states (depth, culling, stencil and alpha)
  28869. */
  28870. applyStates(): void;
  28871. /**
  28872. * Send a draw order
  28873. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28874. * @param indexStart defines the starting index
  28875. * @param indexCount defines the number of index to draw
  28876. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28877. */
  28878. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28879. /**
  28880. * Draw a list of points
  28881. * @param verticesStart defines the index of first vertex to draw
  28882. * @param verticesCount defines the count of vertices to draw
  28883. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28884. */
  28885. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28886. /**
  28887. * Draw a list of unindexed primitives
  28888. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28889. * @param verticesStart defines the index of first vertex to draw
  28890. * @param verticesCount defines the count of vertices to draw
  28891. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28892. */
  28893. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28894. /**
  28895. * Draw a list of indexed primitives
  28896. * @param fillMode defines the primitive to use
  28897. * @param indexStart defines the starting index
  28898. * @param indexCount defines the number of index to draw
  28899. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28900. */
  28901. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28902. /**
  28903. * Draw a list of unindexed primitives
  28904. * @param fillMode defines the primitive to use
  28905. * @param verticesStart defines the index of first vertex to draw
  28906. * @param verticesCount defines the count of vertices to draw
  28907. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28908. */
  28909. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28910. private _drawMode;
  28911. /** @hidden */
  28912. _releaseEffect(effect: Effect): void;
  28913. /** @hidden */
  28914. _deleteProgram(program: WebGLProgram): void;
  28915. /**
  28916. * Create a new effect (used to store vertex/fragment shaders)
  28917. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28918. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28919. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28920. * @param samplers defines an array of string used to represent textures
  28921. * @param defines defines the string containing the defines to use to compile the shaders
  28922. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28923. * @param onCompiled defines a function to call when the effect creation is successful
  28924. * @param onError defines a function to call when the effect creation has failed
  28925. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28926. * @returns the new Effect
  28927. */
  28928. 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;
  28929. private _compileShader;
  28930. private _compileRawShader;
  28931. /**
  28932. * Directly creates a webGL program
  28933. * @param vertexCode defines the vertex shader code to use
  28934. * @param fragmentCode defines the fragment shader code to use
  28935. * @param context defines the webGL context to use (if not set, the current one will be used)
  28936. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28937. * @returns the new webGL program
  28938. */
  28939. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28940. /**
  28941. * Creates a webGL program
  28942. * @param vertexCode defines the vertex shader code to use
  28943. * @param fragmentCode defines the fragment shader code to use
  28944. * @param defines defines the string containing the defines to use to compile the shaders
  28945. * @param context defines the webGL context to use (if not set, the current one will be used)
  28946. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28947. * @returns the new webGL program
  28948. */
  28949. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28950. private _createShaderProgram;
  28951. private _finalizeProgram;
  28952. /** @hidden */
  28953. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28954. /** @hidden */
  28955. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28956. /**
  28957. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28958. * @param shaderProgram defines the webGL program to use
  28959. * @param uniformsNames defines the list of uniform names
  28960. * @returns an array of webGL uniform locations
  28961. */
  28962. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28963. /**
  28964. * Gets the lsit of active attributes for a given webGL program
  28965. * @param shaderProgram defines the webGL program to use
  28966. * @param attributesNames defines the list of attribute names to get
  28967. * @returns an array of indices indicating the offset of each attribute
  28968. */
  28969. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28970. /**
  28971. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28972. * @param effect defines the effect to activate
  28973. */
  28974. enableEffect(effect: Nullable<Effect>): void;
  28975. /**
  28976. * Set the value of an uniform to an array of int32
  28977. * @param uniform defines the webGL uniform location where to store the value
  28978. * @param array defines the array of int32 to store
  28979. */
  28980. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28981. /**
  28982. * Set the value of an uniform to an array of int32 (stored as vec2)
  28983. * @param uniform defines the webGL uniform location where to store the value
  28984. * @param array defines the array of int32 to store
  28985. */
  28986. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28987. /**
  28988. * Set the value of an uniform to an array of int32 (stored as vec3)
  28989. * @param uniform defines the webGL uniform location where to store the value
  28990. * @param array defines the array of int32 to store
  28991. */
  28992. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28993. /**
  28994. * Set the value of an uniform to an array of int32 (stored as vec4)
  28995. * @param uniform defines the webGL uniform location where to store the value
  28996. * @param array defines the array of int32 to store
  28997. */
  28998. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28999. /**
  29000. * Set the value of an uniform to an array of float32
  29001. * @param uniform defines the webGL uniform location where to store the value
  29002. * @param array defines the array of float32 to store
  29003. */
  29004. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29005. /**
  29006. * Set the value of an uniform to an array of float32 (stored as vec2)
  29007. * @param uniform defines the webGL uniform location where to store the value
  29008. * @param array defines the array of float32 to store
  29009. */
  29010. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29011. /**
  29012. * Set the value of an uniform to an array of float32 (stored as vec3)
  29013. * @param uniform defines the webGL uniform location where to store the value
  29014. * @param array defines the array of float32 to store
  29015. */
  29016. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29017. /**
  29018. * Set the value of an uniform to an array of float32 (stored as vec4)
  29019. * @param uniform defines the webGL uniform location where to store the value
  29020. * @param array defines the array of float32 to store
  29021. */
  29022. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29023. /**
  29024. * Set the value of an uniform to an array of number
  29025. * @param uniform defines the webGL uniform location where to store the value
  29026. * @param array defines the array of number to store
  29027. */
  29028. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29029. /**
  29030. * Set the value of an uniform to an array of number (stored as vec2)
  29031. * @param uniform defines the webGL uniform location where to store the value
  29032. * @param array defines the array of number to store
  29033. */
  29034. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29035. /**
  29036. * Set the value of an uniform to an array of number (stored as vec3)
  29037. * @param uniform defines the webGL uniform location where to store the value
  29038. * @param array defines the array of number to store
  29039. */
  29040. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29041. /**
  29042. * Set the value of an uniform to an array of number (stored as vec4)
  29043. * @param uniform defines the webGL uniform location where to store the value
  29044. * @param array defines the array of number to store
  29045. */
  29046. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29047. /**
  29048. * Set the value of an uniform to an array of float32 (stored as matrices)
  29049. * @param uniform defines the webGL uniform location where to store the value
  29050. * @param matrices defines the array of float32 to store
  29051. */
  29052. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29053. /**
  29054. * Set the value of an uniform to a matrix
  29055. * @param uniform defines the webGL uniform location where to store the value
  29056. * @param matrix defines the matrix to store
  29057. */
  29058. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29059. /**
  29060. * Set the value of an uniform to a matrix (3x3)
  29061. * @param uniform defines the webGL uniform location where to store the value
  29062. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29063. */
  29064. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29065. /**
  29066. * Set the value of an uniform to a matrix (2x2)
  29067. * @param uniform defines the webGL uniform location where to store the value
  29068. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29069. */
  29070. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29071. /**
  29072. * Set the value of an uniform to a number (int)
  29073. * @param uniform defines the webGL uniform location where to store the value
  29074. * @param value defines the int number to store
  29075. */
  29076. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29077. /**
  29078. * Set the value of an uniform to a number (float)
  29079. * @param uniform defines the webGL uniform location where to store the value
  29080. * @param value defines the float number to store
  29081. */
  29082. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29083. /**
  29084. * Set the value of an uniform to a vec2
  29085. * @param uniform defines the webGL uniform location where to store the value
  29086. * @param x defines the 1st component of the value
  29087. * @param y defines the 2nd component of the value
  29088. */
  29089. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29090. /**
  29091. * Set the value of an uniform to a vec3
  29092. * @param uniform defines the webGL uniform location where to store the value
  29093. * @param x defines the 1st component of the value
  29094. * @param y defines the 2nd component of the value
  29095. * @param z defines the 3rd component of the value
  29096. */
  29097. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29098. /**
  29099. * Set the value of an uniform to a boolean
  29100. * @param uniform defines the webGL uniform location where to store the value
  29101. * @param bool defines the boolean to store
  29102. */
  29103. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29104. /**
  29105. * Set the value of an uniform to a vec4
  29106. * @param uniform defines the webGL uniform location where to store the value
  29107. * @param x defines the 1st component of the value
  29108. * @param y defines the 2nd component of the value
  29109. * @param z defines the 3rd component of the value
  29110. * @param w defines the 4th component of the value
  29111. */
  29112. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29113. /**
  29114. * Set the value of an uniform to a Color3
  29115. * @param uniform defines the webGL uniform location where to store the value
  29116. * @param color3 defines the color to store
  29117. */
  29118. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29119. /**
  29120. * Set the value of an uniform to a Color3 and an alpha value
  29121. * @param uniform defines the webGL uniform location where to store the value
  29122. * @param color3 defines the color to store
  29123. * @param alpha defines the alpha component to store
  29124. */
  29125. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29126. /**
  29127. * Sets a Color4 on a uniform variable
  29128. * @param uniform defines the uniform location
  29129. * @param color4 defines the value to be set
  29130. */
  29131. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29132. /**
  29133. * Set various states to the webGL context
  29134. * @param culling defines backface culling state
  29135. * @param zOffset defines the value to apply to zOffset (0 by default)
  29136. * @param force defines if states must be applied even if cache is up to date
  29137. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29138. */
  29139. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29140. /**
  29141. * Set the z offset to apply to current rendering
  29142. * @param value defines the offset to apply
  29143. */
  29144. setZOffset(value: number): void;
  29145. /**
  29146. * Gets the current value of the zOffset
  29147. * @returns the current zOffset state
  29148. */
  29149. getZOffset(): number;
  29150. /**
  29151. * Enable or disable depth buffering
  29152. * @param enable defines the state to set
  29153. */
  29154. setDepthBuffer(enable: boolean): void;
  29155. /**
  29156. * Gets a boolean indicating if depth writing is enabled
  29157. * @returns the current depth writing state
  29158. */
  29159. getDepthWrite(): boolean;
  29160. /**
  29161. * Enable or disable depth writing
  29162. * @param enable defines the state to set
  29163. */
  29164. setDepthWrite(enable: boolean): void;
  29165. /**
  29166. * Enable or disable color writing
  29167. * @param enable defines the state to set
  29168. */
  29169. setColorWrite(enable: boolean): void;
  29170. /**
  29171. * Gets a boolean indicating if color writing is enabled
  29172. * @returns the current color writing state
  29173. */
  29174. getColorWrite(): boolean;
  29175. /**
  29176. * Sets alpha constants used by some alpha blending modes
  29177. * @param r defines the red component
  29178. * @param g defines the green component
  29179. * @param b defines the blue component
  29180. * @param a defines the alpha component
  29181. */
  29182. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29183. /**
  29184. * Sets the current alpha mode
  29185. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29186. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29187. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29188. */
  29189. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29190. /**
  29191. * Gets the current alpha mode
  29192. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29193. * @returns the current alpha mode
  29194. */
  29195. getAlphaMode(): number;
  29196. /**
  29197. * Clears the list of texture accessible through engine.
  29198. * This can help preventing texture load conflict due to name collision.
  29199. */
  29200. clearInternalTexturesCache(): void;
  29201. /**
  29202. * Force the entire cache to be cleared
  29203. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29204. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29205. */
  29206. wipeCaches(bruteForce?: boolean): void;
  29207. /**
  29208. * Set the compressed texture format to use, based on the formats you have, and the formats
  29209. * supported by the hardware / browser.
  29210. *
  29211. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29212. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29213. * to API arguments needed to compressed textures. This puts the burden on the container
  29214. * generator to house the arcane code for determining these for current & future formats.
  29215. *
  29216. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29217. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29218. *
  29219. * Note: The result of this call is not taken into account when a texture is base64.
  29220. *
  29221. * @param formatsAvailable defines the list of those format families you have created
  29222. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29223. *
  29224. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29225. * @returns The extension selected.
  29226. */
  29227. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29228. /** @hidden */
  29229. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29230. min: number;
  29231. mag: number;
  29232. };
  29233. /** @hidden */
  29234. _createTexture(): WebGLTexture;
  29235. /**
  29236. * Usually called from Texture.ts.
  29237. * Passed information to create a WebGLTexture
  29238. * @param urlArg defines a value which contains one of the following:
  29239. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29240. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29241. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29242. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29243. * @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)
  29244. * @param scene needed for loading to the correct scene
  29245. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29246. * @param onLoad optional callback to be called upon successful completion
  29247. * @param onError optional callback to be called upon failure
  29248. * @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
  29249. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29250. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29251. * @param forcedExtension defines the extension to use to pick the right loader
  29252. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29253. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29254. */
  29255. 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;
  29256. private _rescaleTexture;
  29257. private _unpackFlipYCached;
  29258. /**
  29259. * In case you are sharing the context with other applications, it might
  29260. * be interested to not cache the unpack flip y state to ensure a consistent
  29261. * value would be set.
  29262. */
  29263. enableUnpackFlipYCached: boolean;
  29264. /** @hidden */
  29265. _unpackFlipY(value: boolean): void;
  29266. /** @hidden */
  29267. _getUnpackAlignement(): number;
  29268. /**
  29269. * Creates a dynamic texture
  29270. * @param width defines the width of the texture
  29271. * @param height defines the height of the texture
  29272. * @param generateMipMaps defines if the engine should generate the mip levels
  29273. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29274. * @returns the dynamic texture inside an InternalTexture
  29275. */
  29276. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29277. /**
  29278. * Update the sampling mode of a given texture
  29279. * @param samplingMode defines the required sampling mode
  29280. * @param texture defines the texture to update
  29281. */
  29282. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29283. /**
  29284. * Update the content of a dynamic texture
  29285. * @param texture defines the texture to update
  29286. * @param canvas defines the canvas containing the source
  29287. * @param invertY defines if data must be stored with Y axis inverted
  29288. * @param premulAlpha defines if alpha is stored as premultiplied
  29289. * @param format defines the format of the data
  29290. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29291. */
  29292. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29293. /**
  29294. * Update a video texture
  29295. * @param texture defines the texture to update
  29296. * @param video defines the video element to use
  29297. * @param invertY defines if data must be stored with Y axis inverted
  29298. */
  29299. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29300. /**
  29301. * Updates a depth texture Comparison Mode and Function.
  29302. * If the comparison Function is equal to 0, the mode will be set to none.
  29303. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29304. * @param texture The texture to set the comparison function for
  29305. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29306. */
  29307. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29308. /** @hidden */
  29309. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29310. width: number;
  29311. height: number;
  29312. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29313. /**
  29314. * Creates a depth stencil texture.
  29315. * This is only available in WebGL 2 or with the depth texture extension available.
  29316. * @param size The size of face edge in the texture.
  29317. * @param options The options defining the texture.
  29318. * @returns The texture
  29319. */
  29320. createDepthStencilTexture(size: number | {
  29321. width: number;
  29322. height: number;
  29323. }, options: DepthTextureCreationOptions): InternalTexture;
  29324. /**
  29325. * Creates a depth stencil texture.
  29326. * This is only available in WebGL 2 or with the depth texture extension available.
  29327. * @param size The size of face edge in the texture.
  29328. * @param options The options defining the texture.
  29329. * @returns The texture
  29330. */
  29331. private _createDepthStencilTexture;
  29332. /**
  29333. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29334. * @param renderTarget The render target to set the frame buffer for
  29335. */
  29336. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29337. /**
  29338. * Creates a new render target texture
  29339. * @param size defines the size of the texture
  29340. * @param options defines the options used to create the texture
  29341. * @returns a new render target texture stored in an InternalTexture
  29342. */
  29343. createRenderTargetTexture(size: number | {
  29344. width: number;
  29345. height: number;
  29346. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29347. /** @hidden */
  29348. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29349. /**
  29350. * Updates the sample count of a render target texture
  29351. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29352. * @param texture defines the texture to update
  29353. * @param samples defines the sample count to set
  29354. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29355. */
  29356. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29357. /** @hidden */
  29358. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29359. /** @hidden */
  29360. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29361. /** @hidden */
  29362. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29363. /** @hidden */
  29364. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29365. /**
  29366. * @hidden
  29367. */
  29368. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29369. private _prepareWebGLTextureContinuation;
  29370. private _prepareWebGLTexture;
  29371. /** @hidden */
  29372. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29373. /** @hidden */
  29374. _releaseFramebufferObjects(texture: InternalTexture): void;
  29375. /** @hidden */
  29376. _releaseTexture(texture: InternalTexture): void;
  29377. private setProgram;
  29378. private _boundUniforms;
  29379. /**
  29380. * Binds an effect to the webGL context
  29381. * @param effect defines the effect to bind
  29382. */
  29383. bindSamplers(effect: Effect): void;
  29384. private _activateCurrentTexture;
  29385. /** @hidden */
  29386. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29387. /** @hidden */
  29388. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29389. /**
  29390. * Sets a texture to the webGL context from a postprocess
  29391. * @param channel defines the channel to use
  29392. * @param postProcess defines the source postprocess
  29393. */
  29394. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29395. /**
  29396. * Binds the output of the passed in post process to the texture channel specified
  29397. * @param channel The channel the texture should be bound to
  29398. * @param postProcess The post process which's output should be bound
  29399. */
  29400. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29401. /**
  29402. * Unbind all textures from the webGL context
  29403. */
  29404. unbindAllTextures(): void;
  29405. /**
  29406. * Sets a texture to the according uniform.
  29407. * @param channel The texture channel
  29408. * @param uniform The uniform to set
  29409. * @param texture The texture to apply
  29410. */
  29411. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29412. /**
  29413. * Sets a depth stencil texture from a render target to the according uniform.
  29414. * @param channel The texture channel
  29415. * @param uniform The uniform to set
  29416. * @param texture The render target texture containing the depth stencil texture to apply
  29417. */
  29418. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29419. private _bindSamplerUniformToChannel;
  29420. private _getTextureWrapMode;
  29421. private _setTexture;
  29422. /**
  29423. * Sets an array of texture to the webGL context
  29424. * @param channel defines the channel where the texture array must be set
  29425. * @param uniform defines the associated uniform location
  29426. * @param textures defines the array of textures to bind
  29427. */
  29428. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29429. /** @hidden */
  29430. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29431. private _setTextureParameterFloat;
  29432. private _setTextureParameterInteger;
  29433. /**
  29434. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29435. * @param x defines the x coordinate of the rectangle where pixels must be read
  29436. * @param y defines the y coordinate of the rectangle where pixels must be read
  29437. * @param width defines the width of the rectangle where pixels must be read
  29438. * @param height defines the height of the rectangle where pixels must be read
  29439. * @returns a Uint8Array containing RGBA colors
  29440. */
  29441. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29442. /**
  29443. * Add an externaly attached data from its key.
  29444. * This method call will fail and return false, if such key already exists.
  29445. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29446. * @param key the unique key that identifies the data
  29447. * @param data the data object to associate to the key for this Engine instance
  29448. * @return true if no such key were already present and the data was added successfully, false otherwise
  29449. */
  29450. addExternalData<T>(key: string, data: T): boolean;
  29451. /**
  29452. * Get an externaly attached data from its key
  29453. * @param key the unique key that identifies the data
  29454. * @return the associated data, if present (can be null), or undefined if not present
  29455. */
  29456. getExternalData<T>(key: string): T;
  29457. /**
  29458. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29459. * @param key the unique key that identifies the data
  29460. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29461. * @return the associated data, can be null if the factory returned null.
  29462. */
  29463. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29464. /**
  29465. * Remove an externaly attached data from the Engine instance
  29466. * @param key the unique key that identifies the data
  29467. * @return true if the data was successfully removed, false if it doesn't exist
  29468. */
  29469. removeExternalData(key: string): boolean;
  29470. /**
  29471. * Unbind all vertex attributes from the webGL context
  29472. */
  29473. unbindAllAttributes(): void;
  29474. /**
  29475. * 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
  29476. */
  29477. releaseEffects(): void;
  29478. /**
  29479. * Dispose and release all associated resources
  29480. */
  29481. dispose(): void;
  29482. /**
  29483. * Display the loading screen
  29484. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29485. */
  29486. displayLoadingUI(): void;
  29487. /**
  29488. * Hide the loading screen
  29489. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29490. */
  29491. hideLoadingUI(): void;
  29492. /**
  29493. * Gets the current loading screen object
  29494. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29495. */
  29496. /**
  29497. * Sets the current loading screen object
  29498. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29499. */
  29500. loadingScreen: ILoadingScreen;
  29501. /**
  29502. * Sets the current loading screen text
  29503. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29504. */
  29505. loadingUIText: string;
  29506. /**
  29507. * Sets the current loading screen background color
  29508. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29509. */
  29510. loadingUIBackgroundColor: string;
  29511. /**
  29512. * Attach a new callback raised when context lost event is fired
  29513. * @param callback defines the callback to call
  29514. */
  29515. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29516. /**
  29517. * Attach a new callback raised when context restored event is fired
  29518. * @param callback defines the callback to call
  29519. */
  29520. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29521. /**
  29522. * Gets the source code of the vertex shader associated with a specific webGL program
  29523. * @param program defines the program to use
  29524. * @returns a string containing the source code of the vertex shader associated with the program
  29525. */
  29526. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29527. /**
  29528. * Gets the source code of the fragment shader associated with a specific webGL program
  29529. * @param program defines the program to use
  29530. * @returns a string containing the source code of the fragment shader associated with the program
  29531. */
  29532. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29533. /**
  29534. * Get the current error code of the webGL context
  29535. * @returns the error code
  29536. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29537. */
  29538. getError(): number;
  29539. /**
  29540. * Gets the current framerate
  29541. * @returns a number representing the framerate
  29542. */
  29543. getFps(): number;
  29544. /**
  29545. * Gets the time spent between current and previous frame
  29546. * @returns a number representing the delta time in ms
  29547. */
  29548. getDeltaTime(): number;
  29549. private _measureFps;
  29550. /** @hidden */
  29551. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29552. private _canRenderToFloatFramebuffer;
  29553. private _canRenderToHalfFloatFramebuffer;
  29554. private _canRenderToFramebuffer;
  29555. /** @hidden */
  29556. _getWebGLTextureType(type: number): number;
  29557. /** @hidden */
  29558. _getInternalFormat(format: number): number;
  29559. /** @hidden */
  29560. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29561. /** @hidden */
  29562. _getRGBAMultiSampleBufferFormat(type: number): number;
  29563. /** @hidden */
  29564. _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;
  29565. /** @hidden */
  29566. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29567. /**
  29568. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29569. * @returns true if the engine can be created
  29570. * @ignorenaming
  29571. */
  29572. static isSupported(): boolean;
  29573. }
  29574. }
  29575. declare module "babylonjs/Materials/effect" {
  29576. import { Observable } from "babylonjs/Misc/observable";
  29577. import { Nullable } from "babylonjs/types";
  29578. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29579. import { IDisposable } from "babylonjs/scene";
  29580. import { Engine } from "babylonjs/Engines/engine";
  29581. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29582. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29583. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29584. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29586. /**
  29587. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29588. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29589. */
  29590. export class EffectFallbacks {
  29591. private _defines;
  29592. private _currentRank;
  29593. private _maxRank;
  29594. private _mesh;
  29595. /**
  29596. * Removes the fallback from the bound mesh.
  29597. */
  29598. unBindMesh(): void;
  29599. /**
  29600. * Adds a fallback on the specified property.
  29601. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29602. * @param define The name of the define in the shader
  29603. */
  29604. addFallback(rank: number, define: string): void;
  29605. /**
  29606. * Sets the mesh to use CPU skinning when needing to fallback.
  29607. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29608. * @param mesh The mesh to use the fallbacks.
  29609. */
  29610. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29611. /**
  29612. * Checks to see if more fallbacks are still availible.
  29613. */
  29614. readonly isMoreFallbacks: boolean;
  29615. /**
  29616. * Removes the defines that shoould be removed when falling back.
  29617. * @param currentDefines defines the current define statements for the shader.
  29618. * @param effect defines the current effect we try to compile
  29619. * @returns The resulting defines with defines of the current rank removed.
  29620. */
  29621. reduce(currentDefines: string, effect: Effect): string;
  29622. }
  29623. /**
  29624. * Options to be used when creating an effect.
  29625. */
  29626. export class EffectCreationOptions {
  29627. /**
  29628. * Atrributes that will be used in the shader.
  29629. */
  29630. attributes: string[];
  29631. /**
  29632. * Uniform varible names that will be set in the shader.
  29633. */
  29634. uniformsNames: string[];
  29635. /**
  29636. * Uniform buffer varible names that will be set in the shader.
  29637. */
  29638. uniformBuffersNames: string[];
  29639. /**
  29640. * Sampler texture variable names that will be set in the shader.
  29641. */
  29642. samplers: string[];
  29643. /**
  29644. * Define statements that will be set in the shader.
  29645. */
  29646. defines: any;
  29647. /**
  29648. * Possible fallbacks for this effect to improve performance when needed.
  29649. */
  29650. fallbacks: Nullable<EffectFallbacks>;
  29651. /**
  29652. * Callback that will be called when the shader is compiled.
  29653. */
  29654. onCompiled: Nullable<(effect: Effect) => void>;
  29655. /**
  29656. * Callback that will be called if an error occurs during shader compilation.
  29657. */
  29658. onError: Nullable<(effect: Effect, errors: string) => void>;
  29659. /**
  29660. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29661. */
  29662. indexParameters: any;
  29663. /**
  29664. * Max number of lights that can be used in the shader.
  29665. */
  29666. maxSimultaneousLights: number;
  29667. /**
  29668. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29669. */
  29670. transformFeedbackVaryings: Nullable<string[]>;
  29671. }
  29672. /**
  29673. * Effect containing vertex and fragment shader that can be executed on an object.
  29674. */
  29675. export class Effect implements IDisposable {
  29676. /**
  29677. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29678. */
  29679. static ShadersRepository: string;
  29680. /**
  29681. * Name of the effect.
  29682. */
  29683. name: any;
  29684. /**
  29685. * String container all the define statements that should be set on the shader.
  29686. */
  29687. defines: string;
  29688. /**
  29689. * Callback that will be called when the shader is compiled.
  29690. */
  29691. onCompiled: Nullable<(effect: Effect) => void>;
  29692. /**
  29693. * Callback that will be called if an error occurs during shader compilation.
  29694. */
  29695. onError: Nullable<(effect: Effect, errors: string) => void>;
  29696. /**
  29697. * Callback that will be called when effect is bound.
  29698. */
  29699. onBind: Nullable<(effect: Effect) => void>;
  29700. /**
  29701. * Unique ID of the effect.
  29702. */
  29703. uniqueId: number;
  29704. /**
  29705. * Observable that will be called when the shader is compiled.
  29706. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29707. */
  29708. onCompileObservable: Observable<Effect>;
  29709. /**
  29710. * Observable that will be called if an error occurs during shader compilation.
  29711. */
  29712. onErrorObservable: Observable<Effect>;
  29713. /** @hidden */
  29714. _onBindObservable: Nullable<Observable<Effect>>;
  29715. /**
  29716. * Observable that will be called when effect is bound.
  29717. */
  29718. readonly onBindObservable: Observable<Effect>;
  29719. /** @hidden */
  29720. _bonesComputationForcedToCPU: boolean;
  29721. private static _uniqueIdSeed;
  29722. private _engine;
  29723. private _uniformBuffersNames;
  29724. private _uniformsNames;
  29725. private _samplerList;
  29726. private _samplers;
  29727. private _isReady;
  29728. private _compilationError;
  29729. private _attributesNames;
  29730. private _attributes;
  29731. private _uniforms;
  29732. /**
  29733. * Key for the effect.
  29734. * @hidden
  29735. */
  29736. _key: string;
  29737. private _indexParameters;
  29738. private _fallbacks;
  29739. private _vertexSourceCode;
  29740. private _fragmentSourceCode;
  29741. private _vertexSourceCodeOverride;
  29742. private _fragmentSourceCodeOverride;
  29743. private _transformFeedbackVaryings;
  29744. /**
  29745. * Compiled shader to webGL program.
  29746. * @hidden
  29747. */
  29748. _program: WebGLProgram;
  29749. private _valueCache;
  29750. private static _baseCache;
  29751. /**
  29752. * Instantiates an effect.
  29753. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29754. * @param baseName Name of the effect.
  29755. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29756. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29757. * @param samplers List of sampler variables that will be passed to the shader.
  29758. * @param engine Engine to be used to render the effect
  29759. * @param defines Define statements to be added to the shader.
  29760. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29761. * @param onCompiled Callback that will be called when the shader is compiled.
  29762. * @param onError Callback that will be called if an error occurs during shader compilation.
  29763. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29764. */
  29765. 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);
  29766. /**
  29767. * Unique key for this effect
  29768. */
  29769. readonly key: string;
  29770. /**
  29771. * If the effect has been compiled and prepared.
  29772. * @returns if the effect is compiled and prepared.
  29773. */
  29774. isReady(): boolean;
  29775. /**
  29776. * The engine the effect was initialized with.
  29777. * @returns the engine.
  29778. */
  29779. getEngine(): Engine;
  29780. /**
  29781. * The compiled webGL program for the effect
  29782. * @returns the webGL program.
  29783. */
  29784. getProgram(): WebGLProgram;
  29785. /**
  29786. * The set of names of attribute variables for the shader.
  29787. * @returns An array of attribute names.
  29788. */
  29789. getAttributesNames(): string[];
  29790. /**
  29791. * Returns the attribute at the given index.
  29792. * @param index The index of the attribute.
  29793. * @returns The location of the attribute.
  29794. */
  29795. getAttributeLocation(index: number): number;
  29796. /**
  29797. * Returns the attribute based on the name of the variable.
  29798. * @param name of the attribute to look up.
  29799. * @returns the attribute location.
  29800. */
  29801. getAttributeLocationByName(name: string): number;
  29802. /**
  29803. * The number of attributes.
  29804. * @returns the numnber of attributes.
  29805. */
  29806. getAttributesCount(): number;
  29807. /**
  29808. * Gets the index of a uniform variable.
  29809. * @param uniformName of the uniform to look up.
  29810. * @returns the index.
  29811. */
  29812. getUniformIndex(uniformName: string): number;
  29813. /**
  29814. * Returns the attribute based on the name of the variable.
  29815. * @param uniformName of the uniform to look up.
  29816. * @returns the location of the uniform.
  29817. */
  29818. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29819. /**
  29820. * Returns an array of sampler variable names
  29821. * @returns The array of sampler variable neames.
  29822. */
  29823. getSamplers(): string[];
  29824. /**
  29825. * The error from the last compilation.
  29826. * @returns the error string.
  29827. */
  29828. getCompilationError(): string;
  29829. /**
  29830. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29831. * @param func The callback to be used.
  29832. */
  29833. executeWhenCompiled(func: (effect: Effect) => void): void;
  29834. private _checkIsReady;
  29835. /** @hidden */
  29836. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29837. /** @hidden */
  29838. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29839. /** @hidden */
  29840. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29841. private _processShaderConversion;
  29842. private _processIncludes;
  29843. private _processPrecision;
  29844. /**
  29845. * Recompiles the webGL program
  29846. * @param vertexSourceCode The source code for the vertex shader.
  29847. * @param fragmentSourceCode The source code for the fragment shader.
  29848. * @param onCompiled Callback called when completed.
  29849. * @param onError Callback called on error.
  29850. * @hidden
  29851. */
  29852. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29853. /**
  29854. * Gets the uniform locations of the the specified variable names
  29855. * @param names THe names of the variables to lookup.
  29856. * @returns Array of locations in the same order as variable names.
  29857. */
  29858. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29859. /**
  29860. * Prepares the effect
  29861. * @hidden
  29862. */
  29863. _prepareEffect(): void;
  29864. /**
  29865. * Checks if the effect is supported. (Must be called after compilation)
  29866. */
  29867. readonly isSupported: boolean;
  29868. /**
  29869. * Binds a texture to the engine to be used as output of the shader.
  29870. * @param channel Name of the output variable.
  29871. * @param texture Texture to bind.
  29872. * @hidden
  29873. */
  29874. _bindTexture(channel: string, texture: InternalTexture): void;
  29875. /**
  29876. * Sets a texture on the engine to be used in the shader.
  29877. * @param channel Name of the sampler variable.
  29878. * @param texture Texture to set.
  29879. */
  29880. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29881. /**
  29882. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29883. * @param channel Name of the sampler variable.
  29884. * @param texture Texture to set.
  29885. */
  29886. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29887. /**
  29888. * Sets an array of textures on the engine to be used in the shader.
  29889. * @param channel Name of the variable.
  29890. * @param textures Textures to set.
  29891. */
  29892. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29893. /**
  29894. * 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)
  29895. * @param channel Name of the sampler variable.
  29896. * @param postProcess Post process to get the input texture from.
  29897. */
  29898. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29899. /**
  29900. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29901. * 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)
  29902. * @param channel Name of the sampler variable.
  29903. * @param postProcess Post process to get the output texture from.
  29904. */
  29905. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29906. /** @hidden */
  29907. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29908. /** @hidden */
  29909. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29910. /** @hidden */
  29911. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29912. /** @hidden */
  29913. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29914. /**
  29915. * Binds a buffer to a uniform.
  29916. * @param buffer Buffer to bind.
  29917. * @param name Name of the uniform variable to bind to.
  29918. */
  29919. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29920. /**
  29921. * Binds block to a uniform.
  29922. * @param blockName Name of the block to bind.
  29923. * @param index Index to bind.
  29924. */
  29925. bindUniformBlock(blockName: string, index: number): void;
  29926. /**
  29927. * Sets an interger value on a uniform variable.
  29928. * @param uniformName Name of the variable.
  29929. * @param value Value to be set.
  29930. * @returns this effect.
  29931. */
  29932. setInt(uniformName: string, value: number): Effect;
  29933. /**
  29934. * Sets an int array on a uniform variable.
  29935. * @param uniformName Name of the variable.
  29936. * @param array array to be set.
  29937. * @returns this effect.
  29938. */
  29939. setIntArray(uniformName: string, array: Int32Array): Effect;
  29940. /**
  29941. * 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)
  29942. * @param uniformName Name of the variable.
  29943. * @param array array to be set.
  29944. * @returns this effect.
  29945. */
  29946. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29947. /**
  29948. * 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)
  29949. * @param uniformName Name of the variable.
  29950. * @param array array to be set.
  29951. * @returns this effect.
  29952. */
  29953. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29954. /**
  29955. * 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)
  29956. * @param uniformName Name of the variable.
  29957. * @param array array to be set.
  29958. * @returns this effect.
  29959. */
  29960. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29961. /**
  29962. * Sets an float array on a uniform variable.
  29963. * @param uniformName Name of the variable.
  29964. * @param array array to be set.
  29965. * @returns this effect.
  29966. */
  29967. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29968. /**
  29969. * 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)
  29970. * @param uniformName Name of the variable.
  29971. * @param array array to be set.
  29972. * @returns this effect.
  29973. */
  29974. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29975. /**
  29976. * 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)
  29977. * @param uniformName Name of the variable.
  29978. * @param array array to be set.
  29979. * @returns this effect.
  29980. */
  29981. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29982. /**
  29983. * 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)
  29984. * @param uniformName Name of the variable.
  29985. * @param array array to be set.
  29986. * @returns this effect.
  29987. */
  29988. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29989. /**
  29990. * Sets an array on a uniform variable.
  29991. * @param uniformName Name of the variable.
  29992. * @param array array to be set.
  29993. * @returns this effect.
  29994. */
  29995. setArray(uniformName: string, array: number[]): Effect;
  29996. /**
  29997. * 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)
  29998. * @param uniformName Name of the variable.
  29999. * @param array array to be set.
  30000. * @returns this effect.
  30001. */
  30002. setArray2(uniformName: string, array: number[]): Effect;
  30003. /**
  30004. * 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)
  30005. * @param uniformName Name of the variable.
  30006. * @param array array to be set.
  30007. * @returns this effect.
  30008. */
  30009. setArray3(uniformName: string, array: number[]): Effect;
  30010. /**
  30011. * 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)
  30012. * @param uniformName Name of the variable.
  30013. * @param array array to be set.
  30014. * @returns this effect.
  30015. */
  30016. setArray4(uniformName: string, array: number[]): Effect;
  30017. /**
  30018. * Sets matrices on a uniform variable.
  30019. * @param uniformName Name of the variable.
  30020. * @param matrices matrices to be set.
  30021. * @returns this effect.
  30022. */
  30023. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30024. /**
  30025. * Sets matrix on a uniform variable.
  30026. * @param uniformName Name of the variable.
  30027. * @param matrix matrix to be set.
  30028. * @returns this effect.
  30029. */
  30030. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30031. /**
  30032. * 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)
  30033. * @param uniformName Name of the variable.
  30034. * @param matrix matrix to be set.
  30035. * @returns this effect.
  30036. */
  30037. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30038. /**
  30039. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30040. * @param uniformName Name of the variable.
  30041. * @param matrix matrix to be set.
  30042. * @returns this effect.
  30043. */
  30044. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30045. /**
  30046. * Sets a float on a uniform variable.
  30047. * @param uniformName Name of the variable.
  30048. * @param value value to be set.
  30049. * @returns this effect.
  30050. */
  30051. setFloat(uniformName: string, value: number): Effect;
  30052. /**
  30053. * Sets a boolean on a uniform variable.
  30054. * @param uniformName Name of the variable.
  30055. * @param bool value to be set.
  30056. * @returns this effect.
  30057. */
  30058. setBool(uniformName: string, bool: boolean): Effect;
  30059. /**
  30060. * Sets a Vector2 on a uniform variable.
  30061. * @param uniformName Name of the variable.
  30062. * @param vector2 vector2 to be set.
  30063. * @returns this effect.
  30064. */
  30065. setVector2(uniformName: string, vector2: Vector2): Effect;
  30066. /**
  30067. * Sets a float2 on a uniform variable.
  30068. * @param uniformName Name of the variable.
  30069. * @param x First float in float2.
  30070. * @param y Second float in float2.
  30071. * @returns this effect.
  30072. */
  30073. setFloat2(uniformName: string, x: number, y: number): Effect;
  30074. /**
  30075. * Sets a Vector3 on a uniform variable.
  30076. * @param uniformName Name of the variable.
  30077. * @param vector3 Value to be set.
  30078. * @returns this effect.
  30079. */
  30080. setVector3(uniformName: string, vector3: Vector3): Effect;
  30081. /**
  30082. * Sets a float3 on a uniform variable.
  30083. * @param uniformName Name of the variable.
  30084. * @param x First float in float3.
  30085. * @param y Second float in float3.
  30086. * @param z Third float in float3.
  30087. * @returns this effect.
  30088. */
  30089. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30090. /**
  30091. * Sets a Vector4 on a uniform variable.
  30092. * @param uniformName Name of the variable.
  30093. * @param vector4 Value to be set.
  30094. * @returns this effect.
  30095. */
  30096. setVector4(uniformName: string, vector4: Vector4): Effect;
  30097. /**
  30098. * Sets a float4 on a uniform variable.
  30099. * @param uniformName Name of the variable.
  30100. * @param x First float in float4.
  30101. * @param y Second float in float4.
  30102. * @param z Third float in float4.
  30103. * @param w Fourth float in float4.
  30104. * @returns this effect.
  30105. */
  30106. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30107. /**
  30108. * Sets a Color3 on a uniform variable.
  30109. * @param uniformName Name of the variable.
  30110. * @param color3 Value to be set.
  30111. * @returns this effect.
  30112. */
  30113. setColor3(uniformName: string, color3: Color3): Effect;
  30114. /**
  30115. * Sets a Color4 on a uniform variable.
  30116. * @param uniformName Name of the variable.
  30117. * @param color3 Value to be set.
  30118. * @param alpha Alpha value to be set.
  30119. * @returns this effect.
  30120. */
  30121. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30122. /**
  30123. * Sets a Color4 on a uniform variable
  30124. * @param uniformName defines the name of the variable
  30125. * @param color4 defines the value to be set
  30126. * @returns this effect.
  30127. */
  30128. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30129. /** Release all associated resources */
  30130. dispose(): void;
  30131. /**
  30132. * This function will add a new shader to the shader store
  30133. * @param name the name of the shader
  30134. * @param pixelShader optional pixel shader content
  30135. * @param vertexShader optional vertex shader content
  30136. */
  30137. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30138. /**
  30139. * Store of each shader (The can be looked up using effect.key)
  30140. */
  30141. static ShadersStore: {
  30142. [key: string]: string;
  30143. };
  30144. /**
  30145. * Store of each included file for a shader (The can be looked up using effect.key)
  30146. */
  30147. static IncludesShadersStore: {
  30148. [key: string]: string;
  30149. };
  30150. /**
  30151. * Resets the cache of effects.
  30152. */
  30153. static ResetCache(): void;
  30154. }
  30155. }
  30156. declare module "babylonjs/Materials/colorCurves" {
  30157. import { Effect } from "babylonjs/Materials/effect";
  30158. /**
  30159. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30160. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30161. * 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;
  30162. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30163. */
  30164. export class ColorCurves {
  30165. private _dirty;
  30166. private _tempColor;
  30167. private _globalCurve;
  30168. private _highlightsCurve;
  30169. private _midtonesCurve;
  30170. private _shadowsCurve;
  30171. private _positiveCurve;
  30172. private _negativeCurve;
  30173. private _globalHue;
  30174. private _globalDensity;
  30175. private _globalSaturation;
  30176. private _globalExposure;
  30177. /**
  30178. * Gets the global Hue value.
  30179. * 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).
  30180. */
  30181. /**
  30182. * Sets the global Hue value.
  30183. * 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).
  30184. */
  30185. globalHue: number;
  30186. /**
  30187. * Gets the global Density value.
  30188. * 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.
  30189. * Values less than zero provide a filter of opposite hue.
  30190. */
  30191. /**
  30192. * Sets the global Density value.
  30193. * 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.
  30194. * Values less than zero provide a filter of opposite hue.
  30195. */
  30196. globalDensity: number;
  30197. /**
  30198. * Gets the global Saturation value.
  30199. * 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.
  30200. */
  30201. /**
  30202. * Sets the global Saturation value.
  30203. * 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.
  30204. */
  30205. globalSaturation: number;
  30206. /**
  30207. * Gets the global Exposure value.
  30208. * 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.
  30209. */
  30210. /**
  30211. * Sets the global Exposure value.
  30212. * 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.
  30213. */
  30214. globalExposure: number;
  30215. private _highlightsHue;
  30216. private _highlightsDensity;
  30217. private _highlightsSaturation;
  30218. private _highlightsExposure;
  30219. /**
  30220. * Gets the highlights Hue value.
  30221. * 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).
  30222. */
  30223. /**
  30224. * Sets the highlights Hue value.
  30225. * 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).
  30226. */
  30227. highlightsHue: number;
  30228. /**
  30229. * Gets the highlights Density value.
  30230. * 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.
  30231. * Values less than zero provide a filter of opposite hue.
  30232. */
  30233. /**
  30234. * Sets the highlights Density value.
  30235. * 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.
  30236. * Values less than zero provide a filter of opposite hue.
  30237. */
  30238. highlightsDensity: number;
  30239. /**
  30240. * Gets the highlights Saturation value.
  30241. * 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.
  30242. */
  30243. /**
  30244. * Sets the highlights Saturation value.
  30245. * 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.
  30246. */
  30247. highlightsSaturation: number;
  30248. /**
  30249. * Gets the highlights Exposure value.
  30250. * 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.
  30251. */
  30252. /**
  30253. * Sets the highlights Exposure value.
  30254. * 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.
  30255. */
  30256. highlightsExposure: number;
  30257. private _midtonesHue;
  30258. private _midtonesDensity;
  30259. private _midtonesSaturation;
  30260. private _midtonesExposure;
  30261. /**
  30262. * Gets the midtones Hue value.
  30263. * 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).
  30264. */
  30265. /**
  30266. * Sets the midtones Hue value.
  30267. * 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).
  30268. */
  30269. midtonesHue: number;
  30270. /**
  30271. * Gets the midtones Density value.
  30272. * 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.
  30273. * Values less than zero provide a filter of opposite hue.
  30274. */
  30275. /**
  30276. * Sets the midtones Density value.
  30277. * 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.
  30278. * Values less than zero provide a filter of opposite hue.
  30279. */
  30280. midtonesDensity: number;
  30281. /**
  30282. * Gets the midtones Saturation value.
  30283. * 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.
  30284. */
  30285. /**
  30286. * Sets the midtones Saturation value.
  30287. * 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.
  30288. */
  30289. midtonesSaturation: number;
  30290. /**
  30291. * Gets the midtones Exposure value.
  30292. * 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.
  30293. */
  30294. /**
  30295. * Sets the midtones Exposure value.
  30296. * 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.
  30297. */
  30298. midtonesExposure: number;
  30299. private _shadowsHue;
  30300. private _shadowsDensity;
  30301. private _shadowsSaturation;
  30302. private _shadowsExposure;
  30303. /**
  30304. * Gets the shadows Hue value.
  30305. * 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).
  30306. */
  30307. /**
  30308. * Sets the shadows Hue value.
  30309. * 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).
  30310. */
  30311. shadowsHue: number;
  30312. /**
  30313. * Gets the shadows Density value.
  30314. * 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.
  30315. * Values less than zero provide a filter of opposite hue.
  30316. */
  30317. /**
  30318. * Sets the shadows Density value.
  30319. * 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.
  30320. * Values less than zero provide a filter of opposite hue.
  30321. */
  30322. shadowsDensity: number;
  30323. /**
  30324. * Gets the shadows Saturation value.
  30325. * 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.
  30326. */
  30327. /**
  30328. * Sets the shadows Saturation value.
  30329. * 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.
  30330. */
  30331. shadowsSaturation: number;
  30332. /**
  30333. * Gets the shadows Exposure value.
  30334. * 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.
  30335. */
  30336. /**
  30337. * Sets the shadows Exposure value.
  30338. * 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.
  30339. */
  30340. shadowsExposure: number;
  30341. /**
  30342. * Returns the class name
  30343. * @returns The class name
  30344. */
  30345. getClassName(): string;
  30346. /**
  30347. * Binds the color curves to the shader.
  30348. * @param colorCurves The color curve to bind
  30349. * @param effect The effect to bind to
  30350. * @param positiveUniform The positive uniform shader parameter
  30351. * @param neutralUniform The neutral uniform shader parameter
  30352. * @param negativeUniform The negative uniform shader parameter
  30353. */
  30354. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30355. /**
  30356. * Prepare the list of uniforms associated with the ColorCurves effects.
  30357. * @param uniformsList The list of uniforms used in the effect
  30358. */
  30359. static PrepareUniforms(uniformsList: string[]): void;
  30360. /**
  30361. * Returns color grading data based on a hue, density, saturation and exposure value.
  30362. * @param filterHue The hue of the color filter.
  30363. * @param filterDensity The density of the color filter.
  30364. * @param saturation The saturation.
  30365. * @param exposure The exposure.
  30366. * @param result The result data container.
  30367. */
  30368. private getColorGradingDataToRef;
  30369. /**
  30370. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30371. * @param value The input slider value in range [-100,100].
  30372. * @returns Adjusted value.
  30373. */
  30374. private static applyColorGradingSliderNonlinear;
  30375. /**
  30376. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30377. * @param hue The hue (H) input.
  30378. * @param saturation The saturation (S) input.
  30379. * @param brightness The brightness (B) input.
  30380. * @result An RGBA color represented as Vector4.
  30381. */
  30382. private static fromHSBToRef;
  30383. /**
  30384. * Returns a value clamped between min and max
  30385. * @param value The value to clamp
  30386. * @param min The minimum of value
  30387. * @param max The maximum of value
  30388. * @returns The clamped value.
  30389. */
  30390. private static clamp;
  30391. /**
  30392. * Clones the current color curve instance.
  30393. * @return The cloned curves
  30394. */
  30395. clone(): ColorCurves;
  30396. /**
  30397. * Serializes the current color curve instance to a json representation.
  30398. * @return a JSON representation
  30399. */
  30400. serialize(): any;
  30401. /**
  30402. * Parses the color curve from a json representation.
  30403. * @param source the JSON source to parse
  30404. * @return The parsed curves
  30405. */
  30406. static Parse(source: any): ColorCurves;
  30407. }
  30408. }
  30409. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30410. import { Observable } from "babylonjs/Misc/observable";
  30411. import { Nullable } from "babylonjs/types";
  30412. import { Color4 } from "babylonjs/Maths/math";
  30413. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30414. import { Effect } from "babylonjs/Materials/effect";
  30415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30416. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30417. /**
  30418. * Interface to follow in your material defines to integrate easily the
  30419. * Image proccessing functions.
  30420. * @hidden
  30421. */
  30422. export interface IImageProcessingConfigurationDefines {
  30423. IMAGEPROCESSING: boolean;
  30424. VIGNETTE: boolean;
  30425. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30426. VIGNETTEBLENDMODEOPAQUE: boolean;
  30427. TONEMAPPING: boolean;
  30428. TONEMAPPING_ACES: boolean;
  30429. CONTRAST: boolean;
  30430. EXPOSURE: boolean;
  30431. COLORCURVES: boolean;
  30432. COLORGRADING: boolean;
  30433. COLORGRADING3D: boolean;
  30434. SAMPLER3DGREENDEPTH: boolean;
  30435. SAMPLER3DBGRMAP: boolean;
  30436. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30437. }
  30438. /**
  30439. * @hidden
  30440. */
  30441. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30442. IMAGEPROCESSING: boolean;
  30443. VIGNETTE: boolean;
  30444. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30445. VIGNETTEBLENDMODEOPAQUE: boolean;
  30446. TONEMAPPING: boolean;
  30447. TONEMAPPING_ACES: boolean;
  30448. CONTRAST: boolean;
  30449. COLORCURVES: boolean;
  30450. COLORGRADING: boolean;
  30451. COLORGRADING3D: boolean;
  30452. SAMPLER3DGREENDEPTH: boolean;
  30453. SAMPLER3DBGRMAP: boolean;
  30454. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30455. EXPOSURE: boolean;
  30456. constructor();
  30457. }
  30458. /**
  30459. * This groups together the common properties used for image processing either in direct forward pass
  30460. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30461. * or not.
  30462. */
  30463. export class ImageProcessingConfiguration {
  30464. /**
  30465. * Default tone mapping applied in BabylonJS.
  30466. */
  30467. static readonly TONEMAPPING_STANDARD: number;
  30468. /**
  30469. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30470. * to other engines rendering to increase portability.
  30471. */
  30472. static readonly TONEMAPPING_ACES: number;
  30473. /**
  30474. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30475. */
  30476. colorCurves: Nullable<ColorCurves>;
  30477. private _colorCurvesEnabled;
  30478. /**
  30479. * Gets wether the color curves effect is enabled.
  30480. */
  30481. /**
  30482. * Sets wether the color curves effect is enabled.
  30483. */
  30484. colorCurvesEnabled: boolean;
  30485. private _colorGradingTexture;
  30486. /**
  30487. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30488. */
  30489. /**
  30490. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30491. */
  30492. colorGradingTexture: Nullable<BaseTexture>;
  30493. private _colorGradingEnabled;
  30494. /**
  30495. * Gets wether the color grading effect is enabled.
  30496. */
  30497. /**
  30498. * Sets wether the color grading effect is enabled.
  30499. */
  30500. colorGradingEnabled: boolean;
  30501. private _colorGradingWithGreenDepth;
  30502. /**
  30503. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30504. */
  30505. /**
  30506. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30507. */
  30508. colorGradingWithGreenDepth: boolean;
  30509. private _colorGradingBGR;
  30510. /**
  30511. * Gets wether the color grading texture contains BGR values.
  30512. */
  30513. /**
  30514. * Sets wether the color grading texture contains BGR values.
  30515. */
  30516. colorGradingBGR: boolean;
  30517. /** @hidden */
  30518. _exposure: number;
  30519. /**
  30520. * Gets the Exposure used in the effect.
  30521. */
  30522. /**
  30523. * Sets the Exposure used in the effect.
  30524. */
  30525. exposure: number;
  30526. private _toneMappingEnabled;
  30527. /**
  30528. * Gets wether the tone mapping effect is enabled.
  30529. */
  30530. /**
  30531. * Sets wether the tone mapping effect is enabled.
  30532. */
  30533. toneMappingEnabled: boolean;
  30534. private _toneMappingType;
  30535. /**
  30536. * Gets the type of tone mapping effect.
  30537. */
  30538. /**
  30539. * Sets the type of tone mapping effect used in BabylonJS.
  30540. */
  30541. toneMappingType: number;
  30542. protected _contrast: number;
  30543. /**
  30544. * Gets the contrast used in the effect.
  30545. */
  30546. /**
  30547. * Sets the contrast used in the effect.
  30548. */
  30549. contrast: number;
  30550. /**
  30551. * Vignette stretch size.
  30552. */
  30553. vignetteStretch: number;
  30554. /**
  30555. * Vignette centre X Offset.
  30556. */
  30557. vignetteCentreX: number;
  30558. /**
  30559. * Vignette centre Y Offset.
  30560. */
  30561. vignetteCentreY: number;
  30562. /**
  30563. * Vignette weight or intensity of the vignette effect.
  30564. */
  30565. vignetteWeight: number;
  30566. /**
  30567. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30568. * if vignetteEnabled is set to true.
  30569. */
  30570. vignetteColor: Color4;
  30571. /**
  30572. * Camera field of view used by the Vignette effect.
  30573. */
  30574. vignetteCameraFov: number;
  30575. private _vignetteBlendMode;
  30576. /**
  30577. * Gets the vignette blend mode allowing different kind of effect.
  30578. */
  30579. /**
  30580. * Sets the vignette blend mode allowing different kind of effect.
  30581. */
  30582. vignetteBlendMode: number;
  30583. private _vignetteEnabled;
  30584. /**
  30585. * Gets wether the vignette effect is enabled.
  30586. */
  30587. /**
  30588. * Sets wether the vignette effect is enabled.
  30589. */
  30590. vignetteEnabled: boolean;
  30591. private _applyByPostProcess;
  30592. /**
  30593. * Gets wether the image processing is applied through a post process or not.
  30594. */
  30595. /**
  30596. * Sets wether the image processing is applied through a post process or not.
  30597. */
  30598. applyByPostProcess: boolean;
  30599. private _isEnabled;
  30600. /**
  30601. * Gets wether the image processing is enabled or not.
  30602. */
  30603. /**
  30604. * Sets wether the image processing is enabled or not.
  30605. */
  30606. isEnabled: boolean;
  30607. /**
  30608. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30609. */
  30610. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30611. /**
  30612. * Method called each time the image processing information changes requires to recompile the effect.
  30613. */
  30614. protected _updateParameters(): void;
  30615. /**
  30616. * Gets the current class name.
  30617. * @return "ImageProcessingConfiguration"
  30618. */
  30619. getClassName(): string;
  30620. /**
  30621. * Prepare the list of uniforms associated with the Image Processing effects.
  30622. * @param uniforms The list of uniforms used in the effect
  30623. * @param defines the list of defines currently in use
  30624. */
  30625. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30626. /**
  30627. * Prepare the list of samplers associated with the Image Processing effects.
  30628. * @param samplersList The list of uniforms used in the effect
  30629. * @param defines the list of defines currently in use
  30630. */
  30631. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30632. /**
  30633. * Prepare the list of defines associated to the shader.
  30634. * @param defines the list of defines to complete
  30635. * @param forPostProcess Define if we are currently in post process mode or not
  30636. */
  30637. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30638. /**
  30639. * Returns true if all the image processing information are ready.
  30640. * @returns True if ready, otherwise, false
  30641. */
  30642. isReady(): boolean;
  30643. /**
  30644. * Binds the image processing to the shader.
  30645. * @param effect The effect to bind to
  30646. * @param aspectRatio Define the current aspect ratio of the effect
  30647. */
  30648. bind(effect: Effect, aspectRatio?: number): void;
  30649. /**
  30650. * Clones the current image processing instance.
  30651. * @return The cloned image processing
  30652. */
  30653. clone(): ImageProcessingConfiguration;
  30654. /**
  30655. * Serializes the current image processing instance to a json representation.
  30656. * @return a JSON representation
  30657. */
  30658. serialize(): any;
  30659. /**
  30660. * Parses the image processing from a json representation.
  30661. * @param source the JSON source to parse
  30662. * @return The parsed image processing
  30663. */
  30664. static Parse(source: any): ImageProcessingConfiguration;
  30665. private static _VIGNETTEMODE_MULTIPLY;
  30666. private static _VIGNETTEMODE_OPAQUE;
  30667. /**
  30668. * Used to apply the vignette as a mix with the pixel color.
  30669. */
  30670. static readonly VIGNETTEMODE_MULTIPLY: number;
  30671. /**
  30672. * Used to apply the vignette as a replacement of the pixel color.
  30673. */
  30674. static readonly VIGNETTEMODE_OPAQUE: number;
  30675. }
  30676. }
  30677. declare module "babylonjs/Materials/fresnelParameters" {
  30678. import { Color3 } from "babylonjs/Maths/math";
  30679. /**
  30680. * This represents all the required information to add a fresnel effect on a material:
  30681. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30682. */
  30683. export class FresnelParameters {
  30684. private _isEnabled;
  30685. /**
  30686. * Define if the fresnel effect is enable or not.
  30687. */
  30688. isEnabled: boolean;
  30689. /**
  30690. * Define the color used on edges (grazing angle)
  30691. */
  30692. leftColor: Color3;
  30693. /**
  30694. * Define the color used on center
  30695. */
  30696. rightColor: Color3;
  30697. /**
  30698. * Define bias applied to computed fresnel term
  30699. */
  30700. bias: number;
  30701. /**
  30702. * Defined the power exponent applied to fresnel term
  30703. */
  30704. power: number;
  30705. /**
  30706. * Clones the current fresnel and its valuues
  30707. * @returns a clone fresnel configuration
  30708. */
  30709. clone(): FresnelParameters;
  30710. /**
  30711. * Serializes the current fresnel parameters to a JSON representation.
  30712. * @return the JSON serialization
  30713. */
  30714. serialize(): any;
  30715. /**
  30716. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30717. * @param parsedFresnelParameters Define the JSON representation
  30718. * @returns the parsed parameters
  30719. */
  30720. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30721. }
  30722. }
  30723. declare module "babylonjs/Misc/decorators" {
  30724. import { Nullable } from "babylonjs/types";
  30725. import { Scene } from "babylonjs/scene";
  30726. import { IAnimatable } from "babylonjs/Misc/tools";
  30727. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30728. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30729. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30730. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30731. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30732. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30733. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30734. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30735. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30736. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30737. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30738. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30739. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30740. /**
  30741. * Decorator used to define property that can be serialized as reference to a camera
  30742. * @param sourceName defines the name of the property to decorate
  30743. */
  30744. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30745. /**
  30746. * Class used to help serialization objects
  30747. */
  30748. export class SerializationHelper {
  30749. /** hidden */
  30750. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30751. /** hidden */
  30752. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30753. /** hidden */
  30754. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30755. /** hidden */
  30756. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30757. /**
  30758. * Appends the serialized animations from the source animations
  30759. * @param source Source containing the animations
  30760. * @param destination Target to store the animations
  30761. */
  30762. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30763. /**
  30764. * Static function used to serialized a specific entity
  30765. * @param entity defines the entity to serialize
  30766. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30767. * @returns a JSON compatible object representing the serialization of the entity
  30768. */
  30769. static Serialize<T>(entity: T, serializationObject?: any): any;
  30770. /**
  30771. * Creates a new entity from a serialization data object
  30772. * @param creationFunction defines a function used to instanciated the new entity
  30773. * @param source defines the source serialization data
  30774. * @param scene defines the hosting scene
  30775. * @param rootUrl defines the root url for resources
  30776. * @returns a new entity
  30777. */
  30778. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30779. /**
  30780. * Clones an object
  30781. * @param creationFunction defines the function used to instanciate the new object
  30782. * @param source defines the source object
  30783. * @returns the cloned object
  30784. */
  30785. static Clone<T>(creationFunction: () => T, source: T): T;
  30786. /**
  30787. * Instanciates a new object based on a source one (some data will be shared between both object)
  30788. * @param creationFunction defines the function used to instanciate the new object
  30789. * @param source defines the source object
  30790. * @returns the new object
  30791. */
  30792. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30793. }
  30794. }
  30795. declare module "babylonjs/Cameras/camera" {
  30796. import { SmartArray } from "babylonjs/Misc/smartArray";
  30797. import { Observable } from "babylonjs/Misc/observable";
  30798. import { Nullable } from "babylonjs/types";
  30799. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30800. import { Scene } from "babylonjs/scene";
  30801. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30802. import { Node } from "babylonjs/node";
  30803. import { Mesh } from "babylonjs/Meshes/mesh";
  30804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30805. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30806. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30807. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30808. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30809. import { Ray } from "babylonjs/Culling/ray";
  30810. /**
  30811. * This is the base class of all the camera used in the application.
  30812. * @see http://doc.babylonjs.com/features/cameras
  30813. */
  30814. export class Camera extends Node {
  30815. /** @hidden */
  30816. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30817. /**
  30818. * This is the default projection mode used by the cameras.
  30819. * It helps recreating a feeling of perspective and better appreciate depth.
  30820. * This is the best way to simulate real life cameras.
  30821. */
  30822. static readonly PERSPECTIVE_CAMERA: number;
  30823. /**
  30824. * This helps creating camera with an orthographic mode.
  30825. * 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.
  30826. */
  30827. static readonly ORTHOGRAPHIC_CAMERA: number;
  30828. /**
  30829. * This is the default FOV mode for perspective cameras.
  30830. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30831. */
  30832. static readonly FOVMODE_VERTICAL_FIXED: number;
  30833. /**
  30834. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30835. */
  30836. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30837. /**
  30838. * This specifies ther is no need for a camera rig.
  30839. * Basically only one eye is rendered corresponding to the camera.
  30840. */
  30841. static readonly RIG_MODE_NONE: number;
  30842. /**
  30843. * Simulates a camera Rig with one blue eye and one red eye.
  30844. * This can be use with 3d blue and red glasses.
  30845. */
  30846. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30847. /**
  30848. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30849. */
  30850. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30851. /**
  30852. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30853. */
  30854. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30855. /**
  30856. * Defines that both eyes of the camera will be rendered over under each other.
  30857. */
  30858. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30859. /**
  30860. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30861. */
  30862. static readonly RIG_MODE_VR: number;
  30863. /**
  30864. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30865. */
  30866. static readonly RIG_MODE_WEBVR: number;
  30867. /**
  30868. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30869. */
  30870. static readonly RIG_MODE_CUSTOM: number;
  30871. /**
  30872. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30873. */
  30874. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30875. /**
  30876. * Define the input manager associated with the camera.
  30877. */
  30878. inputs: CameraInputsManager<Camera>;
  30879. /** @hidden */
  30880. _position: Vector3;
  30881. /**
  30882. * Define the current local position of the camera in the scene
  30883. */
  30884. position: Vector3;
  30885. /**
  30886. * The vector the camera should consider as up.
  30887. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30888. */
  30889. upVector: Vector3;
  30890. /**
  30891. * Define the current limit on the left side for an orthographic camera
  30892. * In scene unit
  30893. */
  30894. orthoLeft: Nullable<number>;
  30895. /**
  30896. * Define the current limit on the right side for an orthographic camera
  30897. * In scene unit
  30898. */
  30899. orthoRight: Nullable<number>;
  30900. /**
  30901. * Define the current limit on the bottom side for an orthographic camera
  30902. * In scene unit
  30903. */
  30904. orthoBottom: Nullable<number>;
  30905. /**
  30906. * Define the current limit on the top side for an orthographic camera
  30907. * In scene unit
  30908. */
  30909. orthoTop: Nullable<number>;
  30910. /**
  30911. * Field Of View is set in Radians. (default is 0.8)
  30912. */
  30913. fov: number;
  30914. /**
  30915. * Define the minimum distance the camera can see from.
  30916. * This is important to note that the depth buffer are not infinite and the closer it starts
  30917. * the more your scene might encounter depth fighting issue.
  30918. */
  30919. minZ: number;
  30920. /**
  30921. * Define the maximum distance the camera can see to.
  30922. * This is important to note that the depth buffer are not infinite and the further it end
  30923. * the more your scene might encounter depth fighting issue.
  30924. */
  30925. maxZ: number;
  30926. /**
  30927. * Define the default inertia of the camera.
  30928. * This helps giving a smooth feeling to the camera movement.
  30929. */
  30930. inertia: number;
  30931. /**
  30932. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30933. */
  30934. mode: number;
  30935. /**
  30936. * Define wether the camera is intermediate.
  30937. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30938. */
  30939. isIntermediate: boolean;
  30940. /**
  30941. * Define the viewport of the camera.
  30942. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30943. */
  30944. viewport: Viewport;
  30945. /**
  30946. * Restricts the camera to viewing objects with the same layerMask.
  30947. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30948. */
  30949. layerMask: number;
  30950. /**
  30951. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30952. */
  30953. fovMode: number;
  30954. /**
  30955. * Rig mode of the camera.
  30956. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30957. * This is normally controlled byt the camera themselves as internal use.
  30958. */
  30959. cameraRigMode: number;
  30960. /**
  30961. * Defines the distance between both "eyes" in case of a RIG
  30962. */
  30963. interaxialDistance: number;
  30964. /**
  30965. * Defines if stereoscopic rendering is done side by side or over under.
  30966. */
  30967. isStereoscopicSideBySide: boolean;
  30968. /**
  30969. * 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
  30970. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30971. * else in the scene.
  30972. */
  30973. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30974. /**
  30975. * When set, the camera will render to this render target instead of the default canvas
  30976. */
  30977. outputRenderTarget: Nullable<RenderTargetTexture>;
  30978. /**
  30979. * Observable triggered when the camera view matrix has changed.
  30980. */
  30981. onViewMatrixChangedObservable: Observable<Camera>;
  30982. /**
  30983. * Observable triggered when the camera Projection matrix has changed.
  30984. */
  30985. onProjectionMatrixChangedObservable: Observable<Camera>;
  30986. /**
  30987. * Observable triggered when the inputs have been processed.
  30988. */
  30989. onAfterCheckInputsObservable: Observable<Camera>;
  30990. /**
  30991. * Observable triggered when reset has been called and applied to the camera.
  30992. */
  30993. onRestoreStateObservable: Observable<Camera>;
  30994. /** @hidden */
  30995. _cameraRigParams: any;
  30996. /** @hidden */
  30997. _rigCameras: Camera[];
  30998. /** @hidden */
  30999. _rigPostProcess: Nullable<PostProcess>;
  31000. protected _webvrViewMatrix: Matrix;
  31001. /** @hidden */
  31002. _skipRendering: boolean;
  31003. /** @hidden */
  31004. _projectionMatrix: Matrix;
  31005. /** @hidden */
  31006. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31007. /** @hidden */
  31008. _activeMeshes: SmartArray<AbstractMesh>;
  31009. protected _globalPosition: Vector3;
  31010. /** hidden */
  31011. _computedViewMatrix: Matrix;
  31012. private _doNotComputeProjectionMatrix;
  31013. private _transformMatrix;
  31014. private _frustumPlanes;
  31015. private _refreshFrustumPlanes;
  31016. private _storedFov;
  31017. private _stateStored;
  31018. /**
  31019. * Instantiates a new camera object.
  31020. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31021. * @see http://doc.babylonjs.com/features/cameras
  31022. * @param name Defines the name of the camera in the scene
  31023. * @param position Defines the position of the camera
  31024. * @param scene Defines the scene the camera belongs too
  31025. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31026. */
  31027. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31028. /**
  31029. * Store current camera state (fov, position, etc..)
  31030. * @returns the camera
  31031. */
  31032. storeState(): Camera;
  31033. /**
  31034. * Restores the camera state values if it has been stored. You must call storeState() first
  31035. */
  31036. protected _restoreStateValues(): boolean;
  31037. /**
  31038. * Restored camera state. You must call storeState() first.
  31039. * @returns true if restored and false otherwise
  31040. */
  31041. restoreState(): boolean;
  31042. /**
  31043. * Gets the class name of the camera.
  31044. * @returns the class name
  31045. */
  31046. getClassName(): string;
  31047. /** @hidden */
  31048. readonly _isCamera: boolean;
  31049. /**
  31050. * Gets a string representation of the camera useful for debug purpose.
  31051. * @param fullDetails Defines that a more verboe level of logging is required
  31052. * @returns the string representation
  31053. */
  31054. toString(fullDetails?: boolean): string;
  31055. /**
  31056. * Gets the current world space position of the camera.
  31057. */
  31058. readonly globalPosition: Vector3;
  31059. /**
  31060. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31061. * @returns the active meshe list
  31062. */
  31063. getActiveMeshes(): SmartArray<AbstractMesh>;
  31064. /**
  31065. * Check wether a mesh is part of the current active mesh list of the camera
  31066. * @param mesh Defines the mesh to check
  31067. * @returns true if active, false otherwise
  31068. */
  31069. isActiveMesh(mesh: Mesh): boolean;
  31070. /**
  31071. * Is this camera ready to be used/rendered
  31072. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31073. * @return true if the camera is ready
  31074. */
  31075. isReady(completeCheck?: boolean): boolean;
  31076. /** @hidden */
  31077. _initCache(): void;
  31078. /** @hidden */
  31079. _updateCache(ignoreParentClass?: boolean): void;
  31080. /** @hidden */
  31081. _isSynchronized(): boolean;
  31082. /** @hidden */
  31083. _isSynchronizedViewMatrix(): boolean;
  31084. /** @hidden */
  31085. _isSynchronizedProjectionMatrix(): boolean;
  31086. /**
  31087. * Attach the input controls to a specific dom element to get the input from.
  31088. * @param element Defines the element the controls should be listened from
  31089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31090. */
  31091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31092. /**
  31093. * Detach the current controls from the specified dom element.
  31094. * @param element Defines the element to stop listening the inputs from
  31095. */
  31096. detachControl(element: HTMLElement): void;
  31097. /**
  31098. * Update the camera state according to the different inputs gathered during the frame.
  31099. */
  31100. update(): void;
  31101. /** @hidden */
  31102. _checkInputs(): void;
  31103. /** @hidden */
  31104. readonly rigCameras: Camera[];
  31105. /**
  31106. * Gets the post process used by the rig cameras
  31107. */
  31108. readonly rigPostProcess: Nullable<PostProcess>;
  31109. /**
  31110. * Internal, gets the first post proces.
  31111. * @returns the first post process to be run on this camera.
  31112. */
  31113. _getFirstPostProcess(): Nullable<PostProcess>;
  31114. private _cascadePostProcessesToRigCams;
  31115. /**
  31116. * Attach a post process to the camera.
  31117. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31118. * @param postProcess The post process to attach to the camera
  31119. * @param insertAt The position of the post process in case several of them are in use in the scene
  31120. * @returns the position the post process has been inserted at
  31121. */
  31122. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31123. /**
  31124. * Detach a post process to the camera.
  31125. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31126. * @param postProcess The post process to detach from the camera
  31127. */
  31128. detachPostProcess(postProcess: PostProcess): void;
  31129. /**
  31130. * Gets the current world matrix of the camera
  31131. */
  31132. getWorldMatrix(): Matrix;
  31133. /** @hidden */
  31134. _getViewMatrix(): Matrix;
  31135. /**
  31136. * Gets the current view matrix of the camera.
  31137. * @param force forces the camera to recompute the matrix without looking at the cached state
  31138. * @returns the view matrix
  31139. */
  31140. getViewMatrix(force?: boolean): Matrix;
  31141. /**
  31142. * Freeze the projection matrix.
  31143. * It will prevent the cache check of the camera projection compute and can speed up perf
  31144. * if no parameter of the camera are meant to change
  31145. * @param projection Defines manually a projection if necessary
  31146. */
  31147. freezeProjectionMatrix(projection?: Matrix): void;
  31148. /**
  31149. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31150. */
  31151. unfreezeProjectionMatrix(): void;
  31152. /**
  31153. * Gets the current projection matrix of the camera.
  31154. * @param force forces the camera to recompute the matrix without looking at the cached state
  31155. * @returns the projection matrix
  31156. */
  31157. getProjectionMatrix(force?: boolean): Matrix;
  31158. /**
  31159. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31160. * @returns a Matrix
  31161. */
  31162. getTransformationMatrix(): Matrix;
  31163. private _updateFrustumPlanes;
  31164. /**
  31165. * Checks if a cullable object (mesh...) is in the camera frustum
  31166. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31167. * @param target The object to check
  31168. * @returns true if the object is in frustum otherwise false
  31169. */
  31170. isInFrustum(target: ICullable): boolean;
  31171. /**
  31172. * Checks if a cullable object (mesh...) is in the camera frustum
  31173. * Unlike isInFrustum this cheks the full bounding box
  31174. * @param target The object to check
  31175. * @returns true if the object is in frustum otherwise false
  31176. */
  31177. isCompletelyInFrustum(target: ICullable): boolean;
  31178. /**
  31179. * Gets a ray in the forward direction from the camera.
  31180. * @param length Defines the length of the ray to create
  31181. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31182. * @param origin Defines the start point of the ray which defaults to the camera position
  31183. * @returns the forward ray
  31184. */
  31185. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31186. /**
  31187. * Releases resources associated with this node.
  31188. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31189. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31190. */
  31191. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31192. /** @hidden */
  31193. _isLeftCamera: boolean;
  31194. /**
  31195. * Gets the left camera of a rig setup in case of Rigged Camera
  31196. */
  31197. readonly isLeftCamera: boolean;
  31198. /** @hidden */
  31199. _isRightCamera: boolean;
  31200. /**
  31201. * Gets the right camera of a rig setup in case of Rigged Camera
  31202. */
  31203. readonly isRightCamera: boolean;
  31204. /**
  31205. * Gets the left camera of a rig setup in case of Rigged Camera
  31206. */
  31207. readonly leftCamera: Nullable<FreeCamera>;
  31208. /**
  31209. * Gets the right camera of a rig setup in case of Rigged Camera
  31210. */
  31211. readonly rightCamera: Nullable<FreeCamera>;
  31212. /**
  31213. * Gets the left camera target of a rig setup in case of Rigged Camera
  31214. * @returns the target position
  31215. */
  31216. getLeftTarget(): Nullable<Vector3>;
  31217. /**
  31218. * Gets the right camera target of a rig setup in case of Rigged Camera
  31219. * @returns the target position
  31220. */
  31221. getRightTarget(): Nullable<Vector3>;
  31222. /**
  31223. * @hidden
  31224. */
  31225. setCameraRigMode(mode: number, rigParams: any): void;
  31226. /** @hidden */
  31227. static _setStereoscopicRigMode(camera: Camera): void;
  31228. /** @hidden */
  31229. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31230. /** @hidden */
  31231. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31232. /** @hidden */
  31233. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31234. /** @hidden */
  31235. _getVRProjectionMatrix(): Matrix;
  31236. protected _updateCameraRotationMatrix(): void;
  31237. protected _updateWebVRCameraRotationMatrix(): void;
  31238. /**
  31239. * This function MUST be overwritten by the different WebVR cameras available.
  31240. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31241. * @hidden
  31242. */
  31243. _getWebVRProjectionMatrix(): Matrix;
  31244. /**
  31245. * This function MUST be overwritten by the different WebVR cameras available.
  31246. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31247. * @hidden
  31248. */
  31249. _getWebVRViewMatrix(): Matrix;
  31250. /** @hidden */
  31251. setCameraRigParameter(name: string, value: any): void;
  31252. /**
  31253. * needs to be overridden by children so sub has required properties to be copied
  31254. * @hidden
  31255. */
  31256. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31257. /**
  31258. * May need to be overridden by children
  31259. * @hidden
  31260. */
  31261. _updateRigCameras(): void;
  31262. /** @hidden */
  31263. _setupInputs(): void;
  31264. /**
  31265. * Serialiaze the camera setup to a json represention
  31266. * @returns the JSON representation
  31267. */
  31268. serialize(): any;
  31269. /**
  31270. * Clones the current camera.
  31271. * @param name The cloned camera name
  31272. * @returns the cloned camera
  31273. */
  31274. clone(name: string): Camera;
  31275. /**
  31276. * Gets the direction of the camera relative to a given local axis.
  31277. * @param localAxis Defines the reference axis to provide a relative direction.
  31278. * @return the direction
  31279. */
  31280. getDirection(localAxis: Vector3): Vector3;
  31281. /**
  31282. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31283. * @param localAxis Defines the reference axis to provide a relative direction.
  31284. * @param result Defines the vector to store the result in
  31285. */
  31286. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31287. /**
  31288. * Gets a camera constructor for a given camera type
  31289. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31290. * @param name The name of the camera the result will be able to instantiate
  31291. * @param scene The scene the result will construct the camera in
  31292. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31293. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31294. * @returns a factory method to construc the camera
  31295. */
  31296. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31297. /**
  31298. * Compute the world matrix of the camera.
  31299. * @returns the camera workd matrix
  31300. */
  31301. computeWorldMatrix(): Matrix;
  31302. /**
  31303. * Parse a JSON and creates the camera from the parsed information
  31304. * @param parsedCamera The JSON to parse
  31305. * @param scene The scene to instantiate the camera in
  31306. * @returns the newly constructed camera
  31307. */
  31308. static Parse(parsedCamera: any, scene: Scene): Camera;
  31309. }
  31310. }
  31311. declare module "babylonjs/Misc/tools" {
  31312. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31313. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31314. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31315. import { Observable } from "babylonjs/Misc/observable";
  31316. import { DomManagement } from "babylonjs/Misc/domManagement";
  31317. import { WebRequest } from "babylonjs/Misc/webRequest";
  31318. import { Camera } from "babylonjs/Cameras/camera";
  31319. import { Engine } from "babylonjs/Engines/engine";
  31320. import { Animation } from "babylonjs/Animations/animation";
  31321. /**
  31322. * Interface for any object that can request an animation frame
  31323. */
  31324. export interface ICustomAnimationFrameRequester {
  31325. /**
  31326. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31327. */
  31328. renderFunction?: Function;
  31329. /**
  31330. * Called to request the next frame to render to
  31331. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31332. */
  31333. requestAnimationFrame: Function;
  31334. /**
  31335. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31336. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31337. */
  31338. requestID?: number;
  31339. }
  31340. /**
  31341. * Interface containing an array of animations
  31342. */
  31343. export interface IAnimatable {
  31344. /**
  31345. * Array of animations
  31346. */
  31347. animations: Nullable<Array<Animation>>;
  31348. }
  31349. /** Interface used by value gradients (color, factor, ...) */
  31350. export interface IValueGradient {
  31351. /**
  31352. * Gets or sets the gradient value (between 0 and 1)
  31353. */
  31354. gradient: number;
  31355. }
  31356. /** Class used to store color4 gradient */
  31357. export class ColorGradient implements IValueGradient {
  31358. /**
  31359. * Gets or sets the gradient value (between 0 and 1)
  31360. */
  31361. gradient: number;
  31362. /**
  31363. * Gets or sets first associated color
  31364. */
  31365. color1: Color4;
  31366. /**
  31367. * Gets or sets second associated color
  31368. */
  31369. color2?: Color4;
  31370. /**
  31371. * Will get a color picked randomly between color1 and color2.
  31372. * If color2 is undefined then color1 will be used
  31373. * @param result defines the target Color4 to store the result in
  31374. */
  31375. getColorToRef(result: Color4): void;
  31376. }
  31377. /** Class used to store color 3 gradient */
  31378. export class Color3Gradient implements IValueGradient {
  31379. /**
  31380. * Gets or sets the gradient value (between 0 and 1)
  31381. */
  31382. gradient: number;
  31383. /**
  31384. * Gets or sets the associated color
  31385. */
  31386. color: Color3;
  31387. }
  31388. /** Class used to store factor gradient */
  31389. export class FactorGradient implements IValueGradient {
  31390. /**
  31391. * Gets or sets the gradient value (between 0 and 1)
  31392. */
  31393. gradient: number;
  31394. /**
  31395. * Gets or sets first associated factor
  31396. */
  31397. factor1: number;
  31398. /**
  31399. * Gets or sets second associated factor
  31400. */
  31401. factor2?: number;
  31402. /**
  31403. * Will get a number picked randomly between factor1 and factor2.
  31404. * If factor2 is undefined then factor1 will be used
  31405. * @returns the picked number
  31406. */
  31407. getFactor(): number;
  31408. }
  31409. /**
  31410. * @ignore
  31411. * Application error to support additional information when loading a file
  31412. */
  31413. export class LoadFileError extends Error {
  31414. /** defines the optional web request */
  31415. request?: WebRequest | undefined;
  31416. private static _setPrototypeOf;
  31417. /**
  31418. * Creates a new LoadFileError
  31419. * @param message defines the message of the error
  31420. * @param request defines the optional web request
  31421. */
  31422. constructor(message: string,
  31423. /** defines the optional web request */
  31424. request?: WebRequest | undefined);
  31425. }
  31426. /**
  31427. * Class used to define a retry strategy when error happens while loading assets
  31428. */
  31429. export class RetryStrategy {
  31430. /**
  31431. * Function used to defines an exponential back off strategy
  31432. * @param maxRetries defines the maximum number of retries (3 by default)
  31433. * @param baseInterval defines the interval between retries
  31434. * @returns the strategy function to use
  31435. */
  31436. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31437. }
  31438. /**
  31439. * File request interface
  31440. */
  31441. export interface IFileRequest {
  31442. /**
  31443. * Raised when the request is complete (success or error).
  31444. */
  31445. onCompleteObservable: Observable<IFileRequest>;
  31446. /**
  31447. * Aborts the request for a file.
  31448. */
  31449. abort: () => void;
  31450. }
  31451. /**
  31452. * Class containing a set of static utilities functions
  31453. */
  31454. export class Tools {
  31455. /**
  31456. * Gets or sets the base URL to use to load assets
  31457. */
  31458. static BaseUrl: string;
  31459. /**
  31460. * Enable/Disable Custom HTTP Request Headers globally.
  31461. * default = false
  31462. * @see CustomRequestHeaders
  31463. */
  31464. static UseCustomRequestHeaders: boolean;
  31465. /**
  31466. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31467. * i.e. when loading files, where the server/service expects an Authorization header
  31468. */
  31469. static CustomRequestHeaders: {
  31470. [key: string]: string;
  31471. };
  31472. /**
  31473. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31474. */
  31475. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31476. /**
  31477. * Default behaviour for cors in the application.
  31478. * It can be a string if the expected behavior is identical in the entire app.
  31479. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31480. */
  31481. static CorsBehavior: string | ((url: string | string[]) => string);
  31482. /**
  31483. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31484. * @ignorenaming
  31485. */
  31486. static UseFallbackTexture: boolean;
  31487. /**
  31488. * Use this object to register external classes like custom textures or material
  31489. * to allow the laoders to instantiate them
  31490. */
  31491. static RegisteredExternalClasses: {
  31492. [key: string]: Object;
  31493. };
  31494. /**
  31495. * Texture content used if a texture cannot loaded
  31496. * @ignorenaming
  31497. */
  31498. static fallbackTexture: string;
  31499. /**
  31500. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31501. * @param u defines the coordinate on X axis
  31502. * @param v defines the coordinate on Y axis
  31503. * @param width defines the width of the source data
  31504. * @param height defines the height of the source data
  31505. * @param pixels defines the source byte array
  31506. * @param color defines the output color
  31507. */
  31508. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31509. /**
  31510. * Interpolates between a and b via alpha
  31511. * @param a The lower value (returned when alpha = 0)
  31512. * @param b The upper value (returned when alpha = 1)
  31513. * @param alpha The interpolation-factor
  31514. * @return The mixed value
  31515. */
  31516. static Mix(a: number, b: number, alpha: number): number;
  31517. /**
  31518. * Tries to instantiate a new object from a given class name
  31519. * @param className defines the class name to instantiate
  31520. * @returns the new object or null if the system was not able to do the instantiation
  31521. */
  31522. static Instantiate(className: string): any;
  31523. /**
  31524. * Provides a slice function that will work even on IE
  31525. * @param data defines the array to slice
  31526. * @param start defines the start of the data (optional)
  31527. * @param end defines the end of the data (optional)
  31528. * @returns the new sliced array
  31529. */
  31530. static Slice<T>(data: T, start?: number, end?: number): T;
  31531. /**
  31532. * Polyfill for setImmediate
  31533. * @param action defines the action to execute after the current execution block
  31534. */
  31535. static SetImmediate(action: () => void): void;
  31536. /**
  31537. * Function indicating if a number is an exponent of 2
  31538. * @param value defines the value to test
  31539. * @returns true if the value is an exponent of 2
  31540. */
  31541. static IsExponentOfTwo(value: number): boolean;
  31542. private static _tmpFloatArray;
  31543. /**
  31544. * Returns the nearest 32-bit single precision float representation of a Number
  31545. * @param value A Number. If the parameter is of a different type, it will get converted
  31546. * to a number or to NaN if it cannot be converted
  31547. * @returns number
  31548. */
  31549. static FloatRound(value: number): number;
  31550. /**
  31551. * Find the next highest power of two.
  31552. * @param x Number to start search from.
  31553. * @return Next highest power of two.
  31554. */
  31555. static CeilingPOT(x: number): number;
  31556. /**
  31557. * Find the next lowest power of two.
  31558. * @param x Number to start search from.
  31559. * @return Next lowest power of two.
  31560. */
  31561. static FloorPOT(x: number): number;
  31562. /**
  31563. * Find the nearest power of two.
  31564. * @param x Number to start search from.
  31565. * @return Next nearest power of two.
  31566. */
  31567. static NearestPOT(x: number): number;
  31568. /**
  31569. * Get the closest exponent of two
  31570. * @param value defines the value to approximate
  31571. * @param max defines the maximum value to return
  31572. * @param mode defines how to define the closest value
  31573. * @returns closest exponent of two of the given value
  31574. */
  31575. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31576. /**
  31577. * Extracts the filename from a path
  31578. * @param path defines the path to use
  31579. * @returns the filename
  31580. */
  31581. static GetFilename(path: string): string;
  31582. /**
  31583. * Extracts the "folder" part of a path (everything before the filename).
  31584. * @param uri The URI to extract the info from
  31585. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31586. * @returns The "folder" part of the path
  31587. */
  31588. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31589. /**
  31590. * Extracts text content from a DOM element hierarchy
  31591. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31592. */
  31593. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31594. /**
  31595. * Convert an angle in radians to degrees
  31596. * @param angle defines the angle to convert
  31597. * @returns the angle in degrees
  31598. */
  31599. static ToDegrees(angle: number): number;
  31600. /**
  31601. * Convert an angle in degrees to radians
  31602. * @param angle defines the angle to convert
  31603. * @returns the angle in radians
  31604. */
  31605. static ToRadians(angle: number): number;
  31606. /**
  31607. * Encode a buffer to a base64 string
  31608. * @param buffer defines the buffer to encode
  31609. * @returns the encoded string
  31610. */
  31611. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31612. /**
  31613. * Extracts minimum and maximum values from a list of indexed positions
  31614. * @param positions defines the positions to use
  31615. * @param indices defines the indices to the positions
  31616. * @param indexStart defines the start index
  31617. * @param indexCount defines the end index
  31618. * @param bias defines bias value to add to the result
  31619. * @return minimum and maximum values
  31620. */
  31621. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31622. minimum: Vector3;
  31623. maximum: Vector3;
  31624. };
  31625. /**
  31626. * Extracts minimum and maximum values from a list of positions
  31627. * @param positions defines the positions to use
  31628. * @param start defines the start index in the positions array
  31629. * @param count defines the number of positions to handle
  31630. * @param bias defines bias value to add to the result
  31631. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31632. * @return minimum and maximum values
  31633. */
  31634. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31635. minimum: Vector3;
  31636. maximum: Vector3;
  31637. };
  31638. /**
  31639. * Returns an array if obj is not an array
  31640. * @param obj defines the object to evaluate as an array
  31641. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31642. * @returns either obj directly if obj is an array or a new array containing obj
  31643. */
  31644. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31645. /**
  31646. * Gets the pointer prefix to use
  31647. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31648. */
  31649. static GetPointerPrefix(): string;
  31650. /**
  31651. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31652. * @param func - the function to be called
  31653. * @param requester - the object that will request the next frame. Falls back to window.
  31654. * @returns frame number
  31655. */
  31656. static QueueNewFrame(func: () => void, requester?: any): number;
  31657. /**
  31658. * Ask the browser to promote the current element to fullscreen rendering mode
  31659. * @param element defines the DOM element to promote
  31660. */
  31661. static RequestFullscreen(element: HTMLElement): void;
  31662. /**
  31663. * Asks the browser to exit fullscreen mode
  31664. */
  31665. static ExitFullscreen(): void;
  31666. /**
  31667. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31668. * @param url define the url we are trying
  31669. * @param element define the dom element where to configure the cors policy
  31670. */
  31671. static SetCorsBehavior(url: string | string[], element: {
  31672. crossOrigin: string | null;
  31673. }): void;
  31674. /**
  31675. * Removes unwanted characters from an url
  31676. * @param url defines the url to clean
  31677. * @returns the cleaned url
  31678. */
  31679. static CleanUrl(url: string): string;
  31680. /**
  31681. * Gets or sets a function used to pre-process url before using them to load assets
  31682. */
  31683. static PreprocessUrl: (url: string) => string;
  31684. /**
  31685. * Loads an image as an HTMLImageElement.
  31686. * @param input url string, ArrayBuffer, or Blob to load
  31687. * @param onLoad callback called when the image successfully loads
  31688. * @param onError callback called when the image fails to load
  31689. * @param offlineProvider offline provider for caching
  31690. * @returns the HTMLImageElement of the loaded image
  31691. */
  31692. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31693. /**
  31694. * Loads a file
  31695. * @param url url string, ArrayBuffer, or Blob to load
  31696. * @param onSuccess callback called when the file successfully loads
  31697. * @param onProgress callback called while file is loading (if the server supports this mode)
  31698. * @param offlineProvider defines the offline provider for caching
  31699. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31700. * @param onError callback called when the file fails to load
  31701. * @returns a file request object
  31702. */
  31703. 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;
  31704. /**
  31705. * Load a script (identified by an url). When the url returns, the
  31706. * content of this file is added into a new script element, attached to the DOM (body element)
  31707. * @param scriptUrl defines the url of the script to laod
  31708. * @param onSuccess defines the callback called when the script is loaded
  31709. * @param onError defines the callback to call if an error occurs
  31710. * @param scriptId defines the id of the script element
  31711. */
  31712. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31713. /**
  31714. * Load an asynchronous script (identified by an url). When the url returns, the
  31715. * content of this file is added into a new script element, attached to the DOM (body element)
  31716. * @param scriptUrl defines the url of the script to laod
  31717. * @param scriptId defines the id of the script element
  31718. * @returns a promise request object
  31719. */
  31720. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31721. /**
  31722. * Loads a file from a blob
  31723. * @param fileToLoad defines the blob to use
  31724. * @param callback defines the callback to call when data is loaded
  31725. * @param progressCallback defines the callback to call during loading process
  31726. * @returns a file request object
  31727. */
  31728. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31729. /**
  31730. * Loads a file
  31731. * @param fileToLoad defines the file to load
  31732. * @param callback defines the callback to call when data is loaded
  31733. * @param progressCallBack defines the callback to call during loading process
  31734. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31735. * @returns a file request object
  31736. */
  31737. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31738. /**
  31739. * Creates a data url from a given string content
  31740. * @param content defines the content to convert
  31741. * @returns the new data url link
  31742. */
  31743. static FileAsURL(content: string): string;
  31744. /**
  31745. * Format the given number to a specific decimal format
  31746. * @param value defines the number to format
  31747. * @param decimals defines the number of decimals to use
  31748. * @returns the formatted string
  31749. */
  31750. static Format(value: number, decimals?: number): string;
  31751. /**
  31752. * Checks if a given vector is inside a specific range
  31753. * @param v defines the vector to test
  31754. * @param min defines the minimum range
  31755. * @param max defines the maximum range
  31756. */
  31757. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31758. /**
  31759. * Tries to copy an object by duplicating every property
  31760. * @param source defines the source object
  31761. * @param destination defines the target object
  31762. * @param doNotCopyList defines a list of properties to avoid
  31763. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31764. */
  31765. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31766. /**
  31767. * Gets a boolean indicating if the given object has no own property
  31768. * @param obj defines the object to test
  31769. * @returns true if object has no own property
  31770. */
  31771. static IsEmpty(obj: any): boolean;
  31772. /**
  31773. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31774. * @param str Source string
  31775. * @param suffix Suffix to search for in the source string
  31776. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31777. */
  31778. static EndsWith(str: string, suffix: string): boolean;
  31779. /**
  31780. * Function used to register events at window level
  31781. * @param events defines the events to register
  31782. */
  31783. static RegisterTopRootEvents(events: {
  31784. name: string;
  31785. handler: Nullable<(e: FocusEvent) => any>;
  31786. }[]): void;
  31787. /**
  31788. * Function used to unregister events from window level
  31789. * @param events defines the events to unregister
  31790. */
  31791. static UnregisterTopRootEvents(events: {
  31792. name: string;
  31793. handler: Nullable<(e: FocusEvent) => any>;
  31794. }[]): void;
  31795. /**
  31796. * @ignore
  31797. */
  31798. static _ScreenshotCanvas: HTMLCanvasElement;
  31799. /**
  31800. * Dumps the current bound framebuffer
  31801. * @param width defines the rendering width
  31802. * @param height defines the rendering height
  31803. * @param engine defines the hosting engine
  31804. * @param successCallback defines the callback triggered once the data are available
  31805. * @param mimeType defines the mime type of the result
  31806. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31807. */
  31808. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31809. /**
  31810. * Converts the canvas data to blob.
  31811. * This acts as a polyfill for browsers not supporting the to blob function.
  31812. * @param canvas Defines the canvas to extract the data from
  31813. * @param successCallback Defines the callback triggered once the data are available
  31814. * @param mimeType Defines the mime type of the result
  31815. */
  31816. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31817. /**
  31818. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31819. * @param successCallback defines the callback triggered once the data are available
  31820. * @param mimeType defines the mime type of the result
  31821. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31822. */
  31823. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31824. /**
  31825. * Downloads a blob in the browser
  31826. * @param blob defines the blob to download
  31827. * @param fileName defines the name of the downloaded file
  31828. */
  31829. static Download(blob: Blob, fileName: string): void;
  31830. /**
  31831. * Captures a screenshot of the current rendering
  31832. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31833. * @param engine defines the rendering engine
  31834. * @param camera defines the source camera
  31835. * @param size This parameter can be set to a single number or to an object with the
  31836. * following (optional) properties: precision, width, height. If a single number is passed,
  31837. * it will be used for both width and height. If an object is passed, the screenshot size
  31838. * will be derived from the parameters. The precision property is a multiplier allowing
  31839. * rendering at a higher or lower resolution
  31840. * @param successCallback defines the callback receives a single parameter which contains the
  31841. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31842. * src parameter of an <img> to display it
  31843. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31844. * Check your browser for supported MIME types
  31845. */
  31846. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31847. /**
  31848. * Generates an image screenshot from the specified camera.
  31849. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31850. * @param engine The engine to use for rendering
  31851. * @param camera The camera to use for rendering
  31852. * @param size This parameter can be set to a single number or to an object with the
  31853. * following (optional) properties: precision, width, height. If a single number is passed,
  31854. * it will be used for both width and height. If an object is passed, the screenshot size
  31855. * will be derived from the parameters. The precision property is a multiplier allowing
  31856. * rendering at a higher or lower resolution
  31857. * @param successCallback The callback receives a single parameter which contains the
  31858. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31859. * src parameter of an <img> to display it
  31860. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31861. * Check your browser for supported MIME types
  31862. * @param samples Texture samples (default: 1)
  31863. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31864. * @param fileName A name for for the downloaded file.
  31865. */
  31866. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31867. /**
  31868. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31869. * Be aware Math.random() could cause collisions, but:
  31870. * "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"
  31871. * @returns a pseudo random id
  31872. */
  31873. static RandomId(): string;
  31874. /**
  31875. * Test if the given uri is a base64 string
  31876. * @param uri The uri to test
  31877. * @return True if the uri is a base64 string or false otherwise
  31878. */
  31879. static IsBase64(uri: string): boolean;
  31880. /**
  31881. * Decode the given base64 uri.
  31882. * @param uri The uri to decode
  31883. * @return The decoded base64 data.
  31884. */
  31885. static DecodeBase64(uri: string): ArrayBuffer;
  31886. /**
  31887. * Gets the absolute url.
  31888. * @param url the input url
  31889. * @return the absolute url
  31890. */
  31891. static GetAbsoluteUrl(url: string): string;
  31892. /**
  31893. * No log
  31894. */
  31895. static readonly NoneLogLevel: number;
  31896. /**
  31897. * Only message logs
  31898. */
  31899. static readonly MessageLogLevel: number;
  31900. /**
  31901. * Only warning logs
  31902. */
  31903. static readonly WarningLogLevel: number;
  31904. /**
  31905. * Only error logs
  31906. */
  31907. static readonly ErrorLogLevel: number;
  31908. /**
  31909. * All logs
  31910. */
  31911. static readonly AllLogLevel: number;
  31912. /**
  31913. * Gets a value indicating the number of loading errors
  31914. * @ignorenaming
  31915. */
  31916. static readonly errorsCount: number;
  31917. /**
  31918. * Callback called when a new log is added
  31919. */
  31920. static OnNewCacheEntry: (entry: string) => void;
  31921. /**
  31922. * Log a message to the console
  31923. * @param message defines the message to log
  31924. */
  31925. static Log(message: string): void;
  31926. /**
  31927. * Write a warning message to the console
  31928. * @param message defines the message to log
  31929. */
  31930. static Warn(message: string): void;
  31931. /**
  31932. * Write an error message to the console
  31933. * @param message defines the message to log
  31934. */
  31935. static Error(message: string): void;
  31936. /**
  31937. * Gets current log cache (list of logs)
  31938. */
  31939. static readonly LogCache: string;
  31940. /**
  31941. * Clears the log cache
  31942. */
  31943. static ClearLogCache(): void;
  31944. /**
  31945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31946. */
  31947. static LogLevels: number;
  31948. /**
  31949. * Checks if the loaded document was accessed via `file:`-Protocol.
  31950. * @returns boolean
  31951. */
  31952. static IsFileURL(): boolean;
  31953. /**
  31954. * Checks if the window object exists
  31955. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31956. */
  31957. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31958. /**
  31959. * No performance log
  31960. */
  31961. static readonly PerformanceNoneLogLevel: number;
  31962. /**
  31963. * Use user marks to log performance
  31964. */
  31965. static readonly PerformanceUserMarkLogLevel: number;
  31966. /**
  31967. * Log performance to the console
  31968. */
  31969. static readonly PerformanceConsoleLogLevel: number;
  31970. private static _performance;
  31971. /**
  31972. * Sets the current performance log level
  31973. */
  31974. static PerformanceLogLevel: number;
  31975. private static _StartPerformanceCounterDisabled;
  31976. private static _EndPerformanceCounterDisabled;
  31977. private static _StartUserMark;
  31978. private static _EndUserMark;
  31979. private static _StartPerformanceConsole;
  31980. private static _EndPerformanceConsole;
  31981. /**
  31982. * Starts a performance counter
  31983. */
  31984. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31985. /**
  31986. * Ends a specific performance coutner
  31987. */
  31988. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31989. /**
  31990. * Gets either window.performance.now() if supported or Date.now() else
  31991. */
  31992. static readonly Now: number;
  31993. /**
  31994. * This method will return the name of the class used to create the instance of the given object.
  31995. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31996. * @param object the object to get the class name from
  31997. * @param isType defines if the object is actually a type
  31998. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31999. */
  32000. static GetClassName(object: any, isType?: boolean): string;
  32001. /**
  32002. * Gets the first element of an array satisfying a given predicate
  32003. * @param array defines the array to browse
  32004. * @param predicate defines the predicate to use
  32005. * @returns null if not found or the element
  32006. */
  32007. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32008. /**
  32009. * This method will return the name of the full name of the class, including its owning module (if any).
  32010. * 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).
  32011. * @param object the object to get the class name from
  32012. * @param isType defines if the object is actually a type
  32013. * @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.
  32014. * @ignorenaming
  32015. */
  32016. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32017. /**
  32018. * Returns a promise that resolves after the given amount of time.
  32019. * @param delay Number of milliseconds to delay
  32020. * @returns Promise that resolves after the given amount of time
  32021. */
  32022. static DelayAsync(delay: number): Promise<void>;
  32023. /**
  32024. * Gets the current gradient from an array of IValueGradient
  32025. * @param ratio defines the current ratio to get
  32026. * @param gradients defines the array of IValueGradient
  32027. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32028. */
  32029. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32030. }
  32031. /**
  32032. * This class is used to track a performance counter which is number based.
  32033. * The user has access to many properties which give statistics of different nature.
  32034. *
  32035. * The implementer can track two kinds of Performance Counter: time and count.
  32036. * 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.
  32037. * 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.
  32038. */
  32039. export class PerfCounter {
  32040. /**
  32041. * Gets or sets a global boolean to turn on and off all the counters
  32042. */
  32043. static Enabled: boolean;
  32044. /**
  32045. * Returns the smallest value ever
  32046. */
  32047. readonly min: number;
  32048. /**
  32049. * Returns the biggest value ever
  32050. */
  32051. readonly max: number;
  32052. /**
  32053. * Returns the average value since the performance counter is running
  32054. */
  32055. readonly average: number;
  32056. /**
  32057. * Returns the average value of the last second the counter was monitored
  32058. */
  32059. readonly lastSecAverage: number;
  32060. /**
  32061. * Returns the current value
  32062. */
  32063. readonly current: number;
  32064. /**
  32065. * Gets the accumulated total
  32066. */
  32067. readonly total: number;
  32068. /**
  32069. * Gets the total value count
  32070. */
  32071. readonly count: number;
  32072. /**
  32073. * Creates a new counter
  32074. */
  32075. constructor();
  32076. /**
  32077. * Call this method to start monitoring a new frame.
  32078. * 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.
  32079. */
  32080. fetchNewFrame(): void;
  32081. /**
  32082. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32083. * @param newCount the count value to add to the monitored count
  32084. * @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.
  32085. */
  32086. addCount(newCount: number, fetchResult: boolean): void;
  32087. /**
  32088. * Start monitoring this performance counter
  32089. */
  32090. beginMonitoring(): void;
  32091. /**
  32092. * Compute the time lapsed since the previous beginMonitoring() call.
  32093. * @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
  32094. */
  32095. endMonitoring(newFrame?: boolean): void;
  32096. private _fetchResult;
  32097. private _startMonitoringTime;
  32098. private _min;
  32099. private _max;
  32100. private _average;
  32101. private _current;
  32102. private _totalValueCount;
  32103. private _totalAccumulated;
  32104. private _lastSecAverage;
  32105. private _lastSecAccumulated;
  32106. private _lastSecTime;
  32107. private _lastSecValueCount;
  32108. }
  32109. /**
  32110. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32111. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32112. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32113. * @param name The name of the class, case should be preserved
  32114. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32115. */
  32116. export function className(name: string, module?: string): (target: Object) => void;
  32117. /**
  32118. * An implementation of a loop for asynchronous functions.
  32119. */
  32120. export class AsyncLoop {
  32121. /**
  32122. * Defines the number of iterations for the loop
  32123. */
  32124. iterations: number;
  32125. /**
  32126. * Defines the current index of the loop.
  32127. */
  32128. index: number;
  32129. private _done;
  32130. private _fn;
  32131. private _successCallback;
  32132. /**
  32133. * Constructor.
  32134. * @param iterations the number of iterations.
  32135. * @param func the function to run each iteration
  32136. * @param successCallback the callback that will be called upon succesful execution
  32137. * @param offset starting offset.
  32138. */
  32139. constructor(
  32140. /**
  32141. * Defines the number of iterations for the loop
  32142. */
  32143. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32144. /**
  32145. * Execute the next iteration. Must be called after the last iteration was finished.
  32146. */
  32147. executeNext(): void;
  32148. /**
  32149. * Break the loop and run the success callback.
  32150. */
  32151. breakLoop(): void;
  32152. /**
  32153. * Create and run an async loop.
  32154. * @param iterations the number of iterations.
  32155. * @param fn the function to run each iteration
  32156. * @param successCallback the callback that will be called upon succesful execution
  32157. * @param offset starting offset.
  32158. * @returns the created async loop object
  32159. */
  32160. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32161. /**
  32162. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32163. * @param iterations total number of iterations
  32164. * @param syncedIterations number of synchronous iterations in each async iteration.
  32165. * @param fn the function to call each iteration.
  32166. * @param callback a success call back that will be called when iterating stops.
  32167. * @param breakFunction a break condition (optional)
  32168. * @param timeout timeout settings for the setTimeout function. default - 0.
  32169. * @returns the created async loop object
  32170. */
  32171. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32172. }
  32173. }
  32174. declare module "babylonjs/Collisions/collisionCoordinator" {
  32175. import { Nullable } from "babylonjs/types";
  32176. import { Scene } from "babylonjs/scene";
  32177. import { Vector3 } from "babylonjs/Maths/math";
  32178. import { Collider } from "babylonjs/Collisions/collider";
  32179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32180. /** @hidden */
  32181. export interface ICollisionCoordinator {
  32182. createCollider(): Collider;
  32183. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32184. init(scene: Scene): void;
  32185. }
  32186. /** @hidden */
  32187. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32188. private _scene;
  32189. private _scaledPosition;
  32190. private _scaledVelocity;
  32191. private _finalPosition;
  32192. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32193. createCollider(): Collider;
  32194. init(scene: Scene): void;
  32195. private _collideWithWorld;
  32196. }
  32197. }
  32198. declare module "babylonjs/Animations/animationGroup" {
  32199. import { Animatable } from "babylonjs/Animations/animatable";
  32200. import { Animation } from "babylonjs/Animations/animation";
  32201. import { Scene, IDisposable } from "babylonjs/scene";
  32202. import { Observable } from "babylonjs/Misc/observable";
  32203. import { Nullable } from "babylonjs/types";
  32204. /**
  32205. * This class defines the direct association between an animation and a target
  32206. */
  32207. export class TargetedAnimation {
  32208. /**
  32209. * Animation to perform
  32210. */
  32211. animation: Animation;
  32212. /**
  32213. * Target to animate
  32214. */
  32215. target: any;
  32216. }
  32217. /**
  32218. * Use this class to create coordinated animations on multiple targets
  32219. */
  32220. export class AnimationGroup implements IDisposable {
  32221. /** The name of the animation group */
  32222. name: string;
  32223. private _scene;
  32224. private _targetedAnimations;
  32225. private _animatables;
  32226. private _from;
  32227. private _to;
  32228. private _isStarted;
  32229. private _isPaused;
  32230. private _speedRatio;
  32231. /**
  32232. * Gets or sets the unique id of the node
  32233. */
  32234. uniqueId: number;
  32235. /**
  32236. * This observable will notify when one animation have ended
  32237. */
  32238. onAnimationEndObservable: Observable<TargetedAnimation>;
  32239. /**
  32240. * Observer raised when one animation loops
  32241. */
  32242. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32243. /**
  32244. * This observable will notify when all animations have ended.
  32245. */
  32246. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32247. /**
  32248. * This observable will notify when all animations have paused.
  32249. */
  32250. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32251. /**
  32252. * This observable will notify when all animations are playing.
  32253. */
  32254. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32255. /**
  32256. * Gets the first frame
  32257. */
  32258. readonly from: number;
  32259. /**
  32260. * Gets the last frame
  32261. */
  32262. readonly to: number;
  32263. /**
  32264. * Define if the animations are started
  32265. */
  32266. readonly isStarted: boolean;
  32267. /**
  32268. * Gets a value indicating that the current group is playing
  32269. */
  32270. readonly isPlaying: boolean;
  32271. /**
  32272. * Gets or sets the speed ratio to use for all animations
  32273. */
  32274. /**
  32275. * Gets or sets the speed ratio to use for all animations
  32276. */
  32277. speedRatio: number;
  32278. /**
  32279. * Gets the targeted animations for this animation group
  32280. */
  32281. readonly targetedAnimations: Array<TargetedAnimation>;
  32282. /**
  32283. * returning the list of animatables controlled by this animation group.
  32284. */
  32285. readonly animatables: Array<Animatable>;
  32286. /**
  32287. * Instantiates a new Animation Group.
  32288. * This helps managing several animations at once.
  32289. * @see http://doc.babylonjs.com/how_to/group
  32290. * @param name Defines the name of the group
  32291. * @param scene Defines the scene the group belongs to
  32292. */
  32293. constructor(
  32294. /** The name of the animation group */
  32295. name: string, scene?: Nullable<Scene>);
  32296. /**
  32297. * Add an animation (with its target) in the group
  32298. * @param animation defines the animation we want to add
  32299. * @param target defines the target of the animation
  32300. * @returns the TargetedAnimation object
  32301. */
  32302. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32303. /**
  32304. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32305. * It can add constant keys at begin or end
  32306. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32307. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32308. * @returns the animation group
  32309. */
  32310. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32311. /**
  32312. * Start all animations on given targets
  32313. * @param loop defines if animations must loop
  32314. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32315. * @param from defines the from key (optional)
  32316. * @param to defines the to key (optional)
  32317. * @returns the current animation group
  32318. */
  32319. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32320. /**
  32321. * Pause all animations
  32322. * @returns the animation group
  32323. */
  32324. pause(): AnimationGroup;
  32325. /**
  32326. * Play all animations to initial state
  32327. * This function will start() the animations if they were not started or will restart() them if they were paused
  32328. * @param loop defines if animations must loop
  32329. * @returns the animation group
  32330. */
  32331. play(loop?: boolean): AnimationGroup;
  32332. /**
  32333. * Reset all animations to initial state
  32334. * @returns the animation group
  32335. */
  32336. reset(): AnimationGroup;
  32337. /**
  32338. * Restart animations from key 0
  32339. * @returns the animation group
  32340. */
  32341. restart(): AnimationGroup;
  32342. /**
  32343. * Stop all animations
  32344. * @returns the animation group
  32345. */
  32346. stop(): AnimationGroup;
  32347. /**
  32348. * Set animation weight for all animatables
  32349. * @param weight defines the weight to use
  32350. * @return the animationGroup
  32351. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32352. */
  32353. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32354. /**
  32355. * Synchronize and normalize all animatables with a source animatable
  32356. * @param root defines the root animatable to synchronize with
  32357. * @return the animationGroup
  32358. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32359. */
  32360. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32361. /**
  32362. * Goes to a specific frame in this animation group
  32363. * @param frame the frame number to go to
  32364. * @return the animationGroup
  32365. */
  32366. goToFrame(frame: number): AnimationGroup;
  32367. /**
  32368. * Dispose all associated resources
  32369. */
  32370. dispose(): void;
  32371. private _checkAnimationGroupEnded;
  32372. /**
  32373. * Clone the current animation group and returns a copy
  32374. * @param newName defines the name of the new group
  32375. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32376. * @returns the new aniamtion group
  32377. */
  32378. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32379. /**
  32380. * Returns a new AnimationGroup object parsed from the source provided.
  32381. * @param parsedAnimationGroup defines the source
  32382. * @param scene defines the scene that will receive the animationGroup
  32383. * @returns a new AnimationGroup
  32384. */
  32385. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32386. /**
  32387. * Returns the string "AnimationGroup"
  32388. * @returns "AnimationGroup"
  32389. */
  32390. getClassName(): string;
  32391. /**
  32392. * Creates a detailled string about the object
  32393. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32394. * @returns a string representing the object
  32395. */
  32396. toString(fullDetails?: boolean): string;
  32397. }
  32398. }
  32399. declare module "babylonjs/scene" {
  32400. import { Nullable } from "babylonjs/types";
  32401. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32402. import { Observable } from "babylonjs/Misc/observable";
  32403. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32404. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32405. import { Geometry } from "babylonjs/Meshes/geometry";
  32406. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32407. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32409. import { Mesh } from "babylonjs/Meshes/mesh";
  32410. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32411. import { Bone } from "babylonjs/Bones/bone";
  32412. import { Skeleton } from "babylonjs/Bones/skeleton";
  32413. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32414. import { Camera } from "babylonjs/Cameras/camera";
  32415. import { AbstractScene } from "babylonjs/abstractScene";
  32416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32417. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32418. import { Material } from "babylonjs/Materials/material";
  32419. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32420. import { Effect } from "babylonjs/Materials/effect";
  32421. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32422. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32423. import { Light } from "babylonjs/Lights/light";
  32424. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32425. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32426. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32427. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32428. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32429. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32430. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32431. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32432. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32433. import { Engine } from "babylonjs/Engines/engine";
  32434. import { Node } from "babylonjs/node";
  32435. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32436. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32437. import { WebRequest } from "babylonjs/Misc/webRequest";
  32438. import { Ray } from "babylonjs/Culling/ray";
  32439. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32440. import { Animation } from "babylonjs/Animations/animation";
  32441. import { Animatable } from "babylonjs/Animations/animatable";
  32442. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32443. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32444. import { Collider } from "babylonjs/Collisions/collider";
  32445. /**
  32446. * Define an interface for all classes that will hold resources
  32447. */
  32448. export interface IDisposable {
  32449. /**
  32450. * Releases all held resources
  32451. */
  32452. dispose(): void;
  32453. }
  32454. /** Interface defining initialization parameters for Scene class */
  32455. export interface SceneOptions {
  32456. /**
  32457. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32458. * It will improve performance when the number of geometries becomes important.
  32459. */
  32460. useGeometryUniqueIdsMap?: boolean;
  32461. /**
  32462. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32463. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32464. */
  32465. useMaterialMeshMap?: boolean;
  32466. /**
  32467. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32468. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32469. */
  32470. useClonedMeshhMap?: boolean;
  32471. }
  32472. /**
  32473. * Represents a scene to be rendered by the engine.
  32474. * @see http://doc.babylonjs.com/features/scene
  32475. */
  32476. export class Scene extends AbstractScene implements IAnimatable {
  32477. private static _uniqueIdCounter;
  32478. /** The fog is deactivated */
  32479. static readonly FOGMODE_NONE: number;
  32480. /** The fog density is following an exponential function */
  32481. static readonly FOGMODE_EXP: number;
  32482. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32483. static readonly FOGMODE_EXP2: number;
  32484. /** The fog density is following a linear function. */
  32485. static readonly FOGMODE_LINEAR: number;
  32486. /**
  32487. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32488. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32489. */
  32490. static MinDeltaTime: number;
  32491. /**
  32492. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32493. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32494. */
  32495. static MaxDeltaTime: number;
  32496. /**
  32497. * Factory used to create the default material.
  32498. * @param name The name of the material to create
  32499. * @param scene The scene to create the material for
  32500. * @returns The default material
  32501. */
  32502. static DefaultMaterialFactory(scene: Scene): Material;
  32503. /**
  32504. * Factory used to create the a collision coordinator.
  32505. * @returns The collision coordinator
  32506. */
  32507. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32508. /** @hidden */
  32509. readonly _isScene: boolean;
  32510. /**
  32511. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32512. */
  32513. autoClear: boolean;
  32514. /**
  32515. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32516. */
  32517. autoClearDepthAndStencil: boolean;
  32518. /**
  32519. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32520. */
  32521. clearColor: Color4;
  32522. /**
  32523. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32524. */
  32525. ambientColor: Color3;
  32526. /**
  32527. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32528. * It should only be one of the following (if not the default embedded one):
  32529. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32530. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32531. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32532. * The material properties need to be setup according to the type of texture in use.
  32533. */
  32534. environmentBRDFTexture: BaseTexture;
  32535. /** @hidden */
  32536. protected _environmentTexture: Nullable<BaseTexture>;
  32537. /**
  32538. * Texture used in all pbr material as the reflection texture.
  32539. * As in the majority of the scene they are the same (exception for multi room and so on),
  32540. * this is easier to reference from here than from all the materials.
  32541. */
  32542. /**
  32543. * Texture used in all pbr material as the reflection texture.
  32544. * As in the majority of the scene they are the same (exception for multi room and so on),
  32545. * this is easier to set here than in all the materials.
  32546. */
  32547. environmentTexture: Nullable<BaseTexture>;
  32548. /** @hidden */
  32549. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32550. /**
  32551. * Default image processing configuration used either in the rendering
  32552. * Forward main pass or through the imageProcessingPostProcess if present.
  32553. * As in the majority of the scene they are the same (exception for multi camera),
  32554. * this is easier to reference from here than from all the materials and post process.
  32555. *
  32556. * No setter as we it is a shared configuration, you can set the values instead.
  32557. */
  32558. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32559. private _forceWireframe;
  32560. /**
  32561. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32562. */
  32563. forceWireframe: boolean;
  32564. private _forcePointsCloud;
  32565. /**
  32566. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32567. */
  32568. forcePointsCloud: boolean;
  32569. /**
  32570. * Gets or sets the active clipplane 1
  32571. */
  32572. clipPlane: Nullable<Plane>;
  32573. /**
  32574. * Gets or sets the active clipplane 2
  32575. */
  32576. clipPlane2: Nullable<Plane>;
  32577. /**
  32578. * Gets or sets the active clipplane 3
  32579. */
  32580. clipPlane3: Nullable<Plane>;
  32581. /**
  32582. * Gets or sets the active clipplane 4
  32583. */
  32584. clipPlane4: Nullable<Plane>;
  32585. /**
  32586. * Gets or sets a boolean indicating if animations are enabled
  32587. */
  32588. animationsEnabled: boolean;
  32589. private _animationPropertiesOverride;
  32590. /**
  32591. * Gets or sets the animation properties override
  32592. */
  32593. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32594. /**
  32595. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32596. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32597. */
  32598. useConstantAnimationDeltaTime: boolean;
  32599. /**
  32600. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32601. * Please note that it requires to run a ray cast through the scene on every frame
  32602. */
  32603. constantlyUpdateMeshUnderPointer: boolean;
  32604. /**
  32605. * Defines the HTML cursor to use when hovering over interactive elements
  32606. */
  32607. hoverCursor: string;
  32608. /**
  32609. * Defines the HTML default cursor to use (empty by default)
  32610. */
  32611. defaultCursor: string;
  32612. /**
  32613. * This is used to call preventDefault() on pointer down
  32614. * in order to block unwanted artifacts like system double clicks
  32615. */
  32616. preventDefaultOnPointerDown: boolean;
  32617. /**
  32618. * This is used to call preventDefault() on pointer up
  32619. * in order to block unwanted artifacts like system double clicks
  32620. */
  32621. preventDefaultOnPointerUp: boolean;
  32622. /**
  32623. * Gets or sets user defined metadata
  32624. */
  32625. metadata: any;
  32626. /**
  32627. * For internal use only. Please do not use.
  32628. */
  32629. reservedDataStore: any;
  32630. /**
  32631. * Gets the name of the plugin used to load this scene (null by default)
  32632. */
  32633. loadingPluginName: string;
  32634. /**
  32635. * Use this array to add regular expressions used to disable offline support for specific urls
  32636. */
  32637. disableOfflineSupportExceptionRules: RegExp[];
  32638. /**
  32639. * An event triggered when the scene is disposed.
  32640. */
  32641. onDisposeObservable: Observable<Scene>;
  32642. private _onDisposeObserver;
  32643. /** Sets a function to be executed when this scene is disposed. */
  32644. onDispose: () => void;
  32645. /**
  32646. * An event triggered before rendering the scene (right after animations and physics)
  32647. */
  32648. onBeforeRenderObservable: Observable<Scene>;
  32649. private _onBeforeRenderObserver;
  32650. /** Sets a function to be executed before rendering this scene */
  32651. beforeRender: Nullable<() => void>;
  32652. /**
  32653. * An event triggered after rendering the scene
  32654. */
  32655. onAfterRenderObservable: Observable<Scene>;
  32656. private _onAfterRenderObserver;
  32657. /** Sets a function to be executed after rendering this scene */
  32658. afterRender: Nullable<() => void>;
  32659. /**
  32660. * An event triggered before animating the scene
  32661. */
  32662. onBeforeAnimationsObservable: Observable<Scene>;
  32663. /**
  32664. * An event triggered after animations processing
  32665. */
  32666. onAfterAnimationsObservable: Observable<Scene>;
  32667. /**
  32668. * An event triggered before draw calls are ready to be sent
  32669. */
  32670. onBeforeDrawPhaseObservable: Observable<Scene>;
  32671. /**
  32672. * An event triggered after draw calls have been sent
  32673. */
  32674. onAfterDrawPhaseObservable: Observable<Scene>;
  32675. /**
  32676. * An event triggered when the scene is ready
  32677. */
  32678. onReadyObservable: Observable<Scene>;
  32679. /**
  32680. * An event triggered before rendering a camera
  32681. */
  32682. onBeforeCameraRenderObservable: Observable<Camera>;
  32683. private _onBeforeCameraRenderObserver;
  32684. /** Sets a function to be executed before rendering a camera*/
  32685. beforeCameraRender: () => void;
  32686. /**
  32687. * An event triggered after rendering a camera
  32688. */
  32689. onAfterCameraRenderObservable: Observable<Camera>;
  32690. private _onAfterCameraRenderObserver;
  32691. /** Sets a function to be executed after rendering a camera*/
  32692. afterCameraRender: () => void;
  32693. /**
  32694. * An event triggered when active meshes evaluation is about to start
  32695. */
  32696. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32697. /**
  32698. * An event triggered when active meshes evaluation is done
  32699. */
  32700. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32701. /**
  32702. * An event triggered when particles rendering is about to start
  32703. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32704. */
  32705. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32706. /**
  32707. * An event triggered when particles rendering is done
  32708. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32709. */
  32710. onAfterParticlesRenderingObservable: Observable<Scene>;
  32711. /**
  32712. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32713. */
  32714. onDataLoadedObservable: Observable<Scene>;
  32715. /**
  32716. * An event triggered when a camera is created
  32717. */
  32718. onNewCameraAddedObservable: Observable<Camera>;
  32719. /**
  32720. * An event triggered when a camera is removed
  32721. */
  32722. onCameraRemovedObservable: Observable<Camera>;
  32723. /**
  32724. * An event triggered when a light is created
  32725. */
  32726. onNewLightAddedObservable: Observable<Light>;
  32727. /**
  32728. * An event triggered when a light is removed
  32729. */
  32730. onLightRemovedObservable: Observable<Light>;
  32731. /**
  32732. * An event triggered when a geometry is created
  32733. */
  32734. onNewGeometryAddedObservable: Observable<Geometry>;
  32735. /**
  32736. * An event triggered when a geometry is removed
  32737. */
  32738. onGeometryRemovedObservable: Observable<Geometry>;
  32739. /**
  32740. * An event triggered when a transform node is created
  32741. */
  32742. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32743. /**
  32744. * An event triggered when a transform node is removed
  32745. */
  32746. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32747. /**
  32748. * An event triggered when a mesh is created
  32749. */
  32750. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32751. /**
  32752. * An event triggered when a mesh is removed
  32753. */
  32754. onMeshRemovedObservable: Observable<AbstractMesh>;
  32755. /**
  32756. * An event triggered when a skeleton is created
  32757. */
  32758. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32759. /**
  32760. * An event triggered when a skeleton is removed
  32761. */
  32762. onSkeletonRemovedObservable: Observable<Skeleton>;
  32763. /**
  32764. * An event triggered when a material is created
  32765. */
  32766. onNewMaterialAddedObservable: Observable<Material>;
  32767. /**
  32768. * An event triggered when a material is removed
  32769. */
  32770. onMaterialRemovedObservable: Observable<Material>;
  32771. /**
  32772. * An event triggered when a texture is created
  32773. */
  32774. onNewTextureAddedObservable: Observable<BaseTexture>;
  32775. /**
  32776. * An event triggered when a texture is removed
  32777. */
  32778. onTextureRemovedObservable: Observable<BaseTexture>;
  32779. /**
  32780. * An event triggered when render targets are about to be rendered
  32781. * Can happen multiple times per frame.
  32782. */
  32783. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32784. /**
  32785. * An event triggered when render targets were rendered.
  32786. * Can happen multiple times per frame.
  32787. */
  32788. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32789. /**
  32790. * An event triggered before calculating deterministic simulation step
  32791. */
  32792. onBeforeStepObservable: Observable<Scene>;
  32793. /**
  32794. * An event triggered after calculating deterministic simulation step
  32795. */
  32796. onAfterStepObservable: Observable<Scene>;
  32797. /**
  32798. * An event triggered when the activeCamera property is updated
  32799. */
  32800. onActiveCameraChanged: Observable<Scene>;
  32801. /**
  32802. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32803. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32804. * 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)
  32805. */
  32806. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32807. /**
  32808. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32809. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32810. * 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)
  32811. */
  32812. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32813. /**
  32814. * This Observable will when a mesh has been imported into the scene.
  32815. */
  32816. onMeshImportedObservable: Observable<AbstractMesh>;
  32817. /**
  32818. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32819. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32820. */
  32821. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32822. /** @hidden */
  32823. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32824. /**
  32825. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32826. */
  32827. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32828. /**
  32829. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32830. */
  32831. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32832. /**
  32833. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32834. */
  32835. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32836. private _onPointerMove;
  32837. private _onPointerDown;
  32838. private _onPointerUp;
  32839. /** Callback called when a pointer move is detected */
  32840. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32841. /** Callback called when a pointer down is detected */
  32842. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32843. /** Callback called when a pointer up is detected */
  32844. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32845. /** Callback called when a pointer pick is detected */
  32846. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32847. /**
  32848. * 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).
  32849. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32850. */
  32851. onPrePointerObservable: Observable<PointerInfoPre>;
  32852. /**
  32853. * Observable event triggered each time an input event is received from the rendering canvas
  32854. */
  32855. onPointerObservable: Observable<PointerInfo>;
  32856. /**
  32857. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32858. */
  32859. readonly unTranslatedPointer: Vector2;
  32860. /** The distance in pixel that you have to move to prevent some events */
  32861. static DragMovementThreshold: number;
  32862. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32863. static LongPressDelay: number;
  32864. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32865. static DoubleClickDelay: number;
  32866. /** If you need to check double click without raising a single click at first click, enable this flag */
  32867. static ExclusiveDoubleClickMode: boolean;
  32868. private _initClickEvent;
  32869. private _initActionManager;
  32870. private _delayedSimpleClick;
  32871. private _delayedSimpleClickTimeout;
  32872. private _previousDelayedSimpleClickTimeout;
  32873. private _meshPickProceed;
  32874. private _previousButtonPressed;
  32875. private _currentPickResult;
  32876. private _previousPickResult;
  32877. private _totalPointersPressed;
  32878. private _doubleClickOccured;
  32879. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32880. cameraToUseForPointers: Nullable<Camera>;
  32881. private _pointerX;
  32882. private _pointerY;
  32883. private _unTranslatedPointerX;
  32884. private _unTranslatedPointerY;
  32885. private _startingPointerPosition;
  32886. private _previousStartingPointerPosition;
  32887. private _startingPointerTime;
  32888. private _previousStartingPointerTime;
  32889. private _pointerCaptures;
  32890. private _timeAccumulator;
  32891. private _currentStepId;
  32892. private _currentInternalStep;
  32893. /** @hidden */
  32894. _mirroredCameraPosition: Nullable<Vector3>;
  32895. /**
  32896. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32897. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32898. */
  32899. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32900. /**
  32901. * Observable event triggered each time an keyboard event is received from the hosting window
  32902. */
  32903. onKeyboardObservable: Observable<KeyboardInfo>;
  32904. private _onKeyDown;
  32905. private _onKeyUp;
  32906. private _onCanvasFocusObserver;
  32907. private _onCanvasBlurObserver;
  32908. private _useRightHandedSystem;
  32909. /**
  32910. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32911. */
  32912. useRightHandedSystem: boolean;
  32913. /**
  32914. * Sets the step Id used by deterministic lock step
  32915. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32916. * @param newStepId defines the step Id
  32917. */
  32918. setStepId(newStepId: number): void;
  32919. /**
  32920. * Gets the step Id used by deterministic lock step
  32921. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32922. * @returns the step Id
  32923. */
  32924. getStepId(): number;
  32925. /**
  32926. * Gets the internal step used by deterministic lock step
  32927. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32928. * @returns the internal step
  32929. */
  32930. getInternalStep(): number;
  32931. private _fogEnabled;
  32932. /**
  32933. * Gets or sets a boolean indicating if fog is enabled on this scene
  32934. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32935. * (Default is true)
  32936. */
  32937. fogEnabled: boolean;
  32938. private _fogMode;
  32939. /**
  32940. * Gets or sets the fog mode to use
  32941. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32942. * | mode | value |
  32943. * | --- | --- |
  32944. * | FOGMODE_NONE | 0 |
  32945. * | FOGMODE_EXP | 1 |
  32946. * | FOGMODE_EXP2 | 2 |
  32947. * | FOGMODE_LINEAR | 3 |
  32948. */
  32949. fogMode: number;
  32950. /**
  32951. * Gets or sets the fog color to use
  32952. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32953. * (Default is Color3(0.2, 0.2, 0.3))
  32954. */
  32955. fogColor: Color3;
  32956. /**
  32957. * Gets or sets the fog density to use
  32958. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32959. * (Default is 0.1)
  32960. */
  32961. fogDensity: number;
  32962. /**
  32963. * Gets or sets the fog start distance to use
  32964. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32965. * (Default is 0)
  32966. */
  32967. fogStart: number;
  32968. /**
  32969. * Gets or sets the fog end distance to use
  32970. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32971. * (Default is 1000)
  32972. */
  32973. fogEnd: number;
  32974. private _shadowsEnabled;
  32975. /**
  32976. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32977. */
  32978. shadowsEnabled: boolean;
  32979. private _lightsEnabled;
  32980. /**
  32981. * Gets or sets a boolean indicating if lights are enabled on this scene
  32982. */
  32983. lightsEnabled: boolean;
  32984. /** All of the active cameras added to this scene. */
  32985. activeCameras: Camera[];
  32986. /** @hidden */
  32987. _activeCamera: Nullable<Camera>;
  32988. /** Gets or sets the current active camera */
  32989. activeCamera: Nullable<Camera>;
  32990. private _defaultMaterial;
  32991. /** The default material used on meshes when no material is affected */
  32992. /** The default material used on meshes when no material is affected */
  32993. defaultMaterial: Material;
  32994. private _texturesEnabled;
  32995. /**
  32996. * Gets or sets a boolean indicating if textures are enabled on this scene
  32997. */
  32998. texturesEnabled: boolean;
  32999. /**
  33000. * Gets or sets a boolean indicating if particles are enabled on this scene
  33001. */
  33002. particlesEnabled: boolean;
  33003. /**
  33004. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33005. */
  33006. spritesEnabled: boolean;
  33007. private _skeletonsEnabled;
  33008. /**
  33009. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33010. */
  33011. skeletonsEnabled: boolean;
  33012. /**
  33013. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33014. */
  33015. lensFlaresEnabled: boolean;
  33016. /**
  33017. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33018. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33019. */
  33020. collisionsEnabled: boolean;
  33021. private _collisionCoordinator;
  33022. /** @hidden */
  33023. readonly collisionCoordinator: ICollisionCoordinator;
  33024. /**
  33025. * Defines the gravity applied to this scene (used only for collisions)
  33026. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33027. */
  33028. gravity: Vector3;
  33029. /**
  33030. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33031. */
  33032. postProcessesEnabled: boolean;
  33033. /**
  33034. * The list of postprocesses added to the scene
  33035. */
  33036. postProcesses: PostProcess[];
  33037. /**
  33038. * Gets the current postprocess manager
  33039. */
  33040. postProcessManager: PostProcessManager;
  33041. /**
  33042. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33043. */
  33044. renderTargetsEnabled: boolean;
  33045. /**
  33046. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33047. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33048. */
  33049. dumpNextRenderTargets: boolean;
  33050. /**
  33051. * The list of user defined render targets added to the scene
  33052. */
  33053. customRenderTargets: RenderTargetTexture[];
  33054. /**
  33055. * Defines if texture loading must be delayed
  33056. * If true, textures will only be loaded when they need to be rendered
  33057. */
  33058. useDelayedTextureLoading: boolean;
  33059. /**
  33060. * Gets the list of meshes imported to the scene through SceneLoader
  33061. */
  33062. importedMeshesFiles: String[];
  33063. /**
  33064. * Gets or sets a boolean indicating if probes are enabled on this scene
  33065. */
  33066. probesEnabled: boolean;
  33067. /**
  33068. * Gets or sets the current offline provider to use to store scene data
  33069. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33070. */
  33071. offlineProvider: IOfflineProvider;
  33072. /**
  33073. * Gets or sets the action manager associated with the scene
  33074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33075. */
  33076. actionManager: AbstractActionManager;
  33077. private _meshesForIntersections;
  33078. /**
  33079. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33080. */
  33081. proceduralTexturesEnabled: boolean;
  33082. private _engine;
  33083. private _totalVertices;
  33084. /** @hidden */
  33085. _activeIndices: PerfCounter;
  33086. /** @hidden */
  33087. _activeParticles: PerfCounter;
  33088. /** @hidden */
  33089. _activeBones: PerfCounter;
  33090. private _animationRatio;
  33091. /** @hidden */
  33092. _animationTimeLast: number;
  33093. /** @hidden */
  33094. _animationTime: number;
  33095. /**
  33096. * Gets or sets a general scale for animation speed
  33097. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33098. */
  33099. animationTimeScale: number;
  33100. /** @hidden */
  33101. _cachedMaterial: Nullable<Material>;
  33102. /** @hidden */
  33103. _cachedEffect: Nullable<Effect>;
  33104. /** @hidden */
  33105. _cachedVisibility: Nullable<number>;
  33106. private _renderId;
  33107. private _frameId;
  33108. private _executeWhenReadyTimeoutId;
  33109. private _intermediateRendering;
  33110. private _viewUpdateFlag;
  33111. private _projectionUpdateFlag;
  33112. /** @hidden */
  33113. _toBeDisposed: Nullable<IDisposable>[];
  33114. private _activeRequests;
  33115. /** @hidden */
  33116. _pendingData: any[];
  33117. private _isDisposed;
  33118. /**
  33119. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33120. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33121. */
  33122. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33123. private _activeMeshes;
  33124. private _processedMaterials;
  33125. private _renderTargets;
  33126. /** @hidden */
  33127. _activeParticleSystems: SmartArray<IParticleSystem>;
  33128. private _activeSkeletons;
  33129. private _softwareSkinnedMeshes;
  33130. private _renderingManager;
  33131. /** @hidden */
  33132. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33133. private _transformMatrix;
  33134. private _sceneUbo;
  33135. /** @hidden */
  33136. _viewMatrix: Matrix;
  33137. private _projectionMatrix;
  33138. private _wheelEventName;
  33139. /** @hidden */
  33140. _forcedViewPosition: Nullable<Vector3>;
  33141. /** @hidden */
  33142. _frustumPlanes: Plane[];
  33143. /**
  33144. * Gets the list of frustum planes (built from the active camera)
  33145. */
  33146. readonly frustumPlanes: Plane[];
  33147. /**
  33148. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33149. * This is useful if there are more lights that the maximum simulteanous authorized
  33150. */
  33151. requireLightSorting: boolean;
  33152. /** @hidden */
  33153. readonly useMaterialMeshMap: boolean;
  33154. /** @hidden */
  33155. readonly useClonedMeshhMap: boolean;
  33156. private _pointerOverMesh;
  33157. private _pickedDownMesh;
  33158. private _pickedUpMesh;
  33159. private _externalData;
  33160. private _uid;
  33161. /**
  33162. * @hidden
  33163. * Backing store of defined scene components.
  33164. */
  33165. _components: ISceneComponent[];
  33166. /**
  33167. * @hidden
  33168. * Backing store of defined scene components.
  33169. */
  33170. _serializableComponents: ISceneSerializableComponent[];
  33171. /**
  33172. * List of components to register on the next registration step.
  33173. */
  33174. private _transientComponents;
  33175. /**
  33176. * Registers the transient components if needed.
  33177. */
  33178. private _registerTransientComponents;
  33179. /**
  33180. * @hidden
  33181. * Add a component to the scene.
  33182. * Note that the ccomponent could be registered on th next frame if this is called after
  33183. * the register component stage.
  33184. * @param component Defines the component to add to the scene
  33185. */
  33186. _addComponent(component: ISceneComponent): void;
  33187. /**
  33188. * @hidden
  33189. * Gets a component from the scene.
  33190. * @param name defines the name of the component to retrieve
  33191. * @returns the component or null if not present
  33192. */
  33193. _getComponent(name: string): Nullable<ISceneComponent>;
  33194. /**
  33195. * @hidden
  33196. * Defines the actions happening before camera updates.
  33197. */
  33198. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33199. /**
  33200. * @hidden
  33201. * Defines the actions happening before clear the canvas.
  33202. */
  33203. _beforeClearStage: Stage<SimpleStageAction>;
  33204. /**
  33205. * @hidden
  33206. * Defines the actions when collecting render targets for the frame.
  33207. */
  33208. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33209. /**
  33210. * @hidden
  33211. * Defines the actions happening for one camera in the frame.
  33212. */
  33213. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33214. /**
  33215. * @hidden
  33216. * Defines the actions happening during the per mesh ready checks.
  33217. */
  33218. _isReadyForMeshStage: Stage<MeshStageAction>;
  33219. /**
  33220. * @hidden
  33221. * Defines the actions happening before evaluate active mesh checks.
  33222. */
  33223. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33224. /**
  33225. * @hidden
  33226. * Defines the actions happening during the evaluate sub mesh checks.
  33227. */
  33228. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33229. /**
  33230. * @hidden
  33231. * Defines the actions happening during the active mesh stage.
  33232. */
  33233. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33234. /**
  33235. * @hidden
  33236. * Defines the actions happening during the per camera render target step.
  33237. */
  33238. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33239. /**
  33240. * @hidden
  33241. * Defines the actions happening just before the active camera is drawing.
  33242. */
  33243. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33244. /**
  33245. * @hidden
  33246. * Defines the actions happening just before a render target is drawing.
  33247. */
  33248. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33249. /**
  33250. * @hidden
  33251. * Defines the actions happening just before a rendering group is drawing.
  33252. */
  33253. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33254. /**
  33255. * @hidden
  33256. * Defines the actions happening just before a mesh is drawing.
  33257. */
  33258. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33259. /**
  33260. * @hidden
  33261. * Defines the actions happening just after a mesh has been drawn.
  33262. */
  33263. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33264. /**
  33265. * @hidden
  33266. * Defines the actions happening just after a rendering group has been drawn.
  33267. */
  33268. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33269. /**
  33270. * @hidden
  33271. * Defines the actions happening just after the active camera has been drawn.
  33272. */
  33273. _afterCameraDrawStage: Stage<CameraStageAction>;
  33274. /**
  33275. * @hidden
  33276. * Defines the actions happening just after a render target has been drawn.
  33277. */
  33278. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33279. /**
  33280. * @hidden
  33281. * Defines the actions happening just after rendering all cameras and computing intersections.
  33282. */
  33283. _afterRenderStage: Stage<SimpleStageAction>;
  33284. /**
  33285. * @hidden
  33286. * Defines the actions happening when a pointer move event happens.
  33287. */
  33288. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33289. /**
  33290. * @hidden
  33291. * Defines the actions happening when a pointer down event happens.
  33292. */
  33293. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33294. /**
  33295. * @hidden
  33296. * Defines the actions happening when a pointer up event happens.
  33297. */
  33298. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33299. /**
  33300. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33301. */
  33302. private geometriesByUniqueId;
  33303. /**
  33304. * Creates a new Scene
  33305. * @param engine defines the engine to use to render this scene
  33306. * @param options defines the scene options
  33307. */
  33308. constructor(engine: Engine, options?: SceneOptions);
  33309. /**
  33310. * Gets a string idenfifying the name of the class
  33311. * @returns "Scene" string
  33312. */
  33313. getClassName(): string;
  33314. private _defaultMeshCandidates;
  33315. /**
  33316. * @hidden
  33317. */
  33318. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33319. private _defaultSubMeshCandidates;
  33320. /**
  33321. * @hidden
  33322. */
  33323. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33324. /**
  33325. * Sets the default candidate providers for the scene.
  33326. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33327. * and getCollidingSubMeshCandidates to their default function
  33328. */
  33329. setDefaultCandidateProviders(): void;
  33330. /**
  33331. * Gets the mesh that is currently under the pointer
  33332. */
  33333. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33334. /**
  33335. * Gets or sets the current on-screen X position of the pointer
  33336. */
  33337. pointerX: number;
  33338. /**
  33339. * Gets or sets the current on-screen Y position of the pointer
  33340. */
  33341. pointerY: number;
  33342. /**
  33343. * Gets the cached material (ie. the latest rendered one)
  33344. * @returns the cached material
  33345. */
  33346. getCachedMaterial(): Nullable<Material>;
  33347. /**
  33348. * Gets the cached effect (ie. the latest rendered one)
  33349. * @returns the cached effect
  33350. */
  33351. getCachedEffect(): Nullable<Effect>;
  33352. /**
  33353. * Gets the cached visibility state (ie. the latest rendered one)
  33354. * @returns the cached visibility state
  33355. */
  33356. getCachedVisibility(): Nullable<number>;
  33357. /**
  33358. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33359. * @param material defines the current material
  33360. * @param effect defines the current effect
  33361. * @param visibility defines the current visibility state
  33362. * @returns true if one parameter is not cached
  33363. */
  33364. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33365. /**
  33366. * Gets the engine associated with the scene
  33367. * @returns an Engine
  33368. */
  33369. getEngine(): Engine;
  33370. /**
  33371. * Gets the total number of vertices rendered per frame
  33372. * @returns the total number of vertices rendered per frame
  33373. */
  33374. getTotalVertices(): number;
  33375. /**
  33376. * Gets the performance counter for total vertices
  33377. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33378. */
  33379. readonly totalVerticesPerfCounter: PerfCounter;
  33380. /**
  33381. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33382. * @returns the total number of active indices rendered per frame
  33383. */
  33384. getActiveIndices(): number;
  33385. /**
  33386. * Gets the performance counter for active indices
  33387. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33388. */
  33389. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33390. /**
  33391. * Gets the total number of active particles rendered per frame
  33392. * @returns the total number of active particles rendered per frame
  33393. */
  33394. getActiveParticles(): number;
  33395. /**
  33396. * Gets the performance counter for active particles
  33397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33398. */
  33399. readonly activeParticlesPerfCounter: PerfCounter;
  33400. /**
  33401. * Gets the total number of active bones rendered per frame
  33402. * @returns the total number of active bones rendered per frame
  33403. */
  33404. getActiveBones(): number;
  33405. /**
  33406. * Gets the performance counter for active bones
  33407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33408. */
  33409. readonly activeBonesPerfCounter: PerfCounter;
  33410. /**
  33411. * Gets the array of active meshes
  33412. * @returns an array of AbstractMesh
  33413. */
  33414. getActiveMeshes(): SmartArray<AbstractMesh>;
  33415. /**
  33416. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33417. * @returns a number
  33418. */
  33419. getAnimationRatio(): number;
  33420. /**
  33421. * Gets an unique Id for the current render phase
  33422. * @returns a number
  33423. */
  33424. getRenderId(): number;
  33425. /**
  33426. * Gets an unique Id for the current frame
  33427. * @returns a number
  33428. */
  33429. getFrameId(): number;
  33430. /** Call this function if you want to manually increment the render Id*/
  33431. incrementRenderId(): void;
  33432. private _updatePointerPosition;
  33433. private _createUbo;
  33434. private _setRayOnPointerInfo;
  33435. /**
  33436. * Use this method to simulate a pointer move on a mesh
  33437. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33438. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33439. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33440. * @returns the current scene
  33441. */
  33442. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33443. private _processPointerMove;
  33444. private _checkPrePointerObservable;
  33445. /**
  33446. * Use this method to simulate a pointer down on a mesh
  33447. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33448. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33449. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33450. * @returns the current scene
  33451. */
  33452. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33453. private _processPointerDown;
  33454. /**
  33455. * Use this method to simulate a pointer up on a mesh
  33456. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33457. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33458. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33459. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33460. * @returns the current scene
  33461. */
  33462. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33463. private _processPointerUp;
  33464. /**
  33465. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33466. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33467. * @returns true if the pointer was captured
  33468. */
  33469. isPointerCaptured(pointerId?: number): boolean;
  33470. /** @hidden */
  33471. _isPointerSwiping(): boolean;
  33472. /**
  33473. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33474. * @param attachUp defines if you want to attach events to pointerup
  33475. * @param attachDown defines if you want to attach events to pointerdown
  33476. * @param attachMove defines if you want to attach events to pointermove
  33477. */
  33478. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33479. /** Detaches all event handlers*/
  33480. detachControl(): void;
  33481. /**
  33482. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33483. * Delay loaded resources are not taking in account
  33484. * @return true if all required resources are ready
  33485. */
  33486. isReady(): boolean;
  33487. /** Resets all cached information relative to material (including effect and visibility) */
  33488. resetCachedMaterial(): void;
  33489. /**
  33490. * Registers a function to be called before every frame render
  33491. * @param func defines the function to register
  33492. */
  33493. registerBeforeRender(func: () => void): void;
  33494. /**
  33495. * Unregisters a function called before every frame render
  33496. * @param func defines the function to unregister
  33497. */
  33498. unregisterBeforeRender(func: () => void): void;
  33499. /**
  33500. * Registers a function to be called after every frame render
  33501. * @param func defines the function to register
  33502. */
  33503. registerAfterRender(func: () => void): void;
  33504. /**
  33505. * Unregisters a function called after every frame render
  33506. * @param func defines the function to unregister
  33507. */
  33508. unregisterAfterRender(func: () => void): void;
  33509. private _executeOnceBeforeRender;
  33510. /**
  33511. * The provided function will run before render once and will be disposed afterwards.
  33512. * A timeout delay can be provided so that the function will be executed in N ms.
  33513. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33514. * @param func The function to be executed.
  33515. * @param timeout optional delay in ms
  33516. */
  33517. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33518. /** @hidden */
  33519. _addPendingData(data: any): void;
  33520. /** @hidden */
  33521. _removePendingData(data: any): void;
  33522. /**
  33523. * Returns the number of items waiting to be loaded
  33524. * @returns the number of items waiting to be loaded
  33525. */
  33526. getWaitingItemsCount(): number;
  33527. /**
  33528. * Returns a boolean indicating if the scene is still loading data
  33529. */
  33530. readonly isLoading: boolean;
  33531. /**
  33532. * Registers a function to be executed when the scene is ready
  33533. * @param {Function} func - the function to be executed
  33534. */
  33535. executeWhenReady(func: () => void): void;
  33536. /**
  33537. * Returns a promise that resolves when the scene is ready
  33538. * @returns A promise that resolves when the scene is ready
  33539. */
  33540. whenReadyAsync(): Promise<void>;
  33541. /** @hidden */
  33542. _checkIsReady(): void;
  33543. /**
  33544. * Gets all animatable attached to the scene
  33545. */
  33546. readonly animatables: Animatable[];
  33547. /**
  33548. * Resets the last animation time frame.
  33549. * Useful to override when animations start running when loading a scene for the first time.
  33550. */
  33551. resetLastAnimationTimeFrame(): void;
  33552. /**
  33553. * Gets the current view matrix
  33554. * @returns a Matrix
  33555. */
  33556. getViewMatrix(): Matrix;
  33557. /**
  33558. * Gets the current projection matrix
  33559. * @returns a Matrix
  33560. */
  33561. getProjectionMatrix(): Matrix;
  33562. /**
  33563. * Gets the current transform matrix
  33564. * @returns a Matrix made of View * Projection
  33565. */
  33566. getTransformMatrix(): Matrix;
  33567. /**
  33568. * Sets the current transform matrix
  33569. * @param viewL defines the View matrix to use
  33570. * @param projectionL defines the Projection matrix to use
  33571. * @param viewR defines the right View matrix to use (if provided)
  33572. * @param projectionR defines the right Projection matrix to use (if provided)
  33573. */
  33574. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33575. /**
  33576. * Gets the uniform buffer used to store scene data
  33577. * @returns a UniformBuffer
  33578. */
  33579. getSceneUniformBuffer(): UniformBuffer;
  33580. /**
  33581. * Gets an unique (relatively to the current scene) Id
  33582. * @returns an unique number for the scene
  33583. */
  33584. getUniqueId(): number;
  33585. /**
  33586. * Add a mesh to the list of scene's meshes
  33587. * @param newMesh defines the mesh to add
  33588. * @param recursive if all child meshes should also be added to the scene
  33589. */
  33590. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33591. /**
  33592. * Remove a mesh for the list of scene's meshes
  33593. * @param toRemove defines the mesh to remove
  33594. * @param recursive if all child meshes should also be removed from the scene
  33595. * @returns the index where the mesh was in the mesh list
  33596. */
  33597. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33598. /**
  33599. * Add a transform node to the list of scene's transform nodes
  33600. * @param newTransformNode defines the transform node to add
  33601. */
  33602. addTransformNode(newTransformNode: TransformNode): void;
  33603. /**
  33604. * Remove a transform node for the list of scene's transform nodes
  33605. * @param toRemove defines the transform node to remove
  33606. * @returns the index where the transform node was in the transform node list
  33607. */
  33608. removeTransformNode(toRemove: TransformNode): number;
  33609. /**
  33610. * Remove a skeleton for the list of scene's skeletons
  33611. * @param toRemove defines the skeleton to remove
  33612. * @returns the index where the skeleton was in the skeleton list
  33613. */
  33614. removeSkeleton(toRemove: Skeleton): number;
  33615. /**
  33616. * Remove a morph target for the list of scene's morph targets
  33617. * @param toRemove defines the morph target to remove
  33618. * @returns the index where the morph target was in the morph target list
  33619. */
  33620. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33621. /**
  33622. * Remove a light for the list of scene's lights
  33623. * @param toRemove defines the light to remove
  33624. * @returns the index where the light was in the light list
  33625. */
  33626. removeLight(toRemove: Light): number;
  33627. /**
  33628. * Remove a camera for the list of scene's cameras
  33629. * @param toRemove defines the camera to remove
  33630. * @returns the index where the camera was in the camera list
  33631. */
  33632. removeCamera(toRemove: Camera): number;
  33633. /**
  33634. * Remove a particle system for the list of scene's particle systems
  33635. * @param toRemove defines the particle system to remove
  33636. * @returns the index where the particle system was in the particle system list
  33637. */
  33638. removeParticleSystem(toRemove: IParticleSystem): number;
  33639. /**
  33640. * Remove a animation for the list of scene's animations
  33641. * @param toRemove defines the animation to remove
  33642. * @returns the index where the animation was in the animation list
  33643. */
  33644. removeAnimation(toRemove: Animation): number;
  33645. /**
  33646. * Removes the given animation group from this scene.
  33647. * @param toRemove The animation group to remove
  33648. * @returns The index of the removed animation group
  33649. */
  33650. removeAnimationGroup(toRemove: AnimationGroup): number;
  33651. /**
  33652. * Removes the given multi-material from this scene.
  33653. * @param toRemove The multi-material to remove
  33654. * @returns The index of the removed multi-material
  33655. */
  33656. removeMultiMaterial(toRemove: MultiMaterial): number;
  33657. /**
  33658. * Removes the given material from this scene.
  33659. * @param toRemove The material to remove
  33660. * @returns The index of the removed material
  33661. */
  33662. removeMaterial(toRemove: Material): number;
  33663. /**
  33664. * Removes the given action manager from this scene.
  33665. * @param toRemove The action manager to remove
  33666. * @returns The index of the removed action manager
  33667. */
  33668. removeActionManager(toRemove: AbstractActionManager): number;
  33669. /**
  33670. * Removes the given texture from this scene.
  33671. * @param toRemove The texture to remove
  33672. * @returns The index of the removed texture
  33673. */
  33674. removeTexture(toRemove: BaseTexture): number;
  33675. /**
  33676. * Adds the given light to this scene
  33677. * @param newLight The light to add
  33678. */
  33679. addLight(newLight: Light): void;
  33680. /**
  33681. * Sorts the list list based on light priorities
  33682. */
  33683. sortLightsByPriority(): void;
  33684. /**
  33685. * Adds the given camera to this scene
  33686. * @param newCamera The camera to add
  33687. */
  33688. addCamera(newCamera: Camera): void;
  33689. /**
  33690. * Adds the given skeleton to this scene
  33691. * @param newSkeleton The skeleton to add
  33692. */
  33693. addSkeleton(newSkeleton: Skeleton): void;
  33694. /**
  33695. * Adds the given particle system to this scene
  33696. * @param newParticleSystem The particle system to add
  33697. */
  33698. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33699. /**
  33700. * Adds the given animation to this scene
  33701. * @param newAnimation The animation to add
  33702. */
  33703. addAnimation(newAnimation: Animation): void;
  33704. /**
  33705. * Adds the given animation group to this scene.
  33706. * @param newAnimationGroup The animation group to add
  33707. */
  33708. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33709. /**
  33710. * Adds the given multi-material to this scene
  33711. * @param newMultiMaterial The multi-material to add
  33712. */
  33713. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33714. /**
  33715. * Adds the given material to this scene
  33716. * @param newMaterial The material to add
  33717. */
  33718. addMaterial(newMaterial: Material): void;
  33719. /**
  33720. * Adds the given morph target to this scene
  33721. * @param newMorphTargetManager The morph target to add
  33722. */
  33723. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33724. /**
  33725. * Adds the given geometry to this scene
  33726. * @param newGeometry The geometry to add
  33727. */
  33728. addGeometry(newGeometry: Geometry): void;
  33729. /**
  33730. * Adds the given action manager to this scene
  33731. * @param newActionManager The action manager to add
  33732. */
  33733. addActionManager(newActionManager: AbstractActionManager): void;
  33734. /**
  33735. * Adds the given texture to this scene.
  33736. * @param newTexture The texture to add
  33737. */
  33738. addTexture(newTexture: BaseTexture): void;
  33739. /**
  33740. * Switch active camera
  33741. * @param newCamera defines the new active camera
  33742. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33743. */
  33744. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33745. /**
  33746. * sets the active camera of the scene using its ID
  33747. * @param id defines the camera's ID
  33748. * @return the new active camera or null if none found.
  33749. */
  33750. setActiveCameraByID(id: string): Nullable<Camera>;
  33751. /**
  33752. * sets the active camera of the scene using its name
  33753. * @param name defines the camera's name
  33754. * @returns the new active camera or null if none found.
  33755. */
  33756. setActiveCameraByName(name: string): Nullable<Camera>;
  33757. /**
  33758. * get an animation group using its name
  33759. * @param name defines the material's name
  33760. * @return the animation group or null if none found.
  33761. */
  33762. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33763. /**
  33764. * Get a material using its unique id
  33765. * @param uniqueId defines the material's unique id
  33766. * @return the material or null if none found.
  33767. */
  33768. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33769. /**
  33770. * get a material using its id
  33771. * @param id defines the material's ID
  33772. * @return the material or null if none found.
  33773. */
  33774. getMaterialByID(id: string): Nullable<Material>;
  33775. /**
  33776. * Gets a material using its name
  33777. * @param name defines the material's name
  33778. * @return the material or null if none found.
  33779. */
  33780. getMaterialByName(name: string): Nullable<Material>;
  33781. /**
  33782. * Gets a camera using its id
  33783. * @param id defines the id to look for
  33784. * @returns the camera or null if not found
  33785. */
  33786. getCameraByID(id: string): Nullable<Camera>;
  33787. /**
  33788. * Gets a camera using its unique id
  33789. * @param uniqueId defines the unique id to look for
  33790. * @returns the camera or null if not found
  33791. */
  33792. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33793. /**
  33794. * Gets a camera using its name
  33795. * @param name defines the camera's name
  33796. * @return the camera or null if none found.
  33797. */
  33798. getCameraByName(name: string): Nullable<Camera>;
  33799. /**
  33800. * Gets a bone using its id
  33801. * @param id defines the bone's id
  33802. * @return the bone or null if not found
  33803. */
  33804. getBoneByID(id: string): Nullable<Bone>;
  33805. /**
  33806. * Gets a bone using its id
  33807. * @param name defines the bone's name
  33808. * @return the bone or null if not found
  33809. */
  33810. getBoneByName(name: string): Nullable<Bone>;
  33811. /**
  33812. * Gets a light node using its name
  33813. * @param name defines the the light's name
  33814. * @return the light or null if none found.
  33815. */
  33816. getLightByName(name: string): Nullable<Light>;
  33817. /**
  33818. * Gets a light node using its id
  33819. * @param id defines the light's id
  33820. * @return the light or null if none found.
  33821. */
  33822. getLightByID(id: string): Nullable<Light>;
  33823. /**
  33824. * Gets a light node using its scene-generated unique ID
  33825. * @param uniqueId defines the light's unique id
  33826. * @return the light or null if none found.
  33827. */
  33828. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33829. /**
  33830. * Gets a particle system by id
  33831. * @param id defines the particle system id
  33832. * @return the corresponding system or null if none found
  33833. */
  33834. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33835. /**
  33836. * Gets a geometry using its ID
  33837. * @param id defines the geometry's id
  33838. * @return the geometry or null if none found.
  33839. */
  33840. getGeometryByID(id: string): Nullable<Geometry>;
  33841. private _getGeometryByUniqueID;
  33842. /**
  33843. * Add a new geometry to this scene
  33844. * @param geometry defines the geometry to be added to the scene.
  33845. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33846. * @return a boolean defining if the geometry was added or not
  33847. */
  33848. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33849. /**
  33850. * Removes an existing geometry
  33851. * @param geometry defines the geometry to be removed from the scene
  33852. * @return a boolean defining if the geometry was removed or not
  33853. */
  33854. removeGeometry(geometry: Geometry): boolean;
  33855. /**
  33856. * Gets the list of geometries attached to the scene
  33857. * @returns an array of Geometry
  33858. */
  33859. getGeometries(): Geometry[];
  33860. /**
  33861. * Gets the first added mesh found of a given ID
  33862. * @param id defines the id to search for
  33863. * @return the mesh found or null if not found at all
  33864. */
  33865. getMeshByID(id: string): Nullable<AbstractMesh>;
  33866. /**
  33867. * Gets a list of meshes using their id
  33868. * @param id defines the id to search for
  33869. * @returns a list of meshes
  33870. */
  33871. getMeshesByID(id: string): Array<AbstractMesh>;
  33872. /**
  33873. * Gets the first added transform node found of a given ID
  33874. * @param id defines the id to search for
  33875. * @return the found transform node or null if not found at all.
  33876. */
  33877. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33878. /**
  33879. * Gets a transform node with its auto-generated unique id
  33880. * @param uniqueId efines the unique id to search for
  33881. * @return the found transform node or null if not found at all.
  33882. */
  33883. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33884. /**
  33885. * Gets a list of transform nodes using their id
  33886. * @param id defines the id to search for
  33887. * @returns a list of transform nodes
  33888. */
  33889. getTransformNodesByID(id: string): Array<TransformNode>;
  33890. /**
  33891. * Gets a mesh with its auto-generated unique id
  33892. * @param uniqueId defines the unique id to search for
  33893. * @return the found mesh or null if not found at all.
  33894. */
  33895. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33896. /**
  33897. * Gets a the last added mesh using a given id
  33898. * @param id defines the id to search for
  33899. * @return the found mesh or null if not found at all.
  33900. */
  33901. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33902. /**
  33903. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33904. * @param id defines the id to search for
  33905. * @return the found node or null if not found at all
  33906. */
  33907. getLastEntryByID(id: string): Nullable<Node>;
  33908. /**
  33909. * Gets a node (Mesh, Camera, Light) using a given id
  33910. * @param id defines the id to search for
  33911. * @return the found node or null if not found at all
  33912. */
  33913. getNodeByID(id: string): Nullable<Node>;
  33914. /**
  33915. * Gets a node (Mesh, Camera, Light) using a given name
  33916. * @param name defines the name to search for
  33917. * @return the found node or null if not found at all.
  33918. */
  33919. getNodeByName(name: string): Nullable<Node>;
  33920. /**
  33921. * Gets a mesh using a given name
  33922. * @param name defines the name to search for
  33923. * @return the found mesh or null if not found at all.
  33924. */
  33925. getMeshByName(name: string): Nullable<AbstractMesh>;
  33926. /**
  33927. * Gets a transform node using a given name
  33928. * @param name defines the name to search for
  33929. * @return the found transform node or null if not found at all.
  33930. */
  33931. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33932. /**
  33933. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33934. * @param id defines the id to search for
  33935. * @return the found skeleton or null if not found at all.
  33936. */
  33937. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33938. /**
  33939. * Gets a skeleton using a given auto generated unique id
  33940. * @param uniqueId defines the unique id to search for
  33941. * @return the found skeleton or null if not found at all.
  33942. */
  33943. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33944. /**
  33945. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33946. * @param id defines the id to search for
  33947. * @return the found skeleton or null if not found at all.
  33948. */
  33949. getSkeletonById(id: string): Nullable<Skeleton>;
  33950. /**
  33951. * Gets a skeleton using a given name
  33952. * @param name defines the name to search for
  33953. * @return the found skeleton or null if not found at all.
  33954. */
  33955. getSkeletonByName(name: string): Nullable<Skeleton>;
  33956. /**
  33957. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33958. * @param id defines the id to search for
  33959. * @return the found morph target manager or null if not found at all.
  33960. */
  33961. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33962. /**
  33963. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33964. * @param id defines the id to search for
  33965. * @return the found morph target or null if not found at all.
  33966. */
  33967. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33968. /**
  33969. * Gets a boolean indicating if the given mesh is active
  33970. * @param mesh defines the mesh to look for
  33971. * @returns true if the mesh is in the active list
  33972. */
  33973. isActiveMesh(mesh: AbstractMesh): boolean;
  33974. /**
  33975. * Return a unique id as a string which can serve as an identifier for the scene
  33976. */
  33977. readonly uid: string;
  33978. /**
  33979. * Add an externaly attached data from its key.
  33980. * This method call will fail and return false, if such key already exists.
  33981. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33982. * @param key the unique key that identifies the data
  33983. * @param data the data object to associate to the key for this Engine instance
  33984. * @return true if no such key were already present and the data was added successfully, false otherwise
  33985. */
  33986. addExternalData<T>(key: string, data: T): boolean;
  33987. /**
  33988. * Get an externaly attached data from its key
  33989. * @param key the unique key that identifies the data
  33990. * @return the associated data, if present (can be null), or undefined if not present
  33991. */
  33992. getExternalData<T>(key: string): Nullable<T>;
  33993. /**
  33994. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33995. * @param key the unique key that identifies the data
  33996. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33997. * @return the associated data, can be null if the factory returned null.
  33998. */
  33999. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34000. /**
  34001. * Remove an externaly attached data from the Engine instance
  34002. * @param key the unique key that identifies the data
  34003. * @return true if the data was successfully removed, false if it doesn't exist
  34004. */
  34005. removeExternalData(key: string): boolean;
  34006. private _evaluateSubMesh;
  34007. /**
  34008. * Clear the processed materials smart array preventing retention point in material dispose.
  34009. */
  34010. freeProcessedMaterials(): void;
  34011. private _preventFreeActiveMeshesAndRenderingGroups;
  34012. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34013. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34014. * when disposing several meshes in a row or a hierarchy of meshes.
  34015. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34016. */
  34017. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34018. /**
  34019. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34020. */
  34021. freeActiveMeshes(): void;
  34022. /**
  34023. * Clear the info related to rendering groups preventing retention points during dispose.
  34024. */
  34025. freeRenderingGroups(): void;
  34026. /** @hidden */
  34027. _isInIntermediateRendering(): boolean;
  34028. /**
  34029. * Lambda returning the list of potentially active meshes.
  34030. */
  34031. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34032. /**
  34033. * Lambda returning the list of potentially active sub meshes.
  34034. */
  34035. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34036. /**
  34037. * Lambda returning the list of potentially intersecting sub meshes.
  34038. */
  34039. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34040. /**
  34041. * Lambda returning the list of potentially colliding sub meshes.
  34042. */
  34043. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34044. private _activeMeshesFrozen;
  34045. /**
  34046. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34047. * @returns the current scene
  34048. */
  34049. freezeActiveMeshes(): Scene;
  34050. /**
  34051. * Use this function to restart evaluating active meshes on every frame
  34052. * @returns the current scene
  34053. */
  34054. unfreezeActiveMeshes(): Scene;
  34055. private _evaluateActiveMeshes;
  34056. private _activeMesh;
  34057. /**
  34058. * Update the transform matrix to update from the current active camera
  34059. * @param force defines a boolean used to force the update even if cache is up to date
  34060. */
  34061. updateTransformMatrix(force?: boolean): void;
  34062. private _bindFrameBuffer;
  34063. /** @hidden */
  34064. _allowPostProcessClearColor: boolean;
  34065. /** @hidden */
  34066. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34067. private _processSubCameras;
  34068. private _checkIntersections;
  34069. /** @hidden */
  34070. _advancePhysicsEngineStep(step: number): void;
  34071. /**
  34072. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34073. */
  34074. getDeterministicFrameTime: () => number;
  34075. /** @hidden */
  34076. _animate(): void;
  34077. /** Execute all animations (for a frame) */
  34078. animate(): void;
  34079. /**
  34080. * Render the scene
  34081. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34082. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34083. */
  34084. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34085. /**
  34086. * Freeze all materials
  34087. * A frozen material will not be updatable but should be faster to render
  34088. */
  34089. freezeMaterials(): void;
  34090. /**
  34091. * Unfreeze all materials
  34092. * A frozen material will not be updatable but should be faster to render
  34093. */
  34094. unfreezeMaterials(): void;
  34095. /**
  34096. * Releases all held ressources
  34097. */
  34098. dispose(): void;
  34099. /**
  34100. * Gets if the scene is already disposed
  34101. */
  34102. readonly isDisposed: boolean;
  34103. /**
  34104. * Call this function to reduce memory footprint of the scene.
  34105. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34106. */
  34107. clearCachedVertexData(): void;
  34108. /**
  34109. * This function will remove the local cached buffer data from texture.
  34110. * It will save memory but will prevent the texture from being rebuilt
  34111. */
  34112. cleanCachedTextureBuffer(): void;
  34113. /**
  34114. * Get the world extend vectors with an optional filter
  34115. *
  34116. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34117. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34118. */
  34119. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34120. min: Vector3;
  34121. max: Vector3;
  34122. };
  34123. /**
  34124. * Creates a ray that can be used to pick in the scene
  34125. * @param x defines the x coordinate of the origin (on-screen)
  34126. * @param y defines the y coordinate of the origin (on-screen)
  34127. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34128. * @param camera defines the camera to use for the picking
  34129. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34130. * @returns a Ray
  34131. */
  34132. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34133. /**
  34134. * Creates a ray that can be used to pick in the scene
  34135. * @param x defines the x coordinate of the origin (on-screen)
  34136. * @param y defines the y coordinate of the origin (on-screen)
  34137. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34138. * @param result defines the ray where to store the picking ray
  34139. * @param camera defines the camera to use for the picking
  34140. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34141. * @returns the current scene
  34142. */
  34143. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34144. /**
  34145. * Creates a ray that can be used to pick in the scene
  34146. * @param x defines the x coordinate of the origin (on-screen)
  34147. * @param y defines the y coordinate of the origin (on-screen)
  34148. * @param camera defines the camera to use for the picking
  34149. * @returns a Ray
  34150. */
  34151. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34152. /**
  34153. * Creates a ray that can be used to pick in the scene
  34154. * @param x defines the x coordinate of the origin (on-screen)
  34155. * @param y defines the y coordinate of the origin (on-screen)
  34156. * @param result defines the ray where to store the picking ray
  34157. * @param camera defines the camera to use for the picking
  34158. * @returns the current scene
  34159. */
  34160. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34161. /** Launch a ray to try to pick a mesh in the scene
  34162. * @param x position on screen
  34163. * @param y position on screen
  34164. * @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
  34165. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34166. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34167. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34168. * @returns a PickingInfo
  34169. */
  34170. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34171. /** Use the given ray to pick a mesh in the scene
  34172. * @param ray The ray to use to pick meshes
  34173. * @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
  34174. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34175. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34176. * @returns a PickingInfo
  34177. */
  34178. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34179. /**
  34180. * Launch a ray to try to pick a mesh in the scene
  34181. * @param x X position on screen
  34182. * @param y Y position on screen
  34183. * @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
  34184. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34185. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34186. * @returns an array of PickingInfo
  34187. */
  34188. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34189. /**
  34190. * Launch a ray to try to pick a mesh in the scene
  34191. * @param ray Ray to use
  34192. * @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
  34193. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34194. * @returns an array of PickingInfo
  34195. */
  34196. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34197. /**
  34198. * Force the value of meshUnderPointer
  34199. * @param mesh defines the mesh to use
  34200. */
  34201. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34202. /**
  34203. * Gets the mesh under the pointer
  34204. * @returns a Mesh or null if no mesh is under the pointer
  34205. */
  34206. getPointerOverMesh(): Nullable<AbstractMesh>;
  34207. /** @hidden */
  34208. _rebuildGeometries(): void;
  34209. /** @hidden */
  34210. _rebuildTextures(): void;
  34211. private _getByTags;
  34212. /**
  34213. * Get a list of meshes by tags
  34214. * @param tagsQuery defines the tags query to use
  34215. * @param forEach defines a predicate used to filter results
  34216. * @returns an array of Mesh
  34217. */
  34218. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34219. /**
  34220. * Get a list of cameras by tags
  34221. * @param tagsQuery defines the tags query to use
  34222. * @param forEach defines a predicate used to filter results
  34223. * @returns an array of Camera
  34224. */
  34225. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34226. /**
  34227. * Get a list of lights by tags
  34228. * @param tagsQuery defines the tags query to use
  34229. * @param forEach defines a predicate used to filter results
  34230. * @returns an array of Light
  34231. */
  34232. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34233. /**
  34234. * Get a list of materials by tags
  34235. * @param tagsQuery defines the tags query to use
  34236. * @param forEach defines a predicate used to filter results
  34237. * @returns an array of Material
  34238. */
  34239. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34240. /**
  34241. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34242. * This allowed control for front to back rendering or reversly depending of the special needs.
  34243. *
  34244. * @param renderingGroupId The rendering group id corresponding to its index
  34245. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34246. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34247. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34248. */
  34249. 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;
  34250. /**
  34251. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34252. *
  34253. * @param renderingGroupId The rendering group id corresponding to its index
  34254. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34255. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34256. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34257. */
  34258. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34259. /**
  34260. * Gets the current auto clear configuration for one rendering group of the rendering
  34261. * manager.
  34262. * @param index the rendering group index to get the information for
  34263. * @returns The auto clear setup for the requested rendering group
  34264. */
  34265. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34266. private _blockMaterialDirtyMechanism;
  34267. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34268. blockMaterialDirtyMechanism: boolean;
  34269. /**
  34270. * Will flag all materials as dirty to trigger new shader compilation
  34271. * @param flag defines the flag used to specify which material part must be marked as dirty
  34272. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34273. */
  34274. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34275. /** @hidden */
  34276. _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;
  34277. /** @hidden */
  34278. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34279. }
  34280. }
  34281. declare module "babylonjs/assetContainer" {
  34282. import { AbstractScene } from "babylonjs/abstractScene";
  34283. import { Scene } from "babylonjs/scene";
  34284. import { Mesh } from "babylonjs/Meshes/mesh";
  34285. /**
  34286. * Set of assets to keep when moving a scene into an asset container.
  34287. */
  34288. export class KeepAssets extends AbstractScene {
  34289. }
  34290. /**
  34291. * Container with a set of assets that can be added or removed from a scene.
  34292. */
  34293. export class AssetContainer extends AbstractScene {
  34294. /**
  34295. * The scene the AssetContainer belongs to.
  34296. */
  34297. scene: Scene;
  34298. /**
  34299. * Instantiates an AssetContainer.
  34300. * @param scene The scene the AssetContainer belongs to.
  34301. */
  34302. constructor(scene: Scene);
  34303. /**
  34304. * Adds all the assets from the container to the scene.
  34305. */
  34306. addAllToScene(): void;
  34307. /**
  34308. * Removes all the assets in the container from the scene
  34309. */
  34310. removeAllFromScene(): void;
  34311. /**
  34312. * Disposes all the assets in the container
  34313. */
  34314. dispose(): void;
  34315. private _moveAssets;
  34316. /**
  34317. * Removes all the assets contained in the scene and adds them to the container.
  34318. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34319. */
  34320. moveAllFromScene(keepAssets?: KeepAssets): void;
  34321. /**
  34322. * 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.
  34323. * @returns the root mesh
  34324. */
  34325. createRootMesh(): Mesh;
  34326. }
  34327. }
  34328. declare module "babylonjs/abstractScene" {
  34329. import { Scene } from "babylonjs/scene";
  34330. import { Nullable } from "babylonjs/types";
  34331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34332. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34333. import { Geometry } from "babylonjs/Meshes/geometry";
  34334. import { Skeleton } from "babylonjs/Bones/skeleton";
  34335. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34336. import { AssetContainer } from "babylonjs/assetContainer";
  34337. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34338. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34339. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34340. import { Material } from "babylonjs/Materials/material";
  34341. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34342. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34343. import { Camera } from "babylonjs/Cameras/camera";
  34344. import { Light } from "babylonjs/Lights/light";
  34345. import { Node } from "babylonjs/node";
  34346. import { Animation } from "babylonjs/Animations/animation";
  34347. /**
  34348. * Defines how the parser contract is defined.
  34349. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34350. */
  34351. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34352. /**
  34353. * Defines how the individual parser contract is defined.
  34354. * These parser can parse an individual asset
  34355. */
  34356. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34357. /**
  34358. * Base class of the scene acting as a container for the different elements composing a scene.
  34359. * This class is dynamically extended by the different components of the scene increasing
  34360. * flexibility and reducing coupling
  34361. */
  34362. export abstract class AbstractScene {
  34363. /**
  34364. * Stores the list of available parsers in the application.
  34365. */
  34366. private static _BabylonFileParsers;
  34367. /**
  34368. * Stores the list of available individual parsers in the application.
  34369. */
  34370. private static _IndividualBabylonFileParsers;
  34371. /**
  34372. * Adds a parser in the list of available ones
  34373. * @param name Defines the name of the parser
  34374. * @param parser Defines the parser to add
  34375. */
  34376. static AddParser(name: string, parser: BabylonFileParser): void;
  34377. /**
  34378. * Gets a general parser from the list of avaialble ones
  34379. * @param name Defines the name of the parser
  34380. * @returns the requested parser or null
  34381. */
  34382. static GetParser(name: string): Nullable<BabylonFileParser>;
  34383. /**
  34384. * Adds n individual parser in the list of available ones
  34385. * @param name Defines the name of the parser
  34386. * @param parser Defines the parser to add
  34387. */
  34388. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34389. /**
  34390. * Gets an individual parser from the list of avaialble ones
  34391. * @param name Defines the name of the parser
  34392. * @returns the requested parser or null
  34393. */
  34394. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34395. /**
  34396. * Parser json data and populate both a scene and its associated container object
  34397. * @param jsonData Defines the data to parse
  34398. * @param scene Defines the scene to parse the data for
  34399. * @param container Defines the container attached to the parsing sequence
  34400. * @param rootUrl Defines the root url of the data
  34401. */
  34402. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34403. /**
  34404. * Gets the list of root nodes (ie. nodes with no parent)
  34405. */
  34406. rootNodes: Node[];
  34407. /** All of the cameras added to this scene
  34408. * @see http://doc.babylonjs.com/babylon101/cameras
  34409. */
  34410. cameras: Camera[];
  34411. /**
  34412. * All of the lights added to this scene
  34413. * @see http://doc.babylonjs.com/babylon101/lights
  34414. */
  34415. lights: Light[];
  34416. /**
  34417. * All of the (abstract) meshes added to this scene
  34418. */
  34419. meshes: AbstractMesh[];
  34420. /**
  34421. * The list of skeletons added to the scene
  34422. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34423. */
  34424. skeletons: Skeleton[];
  34425. /**
  34426. * All of the particle systems added to this scene
  34427. * @see http://doc.babylonjs.com/babylon101/particles
  34428. */
  34429. particleSystems: IParticleSystem[];
  34430. /**
  34431. * Gets a list of Animations associated with the scene
  34432. */
  34433. animations: Animation[];
  34434. /**
  34435. * All of the animation groups added to this scene
  34436. * @see http://doc.babylonjs.com/how_to/group
  34437. */
  34438. animationGroups: AnimationGroup[];
  34439. /**
  34440. * All of the multi-materials added to this scene
  34441. * @see http://doc.babylonjs.com/how_to/multi_materials
  34442. */
  34443. multiMaterials: MultiMaterial[];
  34444. /**
  34445. * All of the materials added to this scene
  34446. * In the context of a Scene, it is not supposed to be modified manually.
  34447. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34448. * Note also that the order of the Material wihin the array is not significant and might change.
  34449. * @see http://doc.babylonjs.com/babylon101/materials
  34450. */
  34451. materials: Material[];
  34452. /**
  34453. * The list of morph target managers added to the scene
  34454. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34455. */
  34456. morphTargetManagers: MorphTargetManager[];
  34457. /**
  34458. * The list of geometries used in the scene.
  34459. */
  34460. geometries: Geometry[];
  34461. /**
  34462. * All of the tranform nodes added to this scene
  34463. * In the context of a Scene, it is not supposed to be modified manually.
  34464. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34465. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34466. * @see http://doc.babylonjs.com/how_to/transformnode
  34467. */
  34468. transformNodes: TransformNode[];
  34469. /**
  34470. * ActionManagers available on the scene.
  34471. */
  34472. actionManagers: AbstractActionManager[];
  34473. /**
  34474. * Textures to keep.
  34475. */
  34476. textures: BaseTexture[];
  34477. /**
  34478. * Environment texture for the scene
  34479. */
  34480. environmentTexture: Nullable<BaseTexture>;
  34481. }
  34482. }
  34483. declare module "babylonjs/Audio/sound" {
  34484. import { Observable } from "babylonjs/Misc/observable";
  34485. import { Vector3 } from "babylonjs/Maths/math";
  34486. import { Nullable } from "babylonjs/types";
  34487. import { Scene } from "babylonjs/scene";
  34488. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34489. /**
  34490. * Defines a sound that can be played in the application.
  34491. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34493. */
  34494. export class Sound {
  34495. /**
  34496. * The name of the sound in the scene.
  34497. */
  34498. name: string;
  34499. /**
  34500. * Does the sound autoplay once loaded.
  34501. */
  34502. autoplay: boolean;
  34503. /**
  34504. * Does the sound loop after it finishes playing once.
  34505. */
  34506. loop: boolean;
  34507. /**
  34508. * Does the sound use a custom attenuation curve to simulate the falloff
  34509. * happening when the source gets further away from the camera.
  34510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34511. */
  34512. useCustomAttenuation: boolean;
  34513. /**
  34514. * The sound track id this sound belongs to.
  34515. */
  34516. soundTrackId: number;
  34517. /**
  34518. * Is this sound currently played.
  34519. */
  34520. isPlaying: boolean;
  34521. /**
  34522. * Is this sound currently paused.
  34523. */
  34524. isPaused: boolean;
  34525. /**
  34526. * Does this sound enables spatial sound.
  34527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34528. */
  34529. spatialSound: boolean;
  34530. /**
  34531. * Define the reference distance the sound should be heard perfectly.
  34532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34533. */
  34534. refDistance: number;
  34535. /**
  34536. * Define the roll off factor of spatial sounds.
  34537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34538. */
  34539. rolloffFactor: number;
  34540. /**
  34541. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34543. */
  34544. maxDistance: number;
  34545. /**
  34546. * Define the distance attenuation model the sound will follow.
  34547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34548. */
  34549. distanceModel: string;
  34550. /**
  34551. * @hidden
  34552. * Back Compat
  34553. **/
  34554. onended: () => any;
  34555. /**
  34556. * Observable event when the current playing sound finishes.
  34557. */
  34558. onEndedObservable: Observable<Sound>;
  34559. private _panningModel;
  34560. private _playbackRate;
  34561. private _streaming;
  34562. private _startTime;
  34563. private _startOffset;
  34564. private _position;
  34565. /** @hidden */
  34566. _positionInEmitterSpace: boolean;
  34567. private _localDirection;
  34568. private _volume;
  34569. private _isReadyToPlay;
  34570. private _isDirectional;
  34571. private _readyToPlayCallback;
  34572. private _audioBuffer;
  34573. private _soundSource;
  34574. private _streamingSource;
  34575. private _soundPanner;
  34576. private _soundGain;
  34577. private _inputAudioNode;
  34578. private _outputAudioNode;
  34579. private _coneInnerAngle;
  34580. private _coneOuterAngle;
  34581. private _coneOuterGain;
  34582. private _scene;
  34583. private _connectedTransformNode;
  34584. private _customAttenuationFunction;
  34585. private _registerFunc;
  34586. private _isOutputConnected;
  34587. private _htmlAudioElement;
  34588. private _urlType;
  34589. /** @hidden */
  34590. static _SceneComponentInitialization: (scene: Scene) => void;
  34591. /**
  34592. * Create a sound and attach it to a scene
  34593. * @param name Name of your sound
  34594. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34595. * @param scene defines the scene the sound belongs to
  34596. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34597. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34598. */
  34599. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34600. /**
  34601. * Release the sound and its associated resources
  34602. */
  34603. dispose(): void;
  34604. /**
  34605. * Gets if the sounds is ready to be played or not.
  34606. * @returns true if ready, otherwise false
  34607. */
  34608. isReady(): boolean;
  34609. private _soundLoaded;
  34610. /**
  34611. * Sets the data of the sound from an audiobuffer
  34612. * @param audioBuffer The audioBuffer containing the data
  34613. */
  34614. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34615. /**
  34616. * Updates the current sounds options such as maxdistance, loop...
  34617. * @param options A JSON object containing values named as the object properties
  34618. */
  34619. updateOptions(options: any): void;
  34620. private _createSpatialParameters;
  34621. private _updateSpatialParameters;
  34622. /**
  34623. * Switch the panning model to HRTF:
  34624. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34626. */
  34627. switchPanningModelToHRTF(): void;
  34628. /**
  34629. * Switch the panning model to Equal Power:
  34630. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34632. */
  34633. switchPanningModelToEqualPower(): void;
  34634. private _switchPanningModel;
  34635. /**
  34636. * Connect this sound to a sound track audio node like gain...
  34637. * @param soundTrackAudioNode the sound track audio node to connect to
  34638. */
  34639. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34640. /**
  34641. * Transform this sound into a directional source
  34642. * @param coneInnerAngle Size of the inner cone in degree
  34643. * @param coneOuterAngle Size of the outer cone in degree
  34644. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34645. */
  34646. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34647. /**
  34648. * Gets or sets the inner angle for the directional cone.
  34649. */
  34650. /**
  34651. * Gets or sets the inner angle for the directional cone.
  34652. */
  34653. directionalConeInnerAngle: number;
  34654. /**
  34655. * Gets or sets the outer angle for the directional cone.
  34656. */
  34657. /**
  34658. * Gets or sets the outer angle for the directional cone.
  34659. */
  34660. directionalConeOuterAngle: number;
  34661. /**
  34662. * Sets the position of the emitter if spatial sound is enabled
  34663. * @param newPosition Defines the new posisiton
  34664. */
  34665. setPosition(newPosition: Vector3): void;
  34666. /**
  34667. * Sets the local direction of the emitter if spatial sound is enabled
  34668. * @param newLocalDirection Defines the new local direction
  34669. */
  34670. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34671. private _updateDirection;
  34672. /** @hidden */
  34673. updateDistanceFromListener(): void;
  34674. /**
  34675. * Sets a new custom attenuation function for the sound.
  34676. * @param callback Defines the function used for the attenuation
  34677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34678. */
  34679. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34680. /**
  34681. * Play the sound
  34682. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34683. * @param offset (optional) Start the sound setting it at a specific time
  34684. */
  34685. play(time?: number, offset?: number): void;
  34686. private _onended;
  34687. /**
  34688. * Stop the sound
  34689. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34690. */
  34691. stop(time?: number): void;
  34692. /**
  34693. * Put the sound in pause
  34694. */
  34695. pause(): void;
  34696. /**
  34697. * Sets a dedicated volume for this sounds
  34698. * @param newVolume Define the new volume of the sound
  34699. * @param time Define in how long the sound should be at this value
  34700. */
  34701. setVolume(newVolume: number, time?: number): void;
  34702. /**
  34703. * Set the sound play back rate
  34704. * @param newPlaybackRate Define the playback rate the sound should be played at
  34705. */
  34706. setPlaybackRate(newPlaybackRate: number): void;
  34707. /**
  34708. * Gets the volume of the sound.
  34709. * @returns the volume of the sound
  34710. */
  34711. getVolume(): number;
  34712. /**
  34713. * Attach the sound to a dedicated mesh
  34714. * @param transformNode The transform node to connect the sound with
  34715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34716. */
  34717. attachToMesh(transformNode: TransformNode): void;
  34718. /**
  34719. * Detach the sound from the previously attached mesh
  34720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34721. */
  34722. detachFromMesh(): void;
  34723. private _onRegisterAfterWorldMatrixUpdate;
  34724. /**
  34725. * Clone the current sound in the scene.
  34726. * @returns the new sound clone
  34727. */
  34728. clone(): Nullable<Sound>;
  34729. /**
  34730. * Gets the current underlying audio buffer containing the data
  34731. * @returns the audio buffer
  34732. */
  34733. getAudioBuffer(): Nullable<AudioBuffer>;
  34734. /**
  34735. * Serializes the Sound in a JSON representation
  34736. * @returns the JSON representation of the sound
  34737. */
  34738. serialize(): any;
  34739. /**
  34740. * Parse a JSON representation of a sound to innstantiate in a given scene
  34741. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34742. * @param scene Define the scene the new parsed sound should be created in
  34743. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34744. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34745. * @returns the newly parsed sound
  34746. */
  34747. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34748. }
  34749. }
  34750. declare module "babylonjs/Actions/directAudioActions" {
  34751. import { Action } from "babylonjs/Actions/action";
  34752. import { Condition } from "babylonjs/Actions/condition";
  34753. import { Sound } from "babylonjs/Audio/sound";
  34754. /**
  34755. * This defines an action helpful to play a defined sound on a triggered action.
  34756. */
  34757. export class PlaySoundAction extends Action {
  34758. private _sound;
  34759. /**
  34760. * Instantiate the action
  34761. * @param triggerOptions defines the trigger options
  34762. * @param sound defines the sound to play
  34763. * @param condition defines the trigger related conditions
  34764. */
  34765. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34766. /** @hidden */
  34767. _prepare(): void;
  34768. /**
  34769. * Execute the action and play the sound.
  34770. */
  34771. execute(): void;
  34772. /**
  34773. * Serializes the actions and its related information.
  34774. * @param parent defines the object to serialize in
  34775. * @returns the serialized object
  34776. */
  34777. serialize(parent: any): any;
  34778. }
  34779. /**
  34780. * This defines an action helpful to stop a defined sound on a triggered action.
  34781. */
  34782. export class StopSoundAction extends Action {
  34783. private _sound;
  34784. /**
  34785. * Instantiate the action
  34786. * @param triggerOptions defines the trigger options
  34787. * @param sound defines the sound to stop
  34788. * @param condition defines the trigger related conditions
  34789. */
  34790. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34791. /** @hidden */
  34792. _prepare(): void;
  34793. /**
  34794. * Execute the action and stop the sound.
  34795. */
  34796. execute(): void;
  34797. /**
  34798. * Serializes the actions and its related information.
  34799. * @param parent defines the object to serialize in
  34800. * @returns the serialized object
  34801. */
  34802. serialize(parent: any): any;
  34803. }
  34804. }
  34805. declare module "babylonjs/Actions/interpolateValueAction" {
  34806. import { Action } from "babylonjs/Actions/action";
  34807. import { Condition } from "babylonjs/Actions/condition";
  34808. import { Observable } from "babylonjs/Misc/observable";
  34809. /**
  34810. * This defines an action responsible to change the value of a property
  34811. * by interpolating between its current value and the newly set one once triggered.
  34812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34813. */
  34814. export class InterpolateValueAction extends Action {
  34815. /**
  34816. * Defines the path of the property where the value should be interpolated
  34817. */
  34818. propertyPath: string;
  34819. /**
  34820. * Defines the target value at the end of the interpolation.
  34821. */
  34822. value: any;
  34823. /**
  34824. * Defines the time it will take for the property to interpolate to the value.
  34825. */
  34826. duration: number;
  34827. /**
  34828. * Defines if the other scene animations should be stopped when the action has been triggered
  34829. */
  34830. stopOtherAnimations?: boolean;
  34831. /**
  34832. * Defines a callback raised once the interpolation animation has been done.
  34833. */
  34834. onInterpolationDone?: () => void;
  34835. /**
  34836. * Observable triggered once the interpolation animation has been done.
  34837. */
  34838. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34839. private _target;
  34840. private _effectiveTarget;
  34841. private _property;
  34842. /**
  34843. * Instantiate the action
  34844. * @param triggerOptions defines the trigger options
  34845. * @param target defines the object containing the value to interpolate
  34846. * @param propertyPath defines the path to the property in the target object
  34847. * @param value defines the target value at the end of the interpolation
  34848. * @param duration deines the time it will take for the property to interpolate to the value.
  34849. * @param condition defines the trigger related conditions
  34850. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34851. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34852. */
  34853. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34854. /** @hidden */
  34855. _prepare(): void;
  34856. /**
  34857. * Execute the action starts the value interpolation.
  34858. */
  34859. execute(): void;
  34860. /**
  34861. * Serializes the actions and its related information.
  34862. * @param parent defines the object to serialize in
  34863. * @returns the serialized object
  34864. */
  34865. serialize(parent: any): any;
  34866. }
  34867. }
  34868. declare module "babylonjs/Actions/index" {
  34869. export * from "babylonjs/Actions/action";
  34870. export * from "babylonjs/Actions/actionEvent";
  34871. export * from "babylonjs/Actions/actionManager";
  34872. export * from "babylonjs/Actions/condition";
  34873. export * from "babylonjs/Actions/directActions";
  34874. export * from "babylonjs/Actions/directAudioActions";
  34875. export * from "babylonjs/Actions/interpolateValueAction";
  34876. }
  34877. declare module "babylonjs/Animations/index" {
  34878. export * from "babylonjs/Animations/animatable";
  34879. export * from "babylonjs/Animations/animation";
  34880. export * from "babylonjs/Animations/animationGroup";
  34881. export * from "babylonjs/Animations/animationPropertiesOverride";
  34882. export * from "babylonjs/Animations/easing";
  34883. export * from "babylonjs/Animations/runtimeAnimation";
  34884. export * from "babylonjs/Animations/animationEvent";
  34885. export * from "babylonjs/Animations/animationGroup";
  34886. export * from "babylonjs/Animations/animationKey";
  34887. export * from "babylonjs/Animations/animationRange";
  34888. }
  34889. declare module "babylonjs/Audio/soundTrack" {
  34890. import { Sound } from "babylonjs/Audio/sound";
  34891. import { Analyser } from "babylonjs/Audio/analyser";
  34892. import { Scene } from "babylonjs/scene";
  34893. /**
  34894. * Options allowed during the creation of a sound track.
  34895. */
  34896. export interface ISoundTrackOptions {
  34897. /**
  34898. * The volume the sound track should take during creation
  34899. */
  34900. volume?: number;
  34901. /**
  34902. * Define if the sound track is the main sound track of the scene
  34903. */
  34904. mainTrack?: boolean;
  34905. }
  34906. /**
  34907. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34908. * It will be also used in a future release to apply effects on a specific track.
  34909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34910. */
  34911. export class SoundTrack {
  34912. /**
  34913. * The unique identifier of the sound track in the scene.
  34914. */
  34915. id: number;
  34916. /**
  34917. * The list of sounds included in the sound track.
  34918. */
  34919. soundCollection: Array<Sound>;
  34920. private _outputAudioNode;
  34921. private _scene;
  34922. private _isMainTrack;
  34923. private _connectedAnalyser;
  34924. private _options;
  34925. private _isInitialized;
  34926. /**
  34927. * Creates a new sound track.
  34928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34929. * @param scene Define the scene the sound track belongs to
  34930. * @param options
  34931. */
  34932. constructor(scene: Scene, options?: ISoundTrackOptions);
  34933. private _initializeSoundTrackAudioGraph;
  34934. /**
  34935. * Release the sound track and its associated resources
  34936. */
  34937. dispose(): void;
  34938. /**
  34939. * Adds a sound to this sound track
  34940. * @param sound define the cound to add
  34941. * @ignoreNaming
  34942. */
  34943. AddSound(sound: Sound): void;
  34944. /**
  34945. * Removes a sound to this sound track
  34946. * @param sound define the cound to remove
  34947. * @ignoreNaming
  34948. */
  34949. RemoveSound(sound: Sound): void;
  34950. /**
  34951. * Set a global volume for the full sound track.
  34952. * @param newVolume Define the new volume of the sound track
  34953. */
  34954. setVolume(newVolume: number): void;
  34955. /**
  34956. * Switch the panning model to HRTF:
  34957. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34959. */
  34960. switchPanningModelToHRTF(): void;
  34961. /**
  34962. * Switch the panning model to Equal Power:
  34963. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34965. */
  34966. switchPanningModelToEqualPower(): void;
  34967. /**
  34968. * Connect the sound track to an audio analyser allowing some amazing
  34969. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34971. * @param analyser The analyser to connect to the engine
  34972. */
  34973. connectToAnalyser(analyser: Analyser): void;
  34974. }
  34975. }
  34976. declare module "babylonjs/Audio/audioSceneComponent" {
  34977. import { Sound } from "babylonjs/Audio/sound";
  34978. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34979. import { Nullable } from "babylonjs/types";
  34980. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34981. import { Scene } from "babylonjs/scene";
  34982. import { AbstractScene } from "babylonjs/abstractScene";
  34983. module "babylonjs/abstractScene" {
  34984. interface AbstractScene {
  34985. /**
  34986. * The list of sounds used in the scene.
  34987. */
  34988. sounds: Nullable<Array<Sound>>;
  34989. }
  34990. }
  34991. module "babylonjs/scene" {
  34992. interface Scene {
  34993. /**
  34994. * @hidden
  34995. * Backing field
  34996. */
  34997. _mainSoundTrack: SoundTrack;
  34998. /**
  34999. * The main sound track played by the scene.
  35000. * It cotains your primary collection of sounds.
  35001. */
  35002. mainSoundTrack: SoundTrack;
  35003. /**
  35004. * The list of sound tracks added to the scene
  35005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35006. */
  35007. soundTracks: Nullable<Array<SoundTrack>>;
  35008. /**
  35009. * Gets a sound using a given name
  35010. * @param name defines the name to search for
  35011. * @return the found sound or null if not found at all.
  35012. */
  35013. getSoundByName(name: string): Nullable<Sound>;
  35014. /**
  35015. * Gets or sets if audio support is enabled
  35016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35017. */
  35018. audioEnabled: boolean;
  35019. /**
  35020. * Gets or sets if audio will be output to headphones
  35021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35022. */
  35023. headphone: boolean;
  35024. }
  35025. }
  35026. /**
  35027. * Defines the sound scene component responsible to manage any sounds
  35028. * in a given scene.
  35029. */
  35030. export class AudioSceneComponent implements ISceneSerializableComponent {
  35031. /**
  35032. * The component name helpfull to identify the component in the list of scene components.
  35033. */
  35034. readonly name: string;
  35035. /**
  35036. * The scene the component belongs to.
  35037. */
  35038. scene: Scene;
  35039. private _audioEnabled;
  35040. /**
  35041. * Gets whether audio is enabled or not.
  35042. * Please use related enable/disable method to switch state.
  35043. */
  35044. readonly audioEnabled: boolean;
  35045. private _headphone;
  35046. /**
  35047. * Gets whether audio is outputing to headphone or not.
  35048. * Please use the according Switch methods to change output.
  35049. */
  35050. readonly headphone: boolean;
  35051. /**
  35052. * Creates a new instance of the component for the given scene
  35053. * @param scene Defines the scene to register the component in
  35054. */
  35055. constructor(scene: Scene);
  35056. /**
  35057. * Registers the component in a given scene
  35058. */
  35059. register(): void;
  35060. /**
  35061. * Rebuilds the elements related to this component in case of
  35062. * context lost for instance.
  35063. */
  35064. rebuild(): void;
  35065. /**
  35066. * Serializes the component data to the specified json object
  35067. * @param serializationObject The object to serialize to
  35068. */
  35069. serialize(serializationObject: any): void;
  35070. /**
  35071. * Adds all the element from the container to the scene
  35072. * @param container the container holding the elements
  35073. */
  35074. addFromContainer(container: AbstractScene): void;
  35075. /**
  35076. * Removes all the elements in the container from the scene
  35077. * @param container contains the elements to remove
  35078. * @param dispose if the removed element should be disposed (default: false)
  35079. */
  35080. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35081. /**
  35082. * Disposes the component and the associated ressources.
  35083. */
  35084. dispose(): void;
  35085. /**
  35086. * Disables audio in the associated scene.
  35087. */
  35088. disableAudio(): void;
  35089. /**
  35090. * Enables audio in the associated scene.
  35091. */
  35092. enableAudio(): void;
  35093. /**
  35094. * Switch audio to headphone output.
  35095. */
  35096. switchAudioModeForHeadphones(): void;
  35097. /**
  35098. * Switch audio to normal speakers.
  35099. */
  35100. switchAudioModeForNormalSpeakers(): void;
  35101. private _afterRender;
  35102. }
  35103. }
  35104. declare module "babylonjs/Audio/weightedsound" {
  35105. import { Sound } from "babylonjs/Audio/sound";
  35106. /**
  35107. * Wraps one or more Sound objects and selects one with random weight for playback.
  35108. */
  35109. export class WeightedSound {
  35110. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35111. loop: boolean;
  35112. private _coneInnerAngle;
  35113. private _coneOuterAngle;
  35114. private _volume;
  35115. /** A Sound is currently playing. */
  35116. isPlaying: boolean;
  35117. /** A Sound is currently paused. */
  35118. isPaused: boolean;
  35119. private _sounds;
  35120. private _weights;
  35121. private _currentIndex?;
  35122. /**
  35123. * Creates a new WeightedSound from the list of sounds given.
  35124. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35125. * @param sounds Array of Sounds that will be selected from.
  35126. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35127. */
  35128. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35129. /**
  35130. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35131. */
  35132. /**
  35133. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35134. */
  35135. directionalConeInnerAngle: number;
  35136. /**
  35137. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35138. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35139. */
  35140. /**
  35141. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35142. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35143. */
  35144. directionalConeOuterAngle: number;
  35145. /**
  35146. * Playback volume.
  35147. */
  35148. /**
  35149. * Playback volume.
  35150. */
  35151. volume: number;
  35152. private _onended;
  35153. /**
  35154. * Suspend playback
  35155. */
  35156. pause(): void;
  35157. /**
  35158. * Stop playback
  35159. */
  35160. stop(): void;
  35161. /**
  35162. * Start playback.
  35163. * @param startOffset Position the clip head at a specific time in seconds.
  35164. */
  35165. play(startOffset?: number): void;
  35166. }
  35167. }
  35168. declare module "babylonjs/Audio/index" {
  35169. export * from "babylonjs/Audio/analyser";
  35170. export * from "babylonjs/Audio/audioEngine";
  35171. export * from "babylonjs/Audio/audioSceneComponent";
  35172. export * from "babylonjs/Audio/sound";
  35173. export * from "babylonjs/Audio/soundTrack";
  35174. export * from "babylonjs/Audio/weightedsound";
  35175. }
  35176. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35177. import { Behavior } from "babylonjs/Behaviors/behavior";
  35178. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35179. import { BackEase } from "babylonjs/Animations/easing";
  35180. /**
  35181. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35182. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35183. */
  35184. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35185. /**
  35186. * Gets the name of the behavior.
  35187. */
  35188. readonly name: string;
  35189. /**
  35190. * The easing function used by animations
  35191. */
  35192. static EasingFunction: BackEase;
  35193. /**
  35194. * The easing mode used by animations
  35195. */
  35196. static EasingMode: number;
  35197. /**
  35198. * The duration of the animation, in milliseconds
  35199. */
  35200. transitionDuration: number;
  35201. /**
  35202. * Length of the distance animated by the transition when lower radius is reached
  35203. */
  35204. lowerRadiusTransitionRange: number;
  35205. /**
  35206. * Length of the distance animated by the transition when upper radius is reached
  35207. */
  35208. upperRadiusTransitionRange: number;
  35209. private _autoTransitionRange;
  35210. /**
  35211. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35212. */
  35213. /**
  35214. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35215. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35216. */
  35217. autoTransitionRange: boolean;
  35218. private _attachedCamera;
  35219. private _onAfterCheckInputsObserver;
  35220. private _onMeshTargetChangedObserver;
  35221. /**
  35222. * Initializes the behavior.
  35223. */
  35224. init(): void;
  35225. /**
  35226. * Attaches the behavior to its arc rotate camera.
  35227. * @param camera Defines the camera to attach the behavior to
  35228. */
  35229. attach(camera: ArcRotateCamera): void;
  35230. /**
  35231. * Detaches the behavior from its current arc rotate camera.
  35232. */
  35233. detach(): void;
  35234. private _radiusIsAnimating;
  35235. private _radiusBounceTransition;
  35236. private _animatables;
  35237. private _cachedWheelPrecision;
  35238. /**
  35239. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35240. * @param radiusLimit The limit to check against.
  35241. * @return Bool to indicate if at limit.
  35242. */
  35243. private _isRadiusAtLimit;
  35244. /**
  35245. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35246. * @param radiusDelta The delta by which to animate to. Can be negative.
  35247. */
  35248. private _applyBoundRadiusAnimation;
  35249. /**
  35250. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35251. */
  35252. protected _clearAnimationLocks(): void;
  35253. /**
  35254. * Stops and removes all animations that have been applied to the camera
  35255. */
  35256. stopAllAnimations(): void;
  35257. }
  35258. }
  35259. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35260. import { Behavior } from "babylonjs/Behaviors/behavior";
  35261. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35262. import { ExponentialEase } from "babylonjs/Animations/easing";
  35263. import { Nullable } from "babylonjs/types";
  35264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35265. import { Vector3 } from "babylonjs/Maths/math";
  35266. /**
  35267. * 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.
  35268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35269. */
  35270. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35271. /**
  35272. * Gets the name of the behavior.
  35273. */
  35274. readonly name: string;
  35275. private _mode;
  35276. private _radiusScale;
  35277. private _positionScale;
  35278. private _defaultElevation;
  35279. private _elevationReturnTime;
  35280. private _elevationReturnWaitTime;
  35281. private _zoomStopsAnimation;
  35282. private _framingTime;
  35283. /**
  35284. * The easing function used by animations
  35285. */
  35286. static EasingFunction: ExponentialEase;
  35287. /**
  35288. * The easing mode used by animations
  35289. */
  35290. static EasingMode: number;
  35291. /**
  35292. * Sets the current mode used by the behavior
  35293. */
  35294. /**
  35295. * Gets current mode used by the behavior.
  35296. */
  35297. mode: number;
  35298. /**
  35299. * Sets the scale applied to the radius (1 by default)
  35300. */
  35301. /**
  35302. * Gets the scale applied to the radius
  35303. */
  35304. radiusScale: number;
  35305. /**
  35306. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35307. */
  35308. /**
  35309. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35310. */
  35311. positionScale: number;
  35312. /**
  35313. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35314. * behaviour is triggered, in radians.
  35315. */
  35316. /**
  35317. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35318. * behaviour is triggered, in radians.
  35319. */
  35320. defaultElevation: number;
  35321. /**
  35322. * Sets the time (in milliseconds) taken to return to the default beta position.
  35323. * Negative value indicates camera should not return to default.
  35324. */
  35325. /**
  35326. * Gets the time (in milliseconds) taken to return to the default beta position.
  35327. * Negative value indicates camera should not return to default.
  35328. */
  35329. elevationReturnTime: number;
  35330. /**
  35331. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35332. */
  35333. /**
  35334. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35335. */
  35336. elevationReturnWaitTime: number;
  35337. /**
  35338. * Sets the flag that indicates if user zooming should stop animation.
  35339. */
  35340. /**
  35341. * Gets the flag that indicates if user zooming should stop animation.
  35342. */
  35343. zoomStopsAnimation: boolean;
  35344. /**
  35345. * Sets the transition time when framing the mesh, in milliseconds
  35346. */
  35347. /**
  35348. * Gets the transition time when framing the mesh, in milliseconds
  35349. */
  35350. framingTime: number;
  35351. /**
  35352. * Define if the behavior should automatically change the configured
  35353. * camera limits and sensibilities.
  35354. */
  35355. autoCorrectCameraLimitsAndSensibility: boolean;
  35356. private _onPrePointerObservableObserver;
  35357. private _onAfterCheckInputsObserver;
  35358. private _onMeshTargetChangedObserver;
  35359. private _attachedCamera;
  35360. private _isPointerDown;
  35361. private _lastInteractionTime;
  35362. /**
  35363. * Initializes the behavior.
  35364. */
  35365. init(): void;
  35366. /**
  35367. * Attaches the behavior to its arc rotate camera.
  35368. * @param camera Defines the camera to attach the behavior to
  35369. */
  35370. attach(camera: ArcRotateCamera): void;
  35371. /**
  35372. * Detaches the behavior from its current arc rotate camera.
  35373. */
  35374. detach(): void;
  35375. private _animatables;
  35376. private _betaIsAnimating;
  35377. private _betaTransition;
  35378. private _radiusTransition;
  35379. private _vectorTransition;
  35380. /**
  35381. * Targets the given mesh and updates zoom level accordingly.
  35382. * @param mesh The mesh to target.
  35383. * @param radius Optional. If a cached radius position already exists, overrides default.
  35384. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35385. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35386. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35387. */
  35388. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35389. /**
  35390. * Targets the given mesh with its children and updates zoom level accordingly.
  35391. * @param mesh The mesh to target.
  35392. * @param radius Optional. If a cached radius position already exists, overrides default.
  35393. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35394. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35395. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35396. */
  35397. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35398. /**
  35399. * Targets the given meshes with their children and updates zoom level accordingly.
  35400. * @param meshes The mesh to target.
  35401. * @param radius Optional. If a cached radius position already exists, overrides default.
  35402. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35403. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35404. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35405. */
  35406. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35407. /**
  35408. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35409. * @param minimumWorld Determines the smaller position of the bounding box extend
  35410. * @param maximumWorld Determines the bigger position of the bounding box extend
  35411. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35412. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35413. */
  35414. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35415. /**
  35416. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35417. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35418. * frustum width.
  35419. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35420. * to fully enclose the mesh in the viewing frustum.
  35421. */
  35422. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35423. /**
  35424. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35425. * is automatically returned to its default position (expected to be above ground plane).
  35426. */
  35427. private _maintainCameraAboveGround;
  35428. /**
  35429. * Returns the frustum slope based on the canvas ratio and camera FOV
  35430. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35431. */
  35432. private _getFrustumSlope;
  35433. /**
  35434. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35435. */
  35436. private _clearAnimationLocks;
  35437. /**
  35438. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35439. */
  35440. private _applyUserInteraction;
  35441. /**
  35442. * Stops and removes all animations that have been applied to the camera
  35443. */
  35444. stopAllAnimations(): void;
  35445. /**
  35446. * Gets a value indicating if the user is moving the camera
  35447. */
  35448. readonly isUserIsMoving: boolean;
  35449. /**
  35450. * The camera can move all the way towards the mesh.
  35451. */
  35452. static IgnoreBoundsSizeMode: number;
  35453. /**
  35454. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35455. */
  35456. static FitFrustumSidesMode: number;
  35457. }
  35458. }
  35459. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35460. import { Nullable } from "babylonjs/types";
  35461. import { Camera } from "babylonjs/Cameras/camera";
  35462. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35463. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35464. /**
  35465. * Base class for Camera Pointer Inputs.
  35466. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35467. * for example usage.
  35468. */
  35469. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35470. /**
  35471. * Defines the camera the input is attached to.
  35472. */
  35473. abstract camera: Camera;
  35474. /**
  35475. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35476. */
  35477. protected _altKey: boolean;
  35478. protected _ctrlKey: boolean;
  35479. protected _metaKey: boolean;
  35480. protected _shiftKey: boolean;
  35481. /**
  35482. * Which mouse buttons were pressed at time of last mouse event.
  35483. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35484. */
  35485. protected _buttonsPressed: number;
  35486. /**
  35487. * Defines the buttons associated with the input to handle camera move.
  35488. */
  35489. buttons: number[];
  35490. /**
  35491. * Attach the input controls to a specific dom element to get the input from.
  35492. * @param element Defines the element the controls should be listened from
  35493. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35494. */
  35495. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35496. /**
  35497. * Detach the current controls from the specified dom element.
  35498. * @param element Defines the element to stop listening the inputs from
  35499. */
  35500. detachControl(element: Nullable<HTMLElement>): void;
  35501. /**
  35502. * Gets the class name of the current input.
  35503. * @returns the class name
  35504. */
  35505. getClassName(): string;
  35506. /**
  35507. * Get the friendly name associated with the input class.
  35508. * @returns the input friendly name
  35509. */
  35510. getSimpleName(): string;
  35511. /**
  35512. * Called on pointer POINTERDOUBLETAP event.
  35513. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35514. */
  35515. protected onDoubleTap(type: string): void;
  35516. /**
  35517. * Called on pointer POINTERMOVE event if only a single touch is active.
  35518. * Override this method to provide functionality.
  35519. */
  35520. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35521. /**
  35522. * Called on pointer POINTERMOVE event if multiple touches are active.
  35523. * Override this method to provide functionality.
  35524. */
  35525. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35526. /**
  35527. * Called on JS contextmenu event.
  35528. * Override this method to provide functionality.
  35529. */
  35530. protected onContextMenu(evt: PointerEvent): void;
  35531. /**
  35532. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35533. * press.
  35534. * Override this method to provide functionality.
  35535. */
  35536. protected onButtonDown(evt: PointerEvent): void;
  35537. /**
  35538. * Called each time a new POINTERUP event occurs. Ie, for each button
  35539. * release.
  35540. * Override this method to provide functionality.
  35541. */
  35542. protected onButtonUp(evt: PointerEvent): void;
  35543. /**
  35544. * Called when window becomes inactive.
  35545. * Override this method to provide functionality.
  35546. */
  35547. protected onLostFocus(): void;
  35548. private _pointerInput;
  35549. private _observer;
  35550. private _onLostFocus;
  35551. private pointA;
  35552. private pointB;
  35553. }
  35554. }
  35555. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35556. import { Nullable } from "babylonjs/types";
  35557. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35558. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35559. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35560. /**
  35561. * Manage the pointers inputs to control an arc rotate camera.
  35562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35563. */
  35564. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35565. /**
  35566. * Defines the camera the input is attached to.
  35567. */
  35568. camera: ArcRotateCamera;
  35569. /**
  35570. * Gets the class name of the current input.
  35571. * @returns the class name
  35572. */
  35573. getClassName(): string;
  35574. /**
  35575. * Defines the buttons associated with the input to handle camera move.
  35576. */
  35577. buttons: number[];
  35578. /**
  35579. * Defines the pointer angular sensibility along the X axis or how fast is
  35580. * the camera rotating.
  35581. */
  35582. angularSensibilityX: number;
  35583. /**
  35584. * Defines the pointer angular sensibility along the Y axis or how fast is
  35585. * the camera rotating.
  35586. */
  35587. angularSensibilityY: number;
  35588. /**
  35589. * Defines the pointer pinch precision or how fast is the camera zooming.
  35590. */
  35591. pinchPrecision: number;
  35592. /**
  35593. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35594. * from 0.
  35595. * It defines the percentage of current camera.radius to use as delta when
  35596. * pinch zoom is used.
  35597. */
  35598. pinchDeltaPercentage: number;
  35599. /**
  35600. * Defines the pointer panning sensibility or how fast is the camera moving.
  35601. */
  35602. panningSensibility: number;
  35603. /**
  35604. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35605. */
  35606. multiTouchPanning: boolean;
  35607. /**
  35608. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35609. * zoom (pinch) through multitouch.
  35610. */
  35611. multiTouchPanAndZoom: boolean;
  35612. /**
  35613. * Revers pinch action direction.
  35614. */
  35615. pinchInwards: boolean;
  35616. private _isPanClick;
  35617. private _twoFingerActivityCount;
  35618. private _isPinching;
  35619. /**
  35620. * Called on pointer POINTERMOVE event if only a single touch is active.
  35621. */
  35622. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35623. /**
  35624. * Called on pointer POINTERDOUBLETAP event.
  35625. */
  35626. protected onDoubleTap(type: string): void;
  35627. /**
  35628. * Called on pointer POINTERMOVE event if multiple touches are active.
  35629. */
  35630. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35631. /**
  35632. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35633. * press.
  35634. */
  35635. protected onButtonDown(evt: PointerEvent): void;
  35636. /**
  35637. * Called each time a new POINTERUP event occurs. Ie, for each button
  35638. * release.
  35639. */
  35640. protected onButtonUp(evt: PointerEvent): void;
  35641. /**
  35642. * Called when window becomes inactive.
  35643. */
  35644. protected onLostFocus(): void;
  35645. }
  35646. }
  35647. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35648. import { Nullable } from "babylonjs/types";
  35649. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35650. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35651. /**
  35652. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35654. */
  35655. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35656. /**
  35657. * Defines the camera the input is attached to.
  35658. */
  35659. camera: ArcRotateCamera;
  35660. /**
  35661. * Defines the list of key codes associated with the up action (increase alpha)
  35662. */
  35663. keysUp: number[];
  35664. /**
  35665. * Defines the list of key codes associated with the down action (decrease alpha)
  35666. */
  35667. keysDown: number[];
  35668. /**
  35669. * Defines the list of key codes associated with the left action (increase beta)
  35670. */
  35671. keysLeft: number[];
  35672. /**
  35673. * Defines the list of key codes associated with the right action (decrease beta)
  35674. */
  35675. keysRight: number[];
  35676. /**
  35677. * Defines the list of key codes associated with the reset action.
  35678. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35679. */
  35680. keysReset: number[];
  35681. /**
  35682. * Defines the panning sensibility of the inputs.
  35683. * (How fast is the camera paning)
  35684. */
  35685. panningSensibility: number;
  35686. /**
  35687. * Defines the zooming sensibility of the inputs.
  35688. * (How fast is the camera zooming)
  35689. */
  35690. zoomingSensibility: number;
  35691. /**
  35692. * Defines wether maintaining the alt key down switch the movement mode from
  35693. * orientation to zoom.
  35694. */
  35695. useAltToZoom: boolean;
  35696. /**
  35697. * Rotation speed of the camera
  35698. */
  35699. angularSpeed: number;
  35700. private _keys;
  35701. private _ctrlPressed;
  35702. private _altPressed;
  35703. private _onCanvasBlurObserver;
  35704. private _onKeyboardObserver;
  35705. private _engine;
  35706. private _scene;
  35707. /**
  35708. * Attach the input controls to a specific dom element to get the input from.
  35709. * @param element Defines the element the controls should be listened from
  35710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35711. */
  35712. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35713. /**
  35714. * Detach the current controls from the specified dom element.
  35715. * @param element Defines the element to stop listening the inputs from
  35716. */
  35717. detachControl(element: Nullable<HTMLElement>): void;
  35718. /**
  35719. * Update the current camera state depending on the inputs that have been used this frame.
  35720. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35721. */
  35722. checkInputs(): void;
  35723. /**
  35724. * Gets the class name of the current intput.
  35725. * @returns the class name
  35726. */
  35727. getClassName(): string;
  35728. /**
  35729. * Get the friendly name associated with the input class.
  35730. * @returns the input friendly name
  35731. */
  35732. getSimpleName(): string;
  35733. }
  35734. }
  35735. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35736. import { Nullable } from "babylonjs/types";
  35737. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35738. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35739. /**
  35740. * Manage the mouse wheel inputs to control an arc rotate camera.
  35741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35742. */
  35743. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35744. /**
  35745. * Defines the camera the input is attached to.
  35746. */
  35747. camera: ArcRotateCamera;
  35748. /**
  35749. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35750. */
  35751. wheelPrecision: number;
  35752. /**
  35753. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35754. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35755. */
  35756. wheelDeltaPercentage: number;
  35757. private _wheel;
  35758. private _observer;
  35759. /**
  35760. * Attach the input controls to a specific dom element to get the input from.
  35761. * @param element Defines the element the controls should be listened from
  35762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35763. */
  35764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35765. /**
  35766. * Detach the current controls from the specified dom element.
  35767. * @param element Defines the element to stop listening the inputs from
  35768. */
  35769. detachControl(element: Nullable<HTMLElement>): void;
  35770. /**
  35771. * Gets the class name of the current intput.
  35772. * @returns the class name
  35773. */
  35774. getClassName(): string;
  35775. /**
  35776. * Get the friendly name associated with the input class.
  35777. * @returns the input friendly name
  35778. */
  35779. getSimpleName(): string;
  35780. }
  35781. }
  35782. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35783. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35784. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35785. /**
  35786. * Default Inputs manager for the ArcRotateCamera.
  35787. * It groups all the default supported inputs for ease of use.
  35788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35789. */
  35790. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35791. /**
  35792. * Instantiates a new ArcRotateCameraInputsManager.
  35793. * @param camera Defines the camera the inputs belong to
  35794. */
  35795. constructor(camera: ArcRotateCamera);
  35796. /**
  35797. * Add mouse wheel input support to the input manager.
  35798. * @returns the current input manager
  35799. */
  35800. addMouseWheel(): ArcRotateCameraInputsManager;
  35801. /**
  35802. * Add pointers input support to the input manager.
  35803. * @returns the current input manager
  35804. */
  35805. addPointers(): ArcRotateCameraInputsManager;
  35806. /**
  35807. * Add keyboard input support to the input manager.
  35808. * @returns the current input manager
  35809. */
  35810. addKeyboard(): ArcRotateCameraInputsManager;
  35811. }
  35812. }
  35813. declare module "babylonjs/Cameras/arcRotateCamera" {
  35814. import { Observable } from "babylonjs/Misc/observable";
  35815. import { Nullable } from "babylonjs/types";
  35816. import { Scene } from "babylonjs/scene";
  35817. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35819. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35820. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35821. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35822. import { Camera } from "babylonjs/Cameras/camera";
  35823. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35824. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35825. import { Collider } from "babylonjs/Collisions/collider";
  35826. /**
  35827. * This represents an orbital type of camera.
  35828. *
  35829. * 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.
  35830. * 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.
  35831. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35832. */
  35833. export class ArcRotateCamera extends TargetCamera {
  35834. /**
  35835. * Defines the rotation angle of the camera along the longitudinal axis.
  35836. */
  35837. alpha: number;
  35838. /**
  35839. * Defines the rotation angle of the camera along the latitudinal axis.
  35840. */
  35841. beta: number;
  35842. /**
  35843. * Defines the radius of the camera from it s target point.
  35844. */
  35845. radius: number;
  35846. protected _target: Vector3;
  35847. protected _targetHost: Nullable<AbstractMesh>;
  35848. /**
  35849. * Defines the target point of the camera.
  35850. * The camera looks towards it form the radius distance.
  35851. */
  35852. target: Vector3;
  35853. /**
  35854. * Define the current local position of the camera in the scene
  35855. */
  35856. position: Vector3;
  35857. protected _upVector: Vector3;
  35858. protected _upToYMatrix: Matrix;
  35859. protected _YToUpMatrix: Matrix;
  35860. /**
  35861. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35862. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35863. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35864. */
  35865. upVector: Vector3;
  35866. /**
  35867. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35868. */
  35869. setMatUp(): void;
  35870. /**
  35871. * Current inertia value on the longitudinal axis.
  35872. * The bigger this number the longer it will take for the camera to stop.
  35873. */
  35874. inertialAlphaOffset: number;
  35875. /**
  35876. * Current inertia value on the latitudinal axis.
  35877. * The bigger this number the longer it will take for the camera to stop.
  35878. */
  35879. inertialBetaOffset: number;
  35880. /**
  35881. * Current inertia value on the radius axis.
  35882. * The bigger this number the longer it will take for the camera to stop.
  35883. */
  35884. inertialRadiusOffset: number;
  35885. /**
  35886. * Minimum allowed angle on the longitudinal axis.
  35887. * This can help limiting how the Camera is able to move in the scene.
  35888. */
  35889. lowerAlphaLimit: Nullable<number>;
  35890. /**
  35891. * Maximum allowed angle on the longitudinal axis.
  35892. * This can help limiting how the Camera is able to move in the scene.
  35893. */
  35894. upperAlphaLimit: Nullable<number>;
  35895. /**
  35896. * Minimum allowed angle on the latitudinal axis.
  35897. * This can help limiting how the Camera is able to move in the scene.
  35898. */
  35899. lowerBetaLimit: number;
  35900. /**
  35901. * Maximum allowed angle on the latitudinal axis.
  35902. * This can help limiting how the Camera is able to move in the scene.
  35903. */
  35904. upperBetaLimit: number;
  35905. /**
  35906. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35907. * This can help limiting how the Camera is able to move in the scene.
  35908. */
  35909. lowerRadiusLimit: Nullable<number>;
  35910. /**
  35911. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35912. * This can help limiting how the Camera is able to move in the scene.
  35913. */
  35914. upperRadiusLimit: Nullable<number>;
  35915. /**
  35916. * Defines the current inertia value used during panning of the camera along the X axis.
  35917. */
  35918. inertialPanningX: number;
  35919. /**
  35920. * Defines the current inertia value used during panning of the camera along the Y axis.
  35921. */
  35922. inertialPanningY: number;
  35923. /**
  35924. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35925. * Basically if your fingers moves away from more than this distance you will be considered
  35926. * in pinch mode.
  35927. */
  35928. pinchToPanMaxDistance: number;
  35929. /**
  35930. * Defines the maximum distance the camera can pan.
  35931. * This could help keeping the cammera always in your scene.
  35932. */
  35933. panningDistanceLimit: Nullable<number>;
  35934. /**
  35935. * Defines the target of the camera before paning.
  35936. */
  35937. panningOriginTarget: Vector3;
  35938. /**
  35939. * Defines the value of the inertia used during panning.
  35940. * 0 would mean stop inertia and one would mean no decelleration at all.
  35941. */
  35942. panningInertia: number;
  35943. /**
  35944. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35945. */
  35946. angularSensibilityX: number;
  35947. /**
  35948. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35949. */
  35950. angularSensibilityY: number;
  35951. /**
  35952. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35953. */
  35954. pinchPrecision: number;
  35955. /**
  35956. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35957. * It will be used instead of pinchDeltaPrecision if different from 0.
  35958. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35959. */
  35960. pinchDeltaPercentage: number;
  35961. /**
  35962. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35963. */
  35964. panningSensibility: number;
  35965. /**
  35966. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35967. */
  35968. keysUp: number[];
  35969. /**
  35970. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35971. */
  35972. keysDown: number[];
  35973. /**
  35974. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35975. */
  35976. keysLeft: number[];
  35977. /**
  35978. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35979. */
  35980. keysRight: number[];
  35981. /**
  35982. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35983. */
  35984. wheelPrecision: number;
  35985. /**
  35986. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35987. * It will be used instead of pinchDeltaPrecision if different from 0.
  35988. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35989. */
  35990. wheelDeltaPercentage: number;
  35991. /**
  35992. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35993. */
  35994. zoomOnFactor: number;
  35995. /**
  35996. * Defines a screen offset for the camera position.
  35997. */
  35998. targetScreenOffset: Vector2;
  35999. /**
  36000. * Allows the camera to be completely reversed.
  36001. * If false the camera can not arrive upside down.
  36002. */
  36003. allowUpsideDown: boolean;
  36004. /**
  36005. * Define if double tap/click is used to restore the previously saved state of the camera.
  36006. */
  36007. useInputToRestoreState: boolean;
  36008. /** @hidden */
  36009. _viewMatrix: Matrix;
  36010. /** @hidden */
  36011. _useCtrlForPanning: boolean;
  36012. /** @hidden */
  36013. _panningMouseButton: number;
  36014. /**
  36015. * Defines the input associated to the camera.
  36016. */
  36017. inputs: ArcRotateCameraInputsManager;
  36018. /** @hidden */
  36019. _reset: () => void;
  36020. /**
  36021. * Defines the allowed panning axis.
  36022. */
  36023. panningAxis: Vector3;
  36024. protected _localDirection: Vector3;
  36025. protected _transformedDirection: Vector3;
  36026. private _bouncingBehavior;
  36027. /**
  36028. * Gets the bouncing behavior of the camera if it has been enabled.
  36029. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36030. */
  36031. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36032. /**
  36033. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36034. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36035. */
  36036. useBouncingBehavior: boolean;
  36037. private _framingBehavior;
  36038. /**
  36039. * Gets the framing behavior of the camera if it has been enabled.
  36040. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36041. */
  36042. readonly framingBehavior: Nullable<FramingBehavior>;
  36043. /**
  36044. * Defines if the framing behavior of the camera is enabled on the camera.
  36045. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36046. */
  36047. useFramingBehavior: boolean;
  36048. private _autoRotationBehavior;
  36049. /**
  36050. * Gets the auto rotation behavior of the camera if it has been enabled.
  36051. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36052. */
  36053. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36054. /**
  36055. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36056. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36057. */
  36058. useAutoRotationBehavior: boolean;
  36059. /**
  36060. * Observable triggered when the mesh target has been changed on the camera.
  36061. */
  36062. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36063. /**
  36064. * Event raised when the camera is colliding with a mesh.
  36065. */
  36066. onCollide: (collidedMesh: AbstractMesh) => void;
  36067. /**
  36068. * Defines whether the camera should check collision with the objects oh the scene.
  36069. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36070. */
  36071. checkCollisions: boolean;
  36072. /**
  36073. * Defines the collision radius of the camera.
  36074. * This simulates a sphere around the camera.
  36075. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36076. */
  36077. collisionRadius: Vector3;
  36078. protected _collider: Collider;
  36079. protected _previousPosition: Vector3;
  36080. protected _collisionVelocity: Vector3;
  36081. protected _newPosition: Vector3;
  36082. protected _previousAlpha: number;
  36083. protected _previousBeta: number;
  36084. protected _previousRadius: number;
  36085. protected _collisionTriggered: boolean;
  36086. protected _targetBoundingCenter: Nullable<Vector3>;
  36087. private _computationVector;
  36088. /**
  36089. * Instantiates a new ArcRotateCamera in a given scene
  36090. * @param name Defines the name of the camera
  36091. * @param alpha Defines the camera rotation along the logitudinal axis
  36092. * @param beta Defines the camera rotation along the latitudinal axis
  36093. * @param radius Defines the camera distance from its target
  36094. * @param target Defines the camera target
  36095. * @param scene Defines the scene the camera belongs to
  36096. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36097. */
  36098. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36099. /** @hidden */
  36100. _initCache(): void;
  36101. /** @hidden */
  36102. _updateCache(ignoreParentClass?: boolean): void;
  36103. protected _getTargetPosition(): Vector3;
  36104. private _storedAlpha;
  36105. private _storedBeta;
  36106. private _storedRadius;
  36107. private _storedTarget;
  36108. /**
  36109. * Stores the current state of the camera (alpha, beta, radius and target)
  36110. * @returns the camera itself
  36111. */
  36112. storeState(): Camera;
  36113. /**
  36114. * @hidden
  36115. * Restored camera state. You must call storeState() first
  36116. */
  36117. _restoreStateValues(): boolean;
  36118. /** @hidden */
  36119. _isSynchronizedViewMatrix(): boolean;
  36120. /**
  36121. * Attached controls to the current camera.
  36122. * @param element Defines the element the controls should be listened from
  36123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36124. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36125. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36126. */
  36127. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36128. /**
  36129. * Detach the current controls from the camera.
  36130. * The camera will stop reacting to inputs.
  36131. * @param element Defines the element to stop listening the inputs from
  36132. */
  36133. detachControl(element: HTMLElement): void;
  36134. /** @hidden */
  36135. _checkInputs(): void;
  36136. protected _checkLimits(): void;
  36137. /**
  36138. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36139. */
  36140. rebuildAnglesAndRadius(): void;
  36141. /**
  36142. * Use a position to define the current camera related information like aplha, beta and radius
  36143. * @param position Defines the position to set the camera at
  36144. */
  36145. setPosition(position: Vector3): void;
  36146. /**
  36147. * Defines the target the camera should look at.
  36148. * This will automatically adapt alpha beta and radius to fit within the new target.
  36149. * @param target Defines the new target as a Vector or a mesh
  36150. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36151. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36152. */
  36153. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36154. /** @hidden */
  36155. _getViewMatrix(): Matrix;
  36156. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36157. /**
  36158. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36159. * @param meshes Defines the mesh to zoom on
  36160. * @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)
  36161. */
  36162. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36163. /**
  36164. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36165. * The target will be changed but the radius
  36166. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36167. * @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)
  36168. */
  36169. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36170. min: Vector3;
  36171. max: Vector3;
  36172. distance: number;
  36173. }, doNotUpdateMaxZ?: boolean): void;
  36174. /**
  36175. * @override
  36176. * Override Camera.createRigCamera
  36177. */
  36178. createRigCamera(name: string, cameraIndex: number): Camera;
  36179. /**
  36180. * @hidden
  36181. * @override
  36182. * Override Camera._updateRigCameras
  36183. */
  36184. _updateRigCameras(): void;
  36185. /**
  36186. * Destroy the camera and release the current resources hold by it.
  36187. */
  36188. dispose(): void;
  36189. /**
  36190. * Gets the current object class name.
  36191. * @return the class name
  36192. */
  36193. getClassName(): string;
  36194. }
  36195. }
  36196. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36197. import { Behavior } from "babylonjs/Behaviors/behavior";
  36198. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36199. /**
  36200. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36201. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36202. */
  36203. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36204. /**
  36205. * Gets the name of the behavior.
  36206. */
  36207. readonly name: string;
  36208. private _zoomStopsAnimation;
  36209. private _idleRotationSpeed;
  36210. private _idleRotationWaitTime;
  36211. private _idleRotationSpinupTime;
  36212. /**
  36213. * Sets the flag that indicates if user zooming should stop animation.
  36214. */
  36215. /**
  36216. * Gets the flag that indicates if user zooming should stop animation.
  36217. */
  36218. zoomStopsAnimation: boolean;
  36219. /**
  36220. * Sets the default speed at which the camera rotates around the model.
  36221. */
  36222. /**
  36223. * Gets the default speed at which the camera rotates around the model.
  36224. */
  36225. idleRotationSpeed: number;
  36226. /**
  36227. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36228. */
  36229. /**
  36230. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36231. */
  36232. idleRotationWaitTime: number;
  36233. /**
  36234. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36235. */
  36236. /**
  36237. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36238. */
  36239. idleRotationSpinupTime: number;
  36240. /**
  36241. * Gets a value indicating if the camera is currently rotating because of this behavior
  36242. */
  36243. readonly rotationInProgress: boolean;
  36244. private _onPrePointerObservableObserver;
  36245. private _onAfterCheckInputsObserver;
  36246. private _attachedCamera;
  36247. private _isPointerDown;
  36248. private _lastFrameTime;
  36249. private _lastInteractionTime;
  36250. private _cameraRotationSpeed;
  36251. /**
  36252. * Initializes the behavior.
  36253. */
  36254. init(): void;
  36255. /**
  36256. * Attaches the behavior to its arc rotate camera.
  36257. * @param camera Defines the camera to attach the behavior to
  36258. */
  36259. attach(camera: ArcRotateCamera): void;
  36260. /**
  36261. * Detaches the behavior from its current arc rotate camera.
  36262. */
  36263. detach(): void;
  36264. /**
  36265. * Returns true if user is scrolling.
  36266. * @return true if user is scrolling.
  36267. */
  36268. private _userIsZooming;
  36269. private _lastFrameRadius;
  36270. private _shouldAnimationStopForInteraction;
  36271. /**
  36272. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36273. */
  36274. private _applyUserInteraction;
  36275. private _userIsMoving;
  36276. }
  36277. }
  36278. declare module "babylonjs/Behaviors/Cameras/index" {
  36279. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36280. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36281. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36282. }
  36283. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36284. import { Mesh } from "babylonjs/Meshes/mesh";
  36285. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36286. import { Behavior } from "babylonjs/Behaviors/behavior";
  36287. /**
  36288. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36289. */
  36290. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36291. private ui;
  36292. /**
  36293. * The name of the behavior
  36294. */
  36295. name: string;
  36296. /**
  36297. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36298. */
  36299. distanceAwayFromFace: number;
  36300. /**
  36301. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36302. */
  36303. distanceAwayFromBottomOfFace: number;
  36304. private _faceVectors;
  36305. private _target;
  36306. private _scene;
  36307. private _onRenderObserver;
  36308. private _tmpMatrix;
  36309. private _tmpVector;
  36310. /**
  36311. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36312. * @param ui The transform node that should be attched to the mesh
  36313. */
  36314. constructor(ui: TransformNode);
  36315. /**
  36316. * Initializes the behavior
  36317. */
  36318. init(): void;
  36319. private _closestFace;
  36320. private _zeroVector;
  36321. private _lookAtTmpMatrix;
  36322. private _lookAtToRef;
  36323. /**
  36324. * Attaches the AttachToBoxBehavior to the passed in mesh
  36325. * @param target The mesh that the specified node will be attached to
  36326. */
  36327. attach(target: Mesh): void;
  36328. /**
  36329. * Detaches the behavior from the mesh
  36330. */
  36331. detach(): void;
  36332. }
  36333. }
  36334. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36335. import { Behavior } from "babylonjs/Behaviors/behavior";
  36336. import { Mesh } from "babylonjs/Meshes/mesh";
  36337. /**
  36338. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36339. */
  36340. export class FadeInOutBehavior implements Behavior<Mesh> {
  36341. /**
  36342. * Time in milliseconds to delay before fading in (Default: 0)
  36343. */
  36344. delay: number;
  36345. /**
  36346. * Time in milliseconds for the mesh to fade in (Default: 300)
  36347. */
  36348. fadeInTime: number;
  36349. private _millisecondsPerFrame;
  36350. private _hovered;
  36351. private _hoverValue;
  36352. private _ownerNode;
  36353. /**
  36354. * Instatiates the FadeInOutBehavior
  36355. */
  36356. constructor();
  36357. /**
  36358. * The name of the behavior
  36359. */
  36360. readonly name: string;
  36361. /**
  36362. * Initializes the behavior
  36363. */
  36364. init(): void;
  36365. /**
  36366. * Attaches the fade behavior on the passed in mesh
  36367. * @param ownerNode The mesh that will be faded in/out once attached
  36368. */
  36369. attach(ownerNode: Mesh): void;
  36370. /**
  36371. * Detaches the behavior from the mesh
  36372. */
  36373. detach(): void;
  36374. /**
  36375. * Triggers the mesh to begin fading in or out
  36376. * @param value if the object should fade in or out (true to fade in)
  36377. */
  36378. fadeIn(value: boolean): void;
  36379. private _update;
  36380. private _setAllVisibility;
  36381. }
  36382. }
  36383. declare module "babylonjs/Misc/pivotTools" {
  36384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36385. /**
  36386. * Class containing a set of static utilities functions for managing Pivots
  36387. * @hidden
  36388. */
  36389. export class PivotTools {
  36390. private static _PivotCached;
  36391. private static _OldPivotPoint;
  36392. private static _PivotTranslation;
  36393. private static _PivotTmpVector;
  36394. /** @hidden */
  36395. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36396. /** @hidden */
  36397. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36398. }
  36399. }
  36400. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36401. import { Scene } from "babylonjs/scene";
  36402. import { Vector4, Plane } from "babylonjs/Maths/math";
  36403. import { Mesh } from "babylonjs/Meshes/mesh";
  36404. import { Nullable } from "babylonjs/types";
  36405. /**
  36406. * Class containing static functions to help procedurally build meshes
  36407. */
  36408. export class PlaneBuilder {
  36409. /**
  36410. * Creates a plane mesh
  36411. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36412. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36413. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36417. * @param name defines the name of the mesh
  36418. * @param options defines the options used to create the mesh
  36419. * @param scene defines the hosting scene
  36420. * @returns the plane mesh
  36421. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36422. */
  36423. static CreatePlane(name: string, options: {
  36424. size?: number;
  36425. width?: number;
  36426. height?: number;
  36427. sideOrientation?: number;
  36428. frontUVs?: Vector4;
  36429. backUVs?: Vector4;
  36430. updatable?: boolean;
  36431. sourcePlane?: Plane;
  36432. }, scene?: Nullable<Scene>): Mesh;
  36433. }
  36434. }
  36435. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36436. import { Behavior } from "babylonjs/Behaviors/behavior";
  36437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36438. import { Observable } from "babylonjs/Misc/observable";
  36439. import { Vector3 } from "babylonjs/Maths/math";
  36440. import { Ray } from "babylonjs/Culling/ray";
  36441. import "babylonjs/Meshes/Builders/planeBuilder";
  36442. /**
  36443. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36444. */
  36445. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36446. private static _AnyMouseID;
  36447. private _attachedNode;
  36448. private _dragPlane;
  36449. private _scene;
  36450. private _pointerObserver;
  36451. private _beforeRenderObserver;
  36452. private static _planeScene;
  36453. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36454. /**
  36455. * 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)
  36456. */
  36457. maxDragAngle: number;
  36458. /**
  36459. * @hidden
  36460. */
  36461. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36462. /**
  36463. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36464. */
  36465. currentDraggingPointerID: number;
  36466. /**
  36467. * The last position where the pointer hit the drag plane in world space
  36468. */
  36469. lastDragPosition: Vector3;
  36470. /**
  36471. * If the behavior is currently in a dragging state
  36472. */
  36473. dragging: boolean;
  36474. /**
  36475. * 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)
  36476. */
  36477. dragDeltaRatio: number;
  36478. /**
  36479. * If the drag plane orientation should be updated during the dragging (Default: true)
  36480. */
  36481. updateDragPlane: boolean;
  36482. private _debugMode;
  36483. private _moving;
  36484. /**
  36485. * Fires each time the attached mesh is dragged with the pointer
  36486. * * delta between last drag position and current drag position in world space
  36487. * * dragDistance along the drag axis
  36488. * * dragPlaneNormal normal of the current drag plane used during the drag
  36489. * * dragPlanePoint in world space where the drag intersects the drag plane
  36490. */
  36491. onDragObservable: Observable<{
  36492. delta: Vector3;
  36493. dragPlanePoint: Vector3;
  36494. dragPlaneNormal: Vector3;
  36495. dragDistance: number;
  36496. pointerId: number;
  36497. }>;
  36498. /**
  36499. * Fires each time a drag begins (eg. mouse down on mesh)
  36500. */
  36501. onDragStartObservable: Observable<{
  36502. dragPlanePoint: Vector3;
  36503. pointerId: number;
  36504. }>;
  36505. /**
  36506. * Fires each time a drag ends (eg. mouse release after drag)
  36507. */
  36508. onDragEndObservable: Observable<{
  36509. dragPlanePoint: Vector3;
  36510. pointerId: number;
  36511. }>;
  36512. /**
  36513. * If the attached mesh should be moved when dragged
  36514. */
  36515. moveAttached: boolean;
  36516. /**
  36517. * If the drag behavior will react to drag events (Default: true)
  36518. */
  36519. enabled: boolean;
  36520. /**
  36521. * If camera controls should be detached during the drag
  36522. */
  36523. detachCameraControls: boolean;
  36524. /**
  36525. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36526. */
  36527. useObjectOrienationForDragging: boolean;
  36528. private _options;
  36529. /**
  36530. * Creates a pointer drag behavior that can be attached to a mesh
  36531. * @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)
  36532. */
  36533. constructor(options?: {
  36534. dragAxis?: Vector3;
  36535. dragPlaneNormal?: Vector3;
  36536. });
  36537. /**
  36538. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36539. */
  36540. validateDrag: (targetPosition: Vector3) => boolean;
  36541. /**
  36542. * The name of the behavior
  36543. */
  36544. readonly name: string;
  36545. /**
  36546. * Initializes the behavior
  36547. */
  36548. init(): void;
  36549. private _tmpVector;
  36550. private _alternatePickedPoint;
  36551. private _worldDragAxis;
  36552. private _targetPosition;
  36553. private _attachedElement;
  36554. /**
  36555. * Attaches the drag behavior the passed in mesh
  36556. * @param ownerNode The mesh that will be dragged around once attached
  36557. */
  36558. attach(ownerNode: AbstractMesh): void;
  36559. /**
  36560. * Force relase the drag action by code.
  36561. */
  36562. releaseDrag(): void;
  36563. private _startDragRay;
  36564. private _lastPointerRay;
  36565. /**
  36566. * Simulates the start of a pointer drag event on the behavior
  36567. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36568. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36569. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36570. */
  36571. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36572. private _startDrag;
  36573. private _dragDelta;
  36574. private _moveDrag;
  36575. private _pickWithRayOnDragPlane;
  36576. private _pointA;
  36577. private _pointB;
  36578. private _pointC;
  36579. private _lineA;
  36580. private _lineB;
  36581. private _localAxis;
  36582. private _lookAt;
  36583. private _updateDragPlanePosition;
  36584. /**
  36585. * Detaches the behavior from the mesh
  36586. */
  36587. detach(): void;
  36588. }
  36589. }
  36590. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36591. import { Mesh } from "babylonjs/Meshes/mesh";
  36592. import { Behavior } from "babylonjs/Behaviors/behavior";
  36593. /**
  36594. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36595. */
  36596. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36597. private _dragBehaviorA;
  36598. private _dragBehaviorB;
  36599. private _startDistance;
  36600. private _initialScale;
  36601. private _targetScale;
  36602. private _ownerNode;
  36603. private _sceneRenderObserver;
  36604. /**
  36605. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36606. */
  36607. constructor();
  36608. /**
  36609. * The name of the behavior
  36610. */
  36611. readonly name: string;
  36612. /**
  36613. * Initializes the behavior
  36614. */
  36615. init(): void;
  36616. private _getCurrentDistance;
  36617. /**
  36618. * Attaches the scale behavior the passed in mesh
  36619. * @param ownerNode The mesh that will be scaled around once attached
  36620. */
  36621. attach(ownerNode: Mesh): void;
  36622. /**
  36623. * Detaches the behavior from the mesh
  36624. */
  36625. detach(): void;
  36626. }
  36627. }
  36628. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36629. import { Behavior } from "babylonjs/Behaviors/behavior";
  36630. import { Mesh } from "babylonjs/Meshes/mesh";
  36631. import { Observable } from "babylonjs/Misc/observable";
  36632. /**
  36633. * 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
  36634. */
  36635. export class SixDofDragBehavior implements Behavior<Mesh> {
  36636. private static _virtualScene;
  36637. private _ownerNode;
  36638. private _sceneRenderObserver;
  36639. private _scene;
  36640. private _targetPosition;
  36641. private _virtualOriginMesh;
  36642. private _virtualDragMesh;
  36643. private _pointerObserver;
  36644. private _moving;
  36645. private _startingOrientation;
  36646. /**
  36647. * 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)
  36648. */
  36649. private zDragFactor;
  36650. /**
  36651. * If the object should rotate to face the drag origin
  36652. */
  36653. rotateDraggedObject: boolean;
  36654. /**
  36655. * If the behavior is currently in a dragging state
  36656. */
  36657. dragging: boolean;
  36658. /**
  36659. * 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)
  36660. */
  36661. dragDeltaRatio: number;
  36662. /**
  36663. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36664. */
  36665. currentDraggingPointerID: number;
  36666. /**
  36667. * If camera controls should be detached during the drag
  36668. */
  36669. detachCameraControls: boolean;
  36670. /**
  36671. * Fires each time a drag starts
  36672. */
  36673. onDragStartObservable: Observable<{}>;
  36674. /**
  36675. * Fires each time a drag ends (eg. mouse release after drag)
  36676. */
  36677. onDragEndObservable: Observable<{}>;
  36678. /**
  36679. * 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
  36680. */
  36681. constructor();
  36682. /**
  36683. * The name of the behavior
  36684. */
  36685. readonly name: string;
  36686. /**
  36687. * Initializes the behavior
  36688. */
  36689. init(): void;
  36690. /**
  36691. * Attaches the scale behavior the passed in mesh
  36692. * @param ownerNode The mesh that will be scaled around once attached
  36693. */
  36694. attach(ownerNode: Mesh): void;
  36695. /**
  36696. * Detaches the behavior from the mesh
  36697. */
  36698. detach(): void;
  36699. }
  36700. }
  36701. declare module "babylonjs/Behaviors/Meshes/index" {
  36702. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36703. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36704. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36705. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36706. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36707. }
  36708. declare module "babylonjs/Behaviors/index" {
  36709. export * from "babylonjs/Behaviors/behavior";
  36710. export * from "babylonjs/Behaviors/Cameras/index";
  36711. export * from "babylonjs/Behaviors/Meshes/index";
  36712. }
  36713. declare module "babylonjs/Bones/boneIKController" {
  36714. import { Bone } from "babylonjs/Bones/bone";
  36715. import { Vector3 } from "babylonjs/Maths/math";
  36716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36717. import { Nullable } from "babylonjs/types";
  36718. /**
  36719. * Class used to apply inverse kinematics to bones
  36720. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36721. */
  36722. export class BoneIKController {
  36723. private static _tmpVecs;
  36724. private static _tmpQuat;
  36725. private static _tmpMats;
  36726. /**
  36727. * Gets or sets the target mesh
  36728. */
  36729. targetMesh: AbstractMesh;
  36730. /** Gets or sets the mesh used as pole */
  36731. poleTargetMesh: AbstractMesh;
  36732. /**
  36733. * Gets or sets the bone used as pole
  36734. */
  36735. poleTargetBone: Nullable<Bone>;
  36736. /**
  36737. * Gets or sets the target position
  36738. */
  36739. targetPosition: Vector3;
  36740. /**
  36741. * Gets or sets the pole target position
  36742. */
  36743. poleTargetPosition: Vector3;
  36744. /**
  36745. * Gets or sets the pole target local offset
  36746. */
  36747. poleTargetLocalOffset: Vector3;
  36748. /**
  36749. * Gets or sets the pole angle
  36750. */
  36751. poleAngle: number;
  36752. /**
  36753. * Gets or sets the mesh associated with the controller
  36754. */
  36755. mesh: AbstractMesh;
  36756. /**
  36757. * 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)
  36758. */
  36759. slerpAmount: number;
  36760. private _bone1Quat;
  36761. private _bone1Mat;
  36762. private _bone2Ang;
  36763. private _bone1;
  36764. private _bone2;
  36765. private _bone1Length;
  36766. private _bone2Length;
  36767. private _maxAngle;
  36768. private _maxReach;
  36769. private _rightHandedSystem;
  36770. private _bendAxis;
  36771. private _slerping;
  36772. private _adjustRoll;
  36773. /**
  36774. * Gets or sets maximum allowed angle
  36775. */
  36776. maxAngle: number;
  36777. /**
  36778. * Creates a new BoneIKController
  36779. * @param mesh defines the mesh to control
  36780. * @param bone defines the bone to control
  36781. * @param options defines options to set up the controller
  36782. */
  36783. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36784. targetMesh?: AbstractMesh;
  36785. poleTargetMesh?: AbstractMesh;
  36786. poleTargetBone?: Bone;
  36787. poleTargetLocalOffset?: Vector3;
  36788. poleAngle?: number;
  36789. bendAxis?: Vector3;
  36790. maxAngle?: number;
  36791. slerpAmount?: number;
  36792. });
  36793. private _setMaxAngle;
  36794. /**
  36795. * Force the controller to update the bones
  36796. */
  36797. update(): void;
  36798. }
  36799. }
  36800. declare module "babylonjs/Bones/boneLookController" {
  36801. import { Vector3, Space } from "babylonjs/Maths/math";
  36802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36803. import { Bone } from "babylonjs/Bones/bone";
  36804. /**
  36805. * Class used to make a bone look toward a point in space
  36806. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36807. */
  36808. export class BoneLookController {
  36809. private static _tmpVecs;
  36810. private static _tmpQuat;
  36811. private static _tmpMats;
  36812. /**
  36813. * The target Vector3 that the bone will look at
  36814. */
  36815. target: Vector3;
  36816. /**
  36817. * The mesh that the bone is attached to
  36818. */
  36819. mesh: AbstractMesh;
  36820. /**
  36821. * The bone that will be looking to the target
  36822. */
  36823. bone: Bone;
  36824. /**
  36825. * The up axis of the coordinate system that is used when the bone is rotated
  36826. */
  36827. upAxis: Vector3;
  36828. /**
  36829. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36830. */
  36831. upAxisSpace: Space;
  36832. /**
  36833. * Used to make an adjustment to the yaw of the bone
  36834. */
  36835. adjustYaw: number;
  36836. /**
  36837. * Used to make an adjustment to the pitch of the bone
  36838. */
  36839. adjustPitch: number;
  36840. /**
  36841. * Used to make an adjustment to the roll of the bone
  36842. */
  36843. adjustRoll: number;
  36844. /**
  36845. * 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)
  36846. */
  36847. slerpAmount: number;
  36848. private _minYaw;
  36849. private _maxYaw;
  36850. private _minPitch;
  36851. private _maxPitch;
  36852. private _minYawSin;
  36853. private _minYawCos;
  36854. private _maxYawSin;
  36855. private _maxYawCos;
  36856. private _midYawConstraint;
  36857. private _minPitchTan;
  36858. private _maxPitchTan;
  36859. private _boneQuat;
  36860. private _slerping;
  36861. private _transformYawPitch;
  36862. private _transformYawPitchInv;
  36863. private _firstFrameSkipped;
  36864. private _yawRange;
  36865. private _fowardAxis;
  36866. /**
  36867. * Gets or sets the minimum yaw angle that the bone can look to
  36868. */
  36869. minYaw: number;
  36870. /**
  36871. * Gets or sets the maximum yaw angle that the bone can look to
  36872. */
  36873. maxYaw: number;
  36874. /**
  36875. * Gets or sets the minimum pitch angle that the bone can look to
  36876. */
  36877. minPitch: number;
  36878. /**
  36879. * Gets or sets the maximum pitch angle that the bone can look to
  36880. */
  36881. maxPitch: number;
  36882. /**
  36883. * Create a BoneLookController
  36884. * @param mesh the mesh that the bone belongs to
  36885. * @param bone the bone that will be looking to the target
  36886. * @param target the target Vector3 to look at
  36887. * @param options optional settings:
  36888. * * maxYaw: the maximum angle the bone will yaw to
  36889. * * minYaw: the minimum angle the bone will yaw to
  36890. * * maxPitch: the maximum angle the bone will pitch to
  36891. * * minPitch: the minimum angle the bone will yaw to
  36892. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36893. * * upAxis: the up axis of the coordinate system
  36894. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36895. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36896. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36897. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36898. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36899. * * adjustRoll: used to make an adjustment to the roll of the bone
  36900. **/
  36901. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36902. maxYaw?: number;
  36903. minYaw?: number;
  36904. maxPitch?: number;
  36905. minPitch?: number;
  36906. slerpAmount?: number;
  36907. upAxis?: Vector3;
  36908. upAxisSpace?: Space;
  36909. yawAxis?: Vector3;
  36910. pitchAxis?: Vector3;
  36911. adjustYaw?: number;
  36912. adjustPitch?: number;
  36913. adjustRoll?: number;
  36914. });
  36915. /**
  36916. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36917. */
  36918. update(): void;
  36919. private _getAngleDiff;
  36920. private _getAngleBetween;
  36921. private _isAngleBetween;
  36922. }
  36923. }
  36924. declare module "babylonjs/Bones/index" {
  36925. export * from "babylonjs/Bones/bone";
  36926. export * from "babylonjs/Bones/boneIKController";
  36927. export * from "babylonjs/Bones/boneLookController";
  36928. export * from "babylonjs/Bones/skeleton";
  36929. }
  36930. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36931. import { Nullable } from "babylonjs/types";
  36932. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36933. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36934. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36935. /**
  36936. * Manage the gamepad inputs to control an arc rotate camera.
  36937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36938. */
  36939. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36940. /**
  36941. * Defines the camera the input is attached to.
  36942. */
  36943. camera: ArcRotateCamera;
  36944. /**
  36945. * Defines the gamepad the input is gathering event from.
  36946. */
  36947. gamepad: Nullable<Gamepad>;
  36948. /**
  36949. * Defines the gamepad rotation sensiblity.
  36950. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36951. */
  36952. gamepadRotationSensibility: number;
  36953. /**
  36954. * Defines the gamepad move sensiblity.
  36955. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36956. */
  36957. gamepadMoveSensibility: number;
  36958. private _onGamepadConnectedObserver;
  36959. private _onGamepadDisconnectedObserver;
  36960. /**
  36961. * Attach the input controls to a specific dom element to get the input from.
  36962. * @param element Defines the element the controls should be listened from
  36963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36964. */
  36965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36966. /**
  36967. * Detach the current controls from the specified dom element.
  36968. * @param element Defines the element to stop listening the inputs from
  36969. */
  36970. detachControl(element: Nullable<HTMLElement>): void;
  36971. /**
  36972. * Update the current camera state depending on the inputs that have been used this frame.
  36973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36974. */
  36975. checkInputs(): void;
  36976. /**
  36977. * Gets the class name of the current intput.
  36978. * @returns the class name
  36979. */
  36980. getClassName(): string;
  36981. /**
  36982. * Get the friendly name associated with the input class.
  36983. * @returns the input friendly name
  36984. */
  36985. getSimpleName(): string;
  36986. }
  36987. }
  36988. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36989. import { Nullable } from "babylonjs/types";
  36990. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36991. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36992. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36993. interface ArcRotateCameraInputsManager {
  36994. /**
  36995. * Add orientation input support to the input manager.
  36996. * @returns the current input manager
  36997. */
  36998. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36999. }
  37000. }
  37001. /**
  37002. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37004. */
  37005. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37006. /**
  37007. * Defines the camera the input is attached to.
  37008. */
  37009. camera: ArcRotateCamera;
  37010. /**
  37011. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37012. */
  37013. alphaCorrection: number;
  37014. /**
  37015. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37016. */
  37017. gammaCorrection: number;
  37018. private _alpha;
  37019. private _gamma;
  37020. private _dirty;
  37021. private _deviceOrientationHandler;
  37022. /**
  37023. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37024. */
  37025. constructor();
  37026. /**
  37027. * Attach the input controls to a specific dom element to get the input from.
  37028. * @param element Defines the element the controls should be listened from
  37029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37030. */
  37031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37032. /** @hidden */
  37033. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37034. /**
  37035. * Update the current camera state depending on the inputs that have been used this frame.
  37036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37037. */
  37038. checkInputs(): void;
  37039. /**
  37040. * Detach the current controls from the specified dom element.
  37041. * @param element Defines the element to stop listening the inputs from
  37042. */
  37043. detachControl(element: Nullable<HTMLElement>): void;
  37044. /**
  37045. * Gets the class name of the current intput.
  37046. * @returns the class name
  37047. */
  37048. getClassName(): string;
  37049. /**
  37050. * Get the friendly name associated with the input class.
  37051. * @returns the input friendly name
  37052. */
  37053. getSimpleName(): string;
  37054. }
  37055. }
  37056. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37057. import { Nullable } from "babylonjs/types";
  37058. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37059. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37060. /**
  37061. * Listen to mouse events to control the camera.
  37062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37063. */
  37064. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37065. /**
  37066. * Defines the camera the input is attached to.
  37067. */
  37068. camera: FlyCamera;
  37069. /**
  37070. * Defines if touch is enabled. (Default is true.)
  37071. */
  37072. touchEnabled: boolean;
  37073. /**
  37074. * Defines the buttons associated with the input to handle camera rotation.
  37075. */
  37076. buttons: number[];
  37077. /**
  37078. * Assign buttons for Yaw control.
  37079. */
  37080. buttonsYaw: number[];
  37081. /**
  37082. * Assign buttons for Pitch control.
  37083. */
  37084. buttonsPitch: number[];
  37085. /**
  37086. * Assign buttons for Roll control.
  37087. */
  37088. buttonsRoll: number[];
  37089. /**
  37090. * Detect if any button is being pressed while mouse is moved.
  37091. * -1 = Mouse locked.
  37092. * 0 = Left button.
  37093. * 1 = Middle Button.
  37094. * 2 = Right Button.
  37095. */
  37096. activeButton: number;
  37097. /**
  37098. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37099. * Higher values reduce its sensitivity.
  37100. */
  37101. angularSensibility: number;
  37102. private _mousemoveCallback;
  37103. private _observer;
  37104. private _rollObserver;
  37105. private previousPosition;
  37106. private noPreventDefault;
  37107. private element;
  37108. /**
  37109. * Listen to mouse events to control the camera.
  37110. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37112. */
  37113. constructor(touchEnabled?: boolean);
  37114. /**
  37115. * Attach the mouse control to the HTML DOM element.
  37116. * @param element Defines the element that listens to the input events.
  37117. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37118. */
  37119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37120. /**
  37121. * Detach the current controls from the specified dom element.
  37122. * @param element Defines the element to stop listening the inputs from
  37123. */
  37124. detachControl(element: Nullable<HTMLElement>): void;
  37125. /**
  37126. * Gets the class name of the current input.
  37127. * @returns the class name.
  37128. */
  37129. getClassName(): string;
  37130. /**
  37131. * Get the friendly name associated with the input class.
  37132. * @returns the input's friendly name.
  37133. */
  37134. getSimpleName(): string;
  37135. private _pointerInput;
  37136. private _onMouseMove;
  37137. /**
  37138. * Rotate camera by mouse offset.
  37139. */
  37140. private rotateCamera;
  37141. }
  37142. }
  37143. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37144. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37145. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37146. /**
  37147. * Default Inputs manager for the FlyCamera.
  37148. * It groups all the default supported inputs for ease of use.
  37149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37150. */
  37151. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37152. /**
  37153. * Instantiates a new FlyCameraInputsManager.
  37154. * @param camera Defines the camera the inputs belong to.
  37155. */
  37156. constructor(camera: FlyCamera);
  37157. /**
  37158. * Add keyboard input support to the input manager.
  37159. * @returns the new FlyCameraKeyboardMoveInput().
  37160. */
  37161. addKeyboard(): FlyCameraInputsManager;
  37162. /**
  37163. * Add mouse input support to the input manager.
  37164. * @param touchEnabled Enable touch screen support.
  37165. * @returns the new FlyCameraMouseInput().
  37166. */
  37167. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37168. }
  37169. }
  37170. declare module "babylonjs/Cameras/flyCamera" {
  37171. import { Scene } from "babylonjs/scene";
  37172. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37174. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37175. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37176. /**
  37177. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37178. * such as in a 3D Space Shooter or a Flight Simulator.
  37179. */
  37180. export class FlyCamera extends TargetCamera {
  37181. /**
  37182. * Define the collision ellipsoid of the camera.
  37183. * This is helpful for simulating a camera body, like a player's body.
  37184. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37185. */
  37186. ellipsoid: Vector3;
  37187. /**
  37188. * Define an offset for the position of the ellipsoid around the camera.
  37189. * This can be helpful if the camera is attached away from the player's body center,
  37190. * such as at its head.
  37191. */
  37192. ellipsoidOffset: Vector3;
  37193. /**
  37194. * Enable or disable collisions of the camera with the rest of the scene objects.
  37195. */
  37196. checkCollisions: boolean;
  37197. /**
  37198. * Enable or disable gravity on the camera.
  37199. */
  37200. applyGravity: boolean;
  37201. /**
  37202. * Define the current direction the camera is moving to.
  37203. */
  37204. cameraDirection: Vector3;
  37205. /**
  37206. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37207. * This overrides and empties cameraRotation.
  37208. */
  37209. rotationQuaternion: Quaternion;
  37210. /**
  37211. * Track Roll to maintain the wanted Rolling when looking around.
  37212. */
  37213. _trackRoll: number;
  37214. /**
  37215. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37216. */
  37217. rollCorrect: number;
  37218. /**
  37219. * Mimic a banked turn, Rolling the camera when Yawing.
  37220. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37221. */
  37222. bankedTurn: boolean;
  37223. /**
  37224. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37225. */
  37226. bankedTurnLimit: number;
  37227. /**
  37228. * Value of 0 disables the banked Roll.
  37229. * Value of 1 is equal to the Yaw angle in radians.
  37230. */
  37231. bankedTurnMultiplier: number;
  37232. /**
  37233. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37234. */
  37235. inputs: FlyCameraInputsManager;
  37236. /**
  37237. * Gets the input sensibility for mouse input.
  37238. * Higher values reduce sensitivity.
  37239. */
  37240. /**
  37241. * Sets the input sensibility for a mouse input.
  37242. * Higher values reduce sensitivity.
  37243. */
  37244. angularSensibility: number;
  37245. /**
  37246. * Get the keys for camera movement forward.
  37247. */
  37248. /**
  37249. * Set the keys for camera movement forward.
  37250. */
  37251. keysForward: number[];
  37252. /**
  37253. * Get the keys for camera movement backward.
  37254. */
  37255. keysBackward: number[];
  37256. /**
  37257. * Get the keys for camera movement up.
  37258. */
  37259. /**
  37260. * Set the keys for camera movement up.
  37261. */
  37262. keysUp: number[];
  37263. /**
  37264. * Get the keys for camera movement down.
  37265. */
  37266. /**
  37267. * Set the keys for camera movement down.
  37268. */
  37269. keysDown: number[];
  37270. /**
  37271. * Get the keys for camera movement left.
  37272. */
  37273. /**
  37274. * Set the keys for camera movement left.
  37275. */
  37276. keysLeft: number[];
  37277. /**
  37278. * Set the keys for camera movement right.
  37279. */
  37280. /**
  37281. * Set the keys for camera movement right.
  37282. */
  37283. keysRight: number[];
  37284. /**
  37285. * Event raised when the camera collides with a mesh in the scene.
  37286. */
  37287. onCollide: (collidedMesh: AbstractMesh) => void;
  37288. private _collider;
  37289. private _needMoveForGravity;
  37290. private _oldPosition;
  37291. private _diffPosition;
  37292. private _newPosition;
  37293. /** @hidden */
  37294. _localDirection: Vector3;
  37295. /** @hidden */
  37296. _transformedDirection: Vector3;
  37297. /**
  37298. * Instantiates a FlyCamera.
  37299. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37300. * such as in a 3D Space Shooter or a Flight Simulator.
  37301. * @param name Define the name of the camera in the scene.
  37302. * @param position Define the starting position of the camera in the scene.
  37303. * @param scene Define the scene the camera belongs to.
  37304. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37305. */
  37306. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37307. /**
  37308. * Attach a control to the HTML DOM element.
  37309. * @param element Defines the element that listens to the input events.
  37310. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37311. */
  37312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37313. /**
  37314. * Detach a control from the HTML DOM element.
  37315. * The camera will stop reacting to that input.
  37316. * @param element Defines the element that listens to the input events.
  37317. */
  37318. detachControl(element: HTMLElement): void;
  37319. private _collisionMask;
  37320. /**
  37321. * Get the mask that the camera ignores in collision events.
  37322. */
  37323. /**
  37324. * Set the mask that the camera ignores in collision events.
  37325. */
  37326. collisionMask: number;
  37327. /** @hidden */
  37328. _collideWithWorld(displacement: Vector3): void;
  37329. /** @hidden */
  37330. private _onCollisionPositionChange;
  37331. /** @hidden */
  37332. _checkInputs(): void;
  37333. /** @hidden */
  37334. _decideIfNeedsToMove(): boolean;
  37335. /** @hidden */
  37336. _updatePosition(): void;
  37337. /**
  37338. * Restore the Roll to its target value at the rate specified.
  37339. * @param rate - Higher means slower restoring.
  37340. * @hidden
  37341. */
  37342. restoreRoll(rate: number): void;
  37343. /**
  37344. * Destroy the camera and release the current resources held by it.
  37345. */
  37346. dispose(): void;
  37347. /**
  37348. * Get the current object class name.
  37349. * @returns the class name.
  37350. */
  37351. getClassName(): string;
  37352. }
  37353. }
  37354. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37355. import { Nullable } from "babylonjs/types";
  37356. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37357. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37358. /**
  37359. * Listen to keyboard events to control the camera.
  37360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37361. */
  37362. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37363. /**
  37364. * Defines the camera the input is attached to.
  37365. */
  37366. camera: FlyCamera;
  37367. /**
  37368. * The list of keyboard keys used to control the forward move of the camera.
  37369. */
  37370. keysForward: number[];
  37371. /**
  37372. * The list of keyboard keys used to control the backward move of the camera.
  37373. */
  37374. keysBackward: number[];
  37375. /**
  37376. * The list of keyboard keys used to control the forward move of the camera.
  37377. */
  37378. keysUp: number[];
  37379. /**
  37380. * The list of keyboard keys used to control the backward move of the camera.
  37381. */
  37382. keysDown: number[];
  37383. /**
  37384. * The list of keyboard keys used to control the right strafe move of the camera.
  37385. */
  37386. keysRight: number[];
  37387. /**
  37388. * The list of keyboard keys used to control the left strafe move of the camera.
  37389. */
  37390. keysLeft: number[];
  37391. private _keys;
  37392. private _onCanvasBlurObserver;
  37393. private _onKeyboardObserver;
  37394. private _engine;
  37395. private _scene;
  37396. /**
  37397. * Attach the input controls to a specific dom element to get the input from.
  37398. * @param element Defines the element the controls should be listened from
  37399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37400. */
  37401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37402. /**
  37403. * Detach the current controls from the specified dom element.
  37404. * @param element Defines the element to stop listening the inputs from
  37405. */
  37406. detachControl(element: Nullable<HTMLElement>): void;
  37407. /**
  37408. * Gets the class name of the current intput.
  37409. * @returns the class name
  37410. */
  37411. getClassName(): string;
  37412. /** @hidden */
  37413. _onLostFocus(e: FocusEvent): void;
  37414. /**
  37415. * Get the friendly name associated with the input class.
  37416. * @returns the input friendly name
  37417. */
  37418. getSimpleName(): string;
  37419. /**
  37420. * Update the current camera state depending on the inputs that have been used this frame.
  37421. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37422. */
  37423. checkInputs(): void;
  37424. }
  37425. }
  37426. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37427. import { Nullable } from "babylonjs/types";
  37428. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37429. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37430. /**
  37431. * Manage the mouse wheel inputs to control a follow camera.
  37432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37433. */
  37434. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37435. /**
  37436. * Defines the camera the input is attached to.
  37437. */
  37438. camera: FollowCamera;
  37439. /**
  37440. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37441. */
  37442. axisControlRadius: boolean;
  37443. /**
  37444. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37445. */
  37446. axisControlHeight: boolean;
  37447. /**
  37448. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37449. */
  37450. axisControlRotation: boolean;
  37451. /**
  37452. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37453. * relation to mouseWheel events.
  37454. */
  37455. wheelPrecision: number;
  37456. /**
  37457. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37458. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37459. */
  37460. wheelDeltaPercentage: number;
  37461. private _wheel;
  37462. private _observer;
  37463. /**
  37464. * Attach the input controls to a specific dom element to get the input from.
  37465. * @param element Defines the element the controls should be listened from
  37466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37467. */
  37468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37469. /**
  37470. * Detach the current controls from the specified dom element.
  37471. * @param element Defines the element to stop listening the inputs from
  37472. */
  37473. detachControl(element: Nullable<HTMLElement>): void;
  37474. /**
  37475. * Gets the class name of the current intput.
  37476. * @returns the class name
  37477. */
  37478. getClassName(): string;
  37479. /**
  37480. * Get the friendly name associated with the input class.
  37481. * @returns the input friendly name
  37482. */
  37483. getSimpleName(): string;
  37484. }
  37485. }
  37486. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37487. import { Nullable } from "babylonjs/types";
  37488. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37489. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37490. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37491. /**
  37492. * Manage the pointers inputs to control an follow camera.
  37493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37494. */
  37495. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37496. /**
  37497. * Defines the camera the input is attached to.
  37498. */
  37499. camera: FollowCamera;
  37500. /**
  37501. * Gets the class name of the current input.
  37502. * @returns the class name
  37503. */
  37504. getClassName(): string;
  37505. /**
  37506. * Defines the pointer angular sensibility along the X axis or how fast is
  37507. * the camera rotating.
  37508. * A negative number will reverse the axis direction.
  37509. */
  37510. angularSensibilityX: number;
  37511. /**
  37512. * Defines the pointer angular sensibility along the Y axis or how fast is
  37513. * the camera rotating.
  37514. * A negative number will reverse the axis direction.
  37515. */
  37516. angularSensibilityY: number;
  37517. /**
  37518. * Defines the pointer pinch precision or how fast is the camera zooming.
  37519. * A negative number will reverse the axis direction.
  37520. */
  37521. pinchPrecision: number;
  37522. /**
  37523. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37524. * from 0.
  37525. * It defines the percentage of current camera.radius to use as delta when
  37526. * pinch zoom is used.
  37527. */
  37528. pinchDeltaPercentage: number;
  37529. /**
  37530. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37531. */
  37532. axisXControlRadius: boolean;
  37533. /**
  37534. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37535. */
  37536. axisXControlHeight: boolean;
  37537. /**
  37538. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37539. */
  37540. axisXControlRotation: boolean;
  37541. /**
  37542. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37543. */
  37544. axisYControlRadius: boolean;
  37545. /**
  37546. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37547. */
  37548. axisYControlHeight: boolean;
  37549. /**
  37550. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37551. */
  37552. axisYControlRotation: boolean;
  37553. /**
  37554. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37555. */
  37556. axisPinchControlRadius: boolean;
  37557. /**
  37558. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37559. */
  37560. axisPinchControlHeight: boolean;
  37561. /**
  37562. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37563. */
  37564. axisPinchControlRotation: boolean;
  37565. /**
  37566. * Log error messages if basic misconfiguration has occurred.
  37567. */
  37568. warningEnable: boolean;
  37569. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37570. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37571. private _warningCounter;
  37572. private _warning;
  37573. }
  37574. }
  37575. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37576. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37577. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37578. /**
  37579. * Default Inputs manager for the FollowCamera.
  37580. * It groups all the default supported inputs for ease of use.
  37581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37582. */
  37583. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37584. /**
  37585. * Instantiates a new FollowCameraInputsManager.
  37586. * @param camera Defines the camera the inputs belong to
  37587. */
  37588. constructor(camera: FollowCamera);
  37589. /**
  37590. * Add keyboard input support to the input manager.
  37591. * @returns the current input manager
  37592. */
  37593. addKeyboard(): FollowCameraInputsManager;
  37594. /**
  37595. * Add mouse wheel input support to the input manager.
  37596. * @returns the current input manager
  37597. */
  37598. addMouseWheel(): FollowCameraInputsManager;
  37599. /**
  37600. * Add pointers input support to the input manager.
  37601. * @returns the current input manager
  37602. */
  37603. addPointers(): FollowCameraInputsManager;
  37604. /**
  37605. * Add orientation input support to the input manager.
  37606. * @returns the current input manager
  37607. */
  37608. addVRDeviceOrientation(): FollowCameraInputsManager;
  37609. }
  37610. }
  37611. declare module "babylonjs/Cameras/followCamera" {
  37612. import { Nullable } from "babylonjs/types";
  37613. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37614. import { Scene } from "babylonjs/scene";
  37615. import { Vector3 } from "babylonjs/Maths/math";
  37616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37617. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37618. /**
  37619. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37620. * an arc rotate version arcFollowCamera are available.
  37621. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37622. */
  37623. export class FollowCamera extends TargetCamera {
  37624. /**
  37625. * Distance the follow camera should follow an object at
  37626. */
  37627. radius: number;
  37628. /**
  37629. * Minimum allowed distance of the camera to the axis of rotation
  37630. * (The camera can not get closer).
  37631. * This can help limiting how the Camera is able to move in the scene.
  37632. */
  37633. lowerRadiusLimit: Nullable<number>;
  37634. /**
  37635. * Maximum allowed distance of the camera to the axis of rotation
  37636. * (The camera can not get further).
  37637. * This can help limiting how the Camera is able to move in the scene.
  37638. */
  37639. upperRadiusLimit: Nullable<number>;
  37640. /**
  37641. * Define a rotation offset between the camera and the object it follows
  37642. */
  37643. rotationOffset: number;
  37644. /**
  37645. * Minimum allowed angle to camera position relative to target object.
  37646. * This can help limiting how the Camera is able to move in the scene.
  37647. */
  37648. lowerRotationOffsetLimit: Nullable<number>;
  37649. /**
  37650. * Maximum allowed angle to camera position relative to target object.
  37651. * This can help limiting how the Camera is able to move in the scene.
  37652. */
  37653. upperRotationOffsetLimit: Nullable<number>;
  37654. /**
  37655. * Define a height offset between the camera and the object it follows.
  37656. * It can help following an object from the top (like a car chaing a plane)
  37657. */
  37658. heightOffset: number;
  37659. /**
  37660. * Minimum allowed height of camera position relative to target object.
  37661. * This can help limiting how the Camera is able to move in the scene.
  37662. */
  37663. lowerHeightOffsetLimit: Nullable<number>;
  37664. /**
  37665. * Maximum allowed height of camera position relative to target object.
  37666. * This can help limiting how the Camera is able to move in the scene.
  37667. */
  37668. upperHeightOffsetLimit: Nullable<number>;
  37669. /**
  37670. * Define how fast the camera can accelerate to follow it s target.
  37671. */
  37672. cameraAcceleration: number;
  37673. /**
  37674. * Define the speed limit of the camera following an object.
  37675. */
  37676. maxCameraSpeed: number;
  37677. /**
  37678. * Define the target of the camera.
  37679. */
  37680. lockedTarget: Nullable<AbstractMesh>;
  37681. /**
  37682. * Defines the input associated with the camera.
  37683. */
  37684. inputs: FollowCameraInputsManager;
  37685. /**
  37686. * Instantiates the follow camera.
  37687. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37688. * @param name Define the name of the camera in the scene
  37689. * @param position Define the position of the camera
  37690. * @param scene Define the scene the camera belong to
  37691. * @param lockedTarget Define the target of the camera
  37692. */
  37693. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37694. private _follow;
  37695. /**
  37696. * Attached controls to the current camera.
  37697. * @param element Defines the element the controls should be listened from
  37698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37699. */
  37700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37701. /**
  37702. * Detach the current controls from the camera.
  37703. * The camera will stop reacting to inputs.
  37704. * @param element Defines the element to stop listening the inputs from
  37705. */
  37706. detachControl(element: HTMLElement): void;
  37707. /** @hidden */
  37708. _checkInputs(): void;
  37709. private _checkLimits;
  37710. /**
  37711. * Gets the camera class name.
  37712. * @returns the class name
  37713. */
  37714. getClassName(): string;
  37715. }
  37716. /**
  37717. * Arc Rotate version of the follow camera.
  37718. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37719. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37720. */
  37721. export class ArcFollowCamera extends TargetCamera {
  37722. /** The longitudinal angle of the camera */
  37723. alpha: number;
  37724. /** The latitudinal angle of the camera */
  37725. beta: number;
  37726. /** The radius of the camera from its target */
  37727. radius: number;
  37728. /** Define the camera target (the messh it should follow) */
  37729. target: Nullable<AbstractMesh>;
  37730. private _cartesianCoordinates;
  37731. /**
  37732. * Instantiates a new ArcFollowCamera
  37733. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37734. * @param name Define the name of the camera
  37735. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37736. * @param beta Define the rotation angle of the camera around the elevation axis
  37737. * @param radius Define the radius of the camera from its target point
  37738. * @param target Define the target of the camera
  37739. * @param scene Define the scene the camera belongs to
  37740. */
  37741. constructor(name: string,
  37742. /** The longitudinal angle of the camera */
  37743. alpha: number,
  37744. /** The latitudinal angle of the camera */
  37745. beta: number,
  37746. /** The radius of the camera from its target */
  37747. radius: number,
  37748. /** Define the camera target (the messh it should follow) */
  37749. target: Nullable<AbstractMesh>, scene: Scene);
  37750. private _follow;
  37751. /** @hidden */
  37752. _checkInputs(): void;
  37753. /**
  37754. * Returns the class name of the object.
  37755. * It is mostly used internally for serialization purposes.
  37756. */
  37757. getClassName(): string;
  37758. }
  37759. }
  37760. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37761. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37762. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37763. import { Nullable } from "babylonjs/types";
  37764. /**
  37765. * Manage the keyboard inputs to control the movement of a follow camera.
  37766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37767. */
  37768. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37769. /**
  37770. * Defines the camera the input is attached to.
  37771. */
  37772. camera: FollowCamera;
  37773. /**
  37774. * Defines the list of key codes associated with the up action (increase heightOffset)
  37775. */
  37776. keysHeightOffsetIncr: number[];
  37777. /**
  37778. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37779. */
  37780. keysHeightOffsetDecr: number[];
  37781. /**
  37782. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37783. */
  37784. keysHeightOffsetModifierAlt: boolean;
  37785. /**
  37786. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37787. */
  37788. keysHeightOffsetModifierCtrl: boolean;
  37789. /**
  37790. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37791. */
  37792. keysHeightOffsetModifierShift: boolean;
  37793. /**
  37794. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37795. */
  37796. keysRotationOffsetIncr: number[];
  37797. /**
  37798. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37799. */
  37800. keysRotationOffsetDecr: number[];
  37801. /**
  37802. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37803. */
  37804. keysRotationOffsetModifierAlt: boolean;
  37805. /**
  37806. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37807. */
  37808. keysRotationOffsetModifierCtrl: boolean;
  37809. /**
  37810. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37811. */
  37812. keysRotationOffsetModifierShift: boolean;
  37813. /**
  37814. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37815. */
  37816. keysRadiusIncr: number[];
  37817. /**
  37818. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37819. */
  37820. keysRadiusDecr: number[];
  37821. /**
  37822. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37823. */
  37824. keysRadiusModifierAlt: boolean;
  37825. /**
  37826. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37827. */
  37828. keysRadiusModifierCtrl: boolean;
  37829. /**
  37830. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37831. */
  37832. keysRadiusModifierShift: boolean;
  37833. /**
  37834. * Defines the rate of change of heightOffset.
  37835. */
  37836. heightSensibility: number;
  37837. /**
  37838. * Defines the rate of change of rotationOffset.
  37839. */
  37840. rotationSensibility: number;
  37841. /**
  37842. * Defines the rate of change of radius.
  37843. */
  37844. radiusSensibility: number;
  37845. private _keys;
  37846. private _ctrlPressed;
  37847. private _altPressed;
  37848. private _shiftPressed;
  37849. private _onCanvasBlurObserver;
  37850. private _onKeyboardObserver;
  37851. private _engine;
  37852. private _scene;
  37853. /**
  37854. * Attach the input controls to a specific dom element to get the input from.
  37855. * @param element Defines the element the controls should be listened from
  37856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37857. */
  37858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37859. /**
  37860. * Detach the current controls from the specified dom element.
  37861. * @param element Defines the element to stop listening the inputs from
  37862. */
  37863. detachControl(element: Nullable<HTMLElement>): void;
  37864. /**
  37865. * Update the current camera state depending on the inputs that have been used this frame.
  37866. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37867. */
  37868. checkInputs(): void;
  37869. /**
  37870. * Gets the class name of the current input.
  37871. * @returns the class name
  37872. */
  37873. getClassName(): string;
  37874. /**
  37875. * Get the friendly name associated with the input class.
  37876. * @returns the input friendly name
  37877. */
  37878. getSimpleName(): string;
  37879. /**
  37880. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37881. * allow modification of the heightOffset value.
  37882. */
  37883. private _modifierHeightOffset;
  37884. /**
  37885. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37886. * allow modification of the rotationOffset value.
  37887. */
  37888. private _modifierRotationOffset;
  37889. /**
  37890. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37891. * allow modification of the radius value.
  37892. */
  37893. private _modifierRadius;
  37894. }
  37895. }
  37896. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37897. import { Nullable } from "babylonjs/types";
  37898. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37899. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37900. import { Observable } from "babylonjs/Misc/observable";
  37901. module "babylonjs/Cameras/freeCameraInputsManager" {
  37902. interface FreeCameraInputsManager {
  37903. /**
  37904. * @hidden
  37905. */
  37906. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37907. /**
  37908. * Add orientation input support to the input manager.
  37909. * @returns the current input manager
  37910. */
  37911. addDeviceOrientation(): FreeCameraInputsManager;
  37912. }
  37913. }
  37914. /**
  37915. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37916. * Screen rotation is taken into account.
  37917. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37918. */
  37919. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37920. private _camera;
  37921. private _screenOrientationAngle;
  37922. private _constantTranform;
  37923. private _screenQuaternion;
  37924. private _alpha;
  37925. private _beta;
  37926. private _gamma;
  37927. /**
  37928. * @hidden
  37929. */
  37930. _onDeviceOrientationChangedObservable: Observable<void>;
  37931. /**
  37932. * Instantiates a new input
  37933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37934. */
  37935. constructor();
  37936. /**
  37937. * Define the camera controlled by the input.
  37938. */
  37939. camera: FreeCamera;
  37940. /**
  37941. * Attach the input controls to a specific dom element to get the input from.
  37942. * @param element Defines the element the controls should be listened from
  37943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37944. */
  37945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37946. private _orientationChanged;
  37947. private _deviceOrientation;
  37948. /**
  37949. * Detach the current controls from the specified dom element.
  37950. * @param element Defines the element to stop listening the inputs from
  37951. */
  37952. detachControl(element: Nullable<HTMLElement>): void;
  37953. /**
  37954. * Update the current camera state depending on the inputs that have been used this frame.
  37955. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37956. */
  37957. checkInputs(): void;
  37958. /**
  37959. * Gets the class name of the current intput.
  37960. * @returns the class name
  37961. */
  37962. getClassName(): string;
  37963. /**
  37964. * Get the friendly name associated with the input class.
  37965. * @returns the input friendly name
  37966. */
  37967. getSimpleName(): string;
  37968. }
  37969. }
  37970. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37971. import { Nullable } from "babylonjs/types";
  37972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37974. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37975. /**
  37976. * Manage the gamepad inputs to control a free camera.
  37977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37978. */
  37979. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37980. /**
  37981. * Define the camera the input is attached to.
  37982. */
  37983. camera: FreeCamera;
  37984. /**
  37985. * Define the Gamepad controlling the input
  37986. */
  37987. gamepad: Nullable<Gamepad>;
  37988. /**
  37989. * Defines the gamepad rotation sensiblity.
  37990. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37991. */
  37992. gamepadAngularSensibility: number;
  37993. /**
  37994. * Defines the gamepad move sensiblity.
  37995. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37996. */
  37997. gamepadMoveSensibility: number;
  37998. private _onGamepadConnectedObserver;
  37999. private _onGamepadDisconnectedObserver;
  38000. private _cameraTransform;
  38001. private _deltaTransform;
  38002. private _vector3;
  38003. private _vector2;
  38004. /**
  38005. * Attach the input controls to a specific dom element to get the input from.
  38006. * @param element Defines the element the controls should be listened from
  38007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38008. */
  38009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38010. /**
  38011. * Detach the current controls from the specified dom element.
  38012. * @param element Defines the element to stop listening the inputs from
  38013. */
  38014. detachControl(element: Nullable<HTMLElement>): void;
  38015. /**
  38016. * Update the current camera state depending on the inputs that have been used this frame.
  38017. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38018. */
  38019. checkInputs(): void;
  38020. /**
  38021. * Gets the class name of the current intput.
  38022. * @returns the class name
  38023. */
  38024. getClassName(): string;
  38025. /**
  38026. * Get the friendly name associated with the input class.
  38027. * @returns the input friendly name
  38028. */
  38029. getSimpleName(): string;
  38030. }
  38031. }
  38032. declare module "babylonjs/Misc/virtualJoystick" {
  38033. import { Nullable } from "babylonjs/types";
  38034. import { Vector3 } from "babylonjs/Maths/math";
  38035. /**
  38036. * Defines the potential axis of a Joystick
  38037. */
  38038. export enum JoystickAxis {
  38039. /** X axis */
  38040. X = 0,
  38041. /** Y axis */
  38042. Y = 1,
  38043. /** Z axis */
  38044. Z = 2
  38045. }
  38046. /**
  38047. * Class used to define virtual joystick (used in touch mode)
  38048. */
  38049. export class VirtualJoystick {
  38050. /**
  38051. * Gets or sets a boolean indicating that left and right values must be inverted
  38052. */
  38053. reverseLeftRight: boolean;
  38054. /**
  38055. * Gets or sets a boolean indicating that up and down values must be inverted
  38056. */
  38057. reverseUpDown: boolean;
  38058. /**
  38059. * Gets the offset value for the position (ie. the change of the position value)
  38060. */
  38061. deltaPosition: Vector3;
  38062. /**
  38063. * Gets a boolean indicating if the virtual joystick was pressed
  38064. */
  38065. pressed: boolean;
  38066. /**
  38067. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38068. */
  38069. static Canvas: Nullable<HTMLCanvasElement>;
  38070. private static _globalJoystickIndex;
  38071. private static vjCanvasContext;
  38072. private static vjCanvasWidth;
  38073. private static vjCanvasHeight;
  38074. private static halfWidth;
  38075. private _action;
  38076. private _axisTargetedByLeftAndRight;
  38077. private _axisTargetedByUpAndDown;
  38078. private _joystickSensibility;
  38079. private _inversedSensibility;
  38080. private _joystickPointerID;
  38081. private _joystickColor;
  38082. private _joystickPointerPos;
  38083. private _joystickPreviousPointerPos;
  38084. private _joystickPointerStartPos;
  38085. private _deltaJoystickVector;
  38086. private _leftJoystick;
  38087. private _touches;
  38088. private _onPointerDownHandlerRef;
  38089. private _onPointerMoveHandlerRef;
  38090. private _onPointerUpHandlerRef;
  38091. private _onResize;
  38092. /**
  38093. * Creates a new virtual joystick
  38094. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38095. */
  38096. constructor(leftJoystick?: boolean);
  38097. /**
  38098. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38099. * @param newJoystickSensibility defines the new sensibility
  38100. */
  38101. setJoystickSensibility(newJoystickSensibility: number): void;
  38102. private _onPointerDown;
  38103. private _onPointerMove;
  38104. private _onPointerUp;
  38105. /**
  38106. * Change the color of the virtual joystick
  38107. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38108. */
  38109. setJoystickColor(newColor: string): void;
  38110. /**
  38111. * Defines a callback to call when the joystick is touched
  38112. * @param action defines the callback
  38113. */
  38114. setActionOnTouch(action: () => any): void;
  38115. /**
  38116. * Defines which axis you'd like to control for left & right
  38117. * @param axis defines the axis to use
  38118. */
  38119. setAxisForLeftRight(axis: JoystickAxis): void;
  38120. /**
  38121. * Defines which axis you'd like to control for up & down
  38122. * @param axis defines the axis to use
  38123. */
  38124. setAxisForUpDown(axis: JoystickAxis): void;
  38125. private _drawVirtualJoystick;
  38126. /**
  38127. * Release internal HTML canvas
  38128. */
  38129. releaseCanvas(): void;
  38130. }
  38131. }
  38132. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38133. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38134. import { Nullable } from "babylonjs/types";
  38135. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38136. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38137. module "babylonjs/Cameras/freeCameraInputsManager" {
  38138. interface FreeCameraInputsManager {
  38139. /**
  38140. * Add virtual joystick input support to the input manager.
  38141. * @returns the current input manager
  38142. */
  38143. addVirtualJoystick(): FreeCameraInputsManager;
  38144. }
  38145. }
  38146. /**
  38147. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38149. */
  38150. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38151. /**
  38152. * Defines the camera the input is attached to.
  38153. */
  38154. camera: FreeCamera;
  38155. private _leftjoystick;
  38156. private _rightjoystick;
  38157. /**
  38158. * Gets the left stick of the virtual joystick.
  38159. * @returns The virtual Joystick
  38160. */
  38161. getLeftJoystick(): VirtualJoystick;
  38162. /**
  38163. * Gets the right stick of the virtual joystick.
  38164. * @returns The virtual Joystick
  38165. */
  38166. getRightJoystick(): VirtualJoystick;
  38167. /**
  38168. * Update the current camera state depending on the inputs that have been used this frame.
  38169. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38170. */
  38171. checkInputs(): void;
  38172. /**
  38173. * Attach the input controls to a specific dom element to get the input from.
  38174. * @param element Defines the element the controls should be listened from
  38175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38176. */
  38177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38178. /**
  38179. * Detach the current controls from the specified dom element.
  38180. * @param element Defines the element to stop listening the inputs from
  38181. */
  38182. detachControl(element: Nullable<HTMLElement>): void;
  38183. /**
  38184. * Gets the class name of the current intput.
  38185. * @returns the class name
  38186. */
  38187. getClassName(): string;
  38188. /**
  38189. * Get the friendly name associated with the input class.
  38190. * @returns the input friendly name
  38191. */
  38192. getSimpleName(): string;
  38193. }
  38194. }
  38195. declare module "babylonjs/Cameras/Inputs/index" {
  38196. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38197. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38198. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38199. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38200. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38201. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38202. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38203. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38204. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38205. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38206. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38207. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38208. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38209. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38210. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38211. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38212. }
  38213. declare module "babylonjs/Cameras/touchCamera" {
  38214. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38215. import { Scene } from "babylonjs/scene";
  38216. import { Vector3 } from "babylonjs/Maths/math";
  38217. /**
  38218. * This represents a FPS type of camera controlled by touch.
  38219. * This is like a universal camera minus the Gamepad controls.
  38220. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38221. */
  38222. export class TouchCamera extends FreeCamera {
  38223. /**
  38224. * Defines the touch sensibility for rotation.
  38225. * The higher the faster.
  38226. */
  38227. touchAngularSensibility: number;
  38228. /**
  38229. * Defines the touch sensibility for move.
  38230. * The higher the faster.
  38231. */
  38232. touchMoveSensibility: number;
  38233. /**
  38234. * Instantiates a new touch camera.
  38235. * This represents a FPS type of camera controlled by touch.
  38236. * This is like a universal camera minus the Gamepad controls.
  38237. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38238. * @param name Define the name of the camera in the scene
  38239. * @param position Define the start position of the camera in the scene
  38240. * @param scene Define the scene the camera belongs to
  38241. */
  38242. constructor(name: string, position: Vector3, scene: Scene);
  38243. /**
  38244. * Gets the current object class name.
  38245. * @return the class name
  38246. */
  38247. getClassName(): string;
  38248. /** @hidden */
  38249. _setupInputs(): void;
  38250. }
  38251. }
  38252. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38253. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38254. import { Scene } from "babylonjs/scene";
  38255. import { Vector3, Axis } from "babylonjs/Maths/math";
  38256. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38257. /**
  38258. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38259. * being tilted forward or back and left or right.
  38260. */
  38261. export class DeviceOrientationCamera extends FreeCamera {
  38262. private _initialQuaternion;
  38263. private _quaternionCache;
  38264. private _tmpDragQuaternion;
  38265. /**
  38266. * Creates a new device orientation camera
  38267. * @param name The name of the camera
  38268. * @param position The start position camera
  38269. * @param scene The scene the camera belongs to
  38270. */
  38271. constructor(name: string, position: Vector3, scene: Scene);
  38272. /**
  38273. * @hidden
  38274. * Disabled pointer input on first orientation sensor update (Default: true)
  38275. */
  38276. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38277. private _dragFactor;
  38278. /**
  38279. * Enabled turning on the y axis when the orientation sensor is active
  38280. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38281. */
  38282. enableHorizontalDragging(dragFactor?: number): void;
  38283. /**
  38284. * Gets the current instance class name ("DeviceOrientationCamera").
  38285. * This helps avoiding instanceof at run time.
  38286. * @returns the class name
  38287. */
  38288. getClassName(): string;
  38289. /**
  38290. * @hidden
  38291. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38292. */
  38293. _checkInputs(): void;
  38294. /**
  38295. * Reset the camera to its default orientation on the specified axis only.
  38296. * @param axis The axis to reset
  38297. */
  38298. resetToCurrentRotation(axis?: Axis): void;
  38299. }
  38300. }
  38301. declare module "babylonjs/Cameras/universalCamera" {
  38302. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38303. import { Scene } from "babylonjs/scene";
  38304. import { Vector3 } from "babylonjs/Maths/math";
  38305. /**
  38306. * 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,
  38307. * which still works and will still be found in many Playgrounds.
  38308. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38309. */
  38310. export class UniversalCamera extends TouchCamera {
  38311. /**
  38312. * Defines the gamepad rotation sensiblity.
  38313. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38314. */
  38315. gamepadAngularSensibility: number;
  38316. /**
  38317. * Defines the gamepad move sensiblity.
  38318. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38319. */
  38320. gamepadMoveSensibility: number;
  38321. /**
  38322. * 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,
  38323. * which still works and will still be found in many Playgrounds.
  38324. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38325. * @param name Define the name of the camera in the scene
  38326. * @param position Define the start position of the camera in the scene
  38327. * @param scene Define the scene the camera belongs to
  38328. */
  38329. constructor(name: string, position: Vector3, scene: Scene);
  38330. /**
  38331. * Gets the current object class name.
  38332. * @return the class name
  38333. */
  38334. getClassName(): string;
  38335. }
  38336. }
  38337. declare module "babylonjs/Cameras/gamepadCamera" {
  38338. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38339. import { Scene } from "babylonjs/scene";
  38340. import { Vector3 } from "babylonjs/Maths/math";
  38341. /**
  38342. * This represents a FPS type of camera. This is only here for back compat purpose.
  38343. * Please use the UniversalCamera instead as both are identical.
  38344. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38345. */
  38346. export class GamepadCamera extends UniversalCamera {
  38347. /**
  38348. * Instantiates a new Gamepad Camera
  38349. * This represents a FPS type of camera. This is only here for back compat purpose.
  38350. * Please use the UniversalCamera instead as both are identical.
  38351. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38352. * @param name Define the name of the camera in the scene
  38353. * @param position Define the start position of the camera in the scene
  38354. * @param scene Define the scene the camera belongs to
  38355. */
  38356. constructor(name: string, position: Vector3, scene: Scene);
  38357. /**
  38358. * Gets the current object class name.
  38359. * @return the class name
  38360. */
  38361. getClassName(): string;
  38362. }
  38363. }
  38364. declare module "babylonjs/Shaders/pass.fragment" {
  38365. /** @hidden */
  38366. export var passPixelShader: {
  38367. name: string;
  38368. shader: string;
  38369. };
  38370. }
  38371. declare module "babylonjs/Shaders/passCube.fragment" {
  38372. /** @hidden */
  38373. export var passCubePixelShader: {
  38374. name: string;
  38375. shader: string;
  38376. };
  38377. }
  38378. declare module "babylonjs/PostProcesses/passPostProcess" {
  38379. import { Nullable } from "babylonjs/types";
  38380. import { Camera } from "babylonjs/Cameras/camera";
  38381. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38382. import { Engine } from "babylonjs/Engines/engine";
  38383. import "babylonjs/Shaders/pass.fragment";
  38384. import "babylonjs/Shaders/passCube.fragment";
  38385. /**
  38386. * PassPostProcess which produces an output the same as it's input
  38387. */
  38388. export class PassPostProcess extends PostProcess {
  38389. /**
  38390. * Creates the PassPostProcess
  38391. * @param name The name of the effect.
  38392. * @param options The required width/height ratio to downsize to before computing the render pass.
  38393. * @param camera The camera to apply the render pass to.
  38394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38395. * @param engine The engine which the post process will be applied. (default: current engine)
  38396. * @param reusable If the post process can be reused on the same frame. (default: false)
  38397. * @param textureType The type of texture to be used when performing the post processing.
  38398. * @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)
  38399. */
  38400. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38401. }
  38402. /**
  38403. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38404. */
  38405. export class PassCubePostProcess extends PostProcess {
  38406. private _face;
  38407. /**
  38408. * Gets or sets the cube face to display.
  38409. * * 0 is +X
  38410. * * 1 is -X
  38411. * * 2 is +Y
  38412. * * 3 is -Y
  38413. * * 4 is +Z
  38414. * * 5 is -Z
  38415. */
  38416. face: number;
  38417. /**
  38418. * Creates the PassCubePostProcess
  38419. * @param name The name of the effect.
  38420. * @param options The required width/height ratio to downsize to before computing the render pass.
  38421. * @param camera The camera to apply the render pass to.
  38422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38423. * @param engine The engine which the post process will be applied. (default: current engine)
  38424. * @param reusable If the post process can be reused on the same frame. (default: false)
  38425. * @param textureType The type of texture to be used when performing the post processing.
  38426. * @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)
  38427. */
  38428. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38429. }
  38430. }
  38431. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38432. /** @hidden */
  38433. export var anaglyphPixelShader: {
  38434. name: string;
  38435. shader: string;
  38436. };
  38437. }
  38438. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38439. import { Engine } from "babylonjs/Engines/engine";
  38440. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38441. import { Camera } from "babylonjs/Cameras/camera";
  38442. import "babylonjs/Shaders/anaglyph.fragment";
  38443. /**
  38444. * Postprocess used to generate anaglyphic rendering
  38445. */
  38446. export class AnaglyphPostProcess extends PostProcess {
  38447. private _passedProcess;
  38448. /**
  38449. * Creates a new AnaglyphPostProcess
  38450. * @param name defines postprocess name
  38451. * @param options defines creation options or target ratio scale
  38452. * @param rigCameras defines cameras using this postprocess
  38453. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38454. * @param engine defines hosting engine
  38455. * @param reusable defines if the postprocess will be reused multiple times per frame
  38456. */
  38457. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38458. }
  38459. }
  38460. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38461. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38462. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38463. import { Scene } from "babylonjs/scene";
  38464. import { Vector3 } from "babylonjs/Maths/math";
  38465. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38466. /**
  38467. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38468. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38469. */
  38470. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38471. /**
  38472. * Creates a new AnaglyphArcRotateCamera
  38473. * @param name defines camera name
  38474. * @param alpha defines alpha angle (in radians)
  38475. * @param beta defines beta angle (in radians)
  38476. * @param radius defines radius
  38477. * @param target defines camera target
  38478. * @param interaxialDistance defines distance between each color axis
  38479. * @param scene defines the hosting scene
  38480. */
  38481. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38482. /**
  38483. * Gets camera class name
  38484. * @returns AnaglyphArcRotateCamera
  38485. */
  38486. getClassName(): string;
  38487. }
  38488. }
  38489. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38490. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38491. import { Scene } from "babylonjs/scene";
  38492. import { Vector3 } from "babylonjs/Maths/math";
  38493. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38494. /**
  38495. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38496. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38497. */
  38498. export class AnaglyphFreeCamera extends FreeCamera {
  38499. /**
  38500. * Creates a new AnaglyphFreeCamera
  38501. * @param name defines camera name
  38502. * @param position defines initial position
  38503. * @param interaxialDistance defines distance between each color axis
  38504. * @param scene defines the hosting scene
  38505. */
  38506. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38507. /**
  38508. * Gets camera class name
  38509. * @returns AnaglyphFreeCamera
  38510. */
  38511. getClassName(): string;
  38512. }
  38513. }
  38514. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38515. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38516. import { Scene } from "babylonjs/scene";
  38517. import { Vector3 } from "babylonjs/Maths/math";
  38518. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38519. /**
  38520. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38521. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38522. */
  38523. export class AnaglyphGamepadCamera extends GamepadCamera {
  38524. /**
  38525. * Creates a new AnaglyphGamepadCamera
  38526. * @param name defines camera name
  38527. * @param position defines initial position
  38528. * @param interaxialDistance defines distance between each color axis
  38529. * @param scene defines the hosting scene
  38530. */
  38531. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38532. /**
  38533. * Gets camera class name
  38534. * @returns AnaglyphGamepadCamera
  38535. */
  38536. getClassName(): string;
  38537. }
  38538. }
  38539. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38540. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38541. import { Scene } from "babylonjs/scene";
  38542. import { Vector3 } from "babylonjs/Maths/math";
  38543. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38544. /**
  38545. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38546. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38547. */
  38548. export class AnaglyphUniversalCamera extends UniversalCamera {
  38549. /**
  38550. * Creates a new AnaglyphUniversalCamera
  38551. * @param name defines camera name
  38552. * @param position defines initial position
  38553. * @param interaxialDistance defines distance between each color axis
  38554. * @param scene defines the hosting scene
  38555. */
  38556. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38557. /**
  38558. * Gets camera class name
  38559. * @returns AnaglyphUniversalCamera
  38560. */
  38561. getClassName(): string;
  38562. }
  38563. }
  38564. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38565. /** @hidden */
  38566. export var stereoscopicInterlacePixelShader: {
  38567. name: string;
  38568. shader: string;
  38569. };
  38570. }
  38571. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38572. import { Camera } from "babylonjs/Cameras/camera";
  38573. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38574. import { Engine } from "babylonjs/Engines/engine";
  38575. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38576. /**
  38577. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38578. */
  38579. export class StereoscopicInterlacePostProcess extends PostProcess {
  38580. private _stepSize;
  38581. private _passedProcess;
  38582. /**
  38583. * Initializes a StereoscopicInterlacePostProcess
  38584. * @param name The name of the effect.
  38585. * @param rigCameras The rig cameras to be appled to the post process
  38586. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38588. * @param engine The engine which the post process will be applied. (default: current engine)
  38589. * @param reusable If the post process can be reused on the same frame. (default: false)
  38590. */
  38591. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38592. }
  38593. }
  38594. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38595. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38596. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38597. import { Scene } from "babylonjs/scene";
  38598. import { Vector3 } from "babylonjs/Maths/math";
  38599. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38600. /**
  38601. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38602. * @see http://doc.babylonjs.com/features/cameras
  38603. */
  38604. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38605. /**
  38606. * Creates a new StereoscopicArcRotateCamera
  38607. * @param name defines camera name
  38608. * @param alpha defines alpha angle (in radians)
  38609. * @param beta defines beta angle (in radians)
  38610. * @param radius defines radius
  38611. * @param target defines camera target
  38612. * @param interaxialDistance defines distance between each color axis
  38613. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38614. * @param scene defines the hosting scene
  38615. */
  38616. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38617. /**
  38618. * Gets camera class name
  38619. * @returns StereoscopicArcRotateCamera
  38620. */
  38621. getClassName(): string;
  38622. }
  38623. }
  38624. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38625. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38626. import { Scene } from "babylonjs/scene";
  38627. import { Vector3 } from "babylonjs/Maths/math";
  38628. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38629. /**
  38630. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38631. * @see http://doc.babylonjs.com/features/cameras
  38632. */
  38633. export class StereoscopicFreeCamera extends FreeCamera {
  38634. /**
  38635. * Creates a new StereoscopicFreeCamera
  38636. * @param name defines camera name
  38637. * @param position defines initial position
  38638. * @param interaxialDistance defines distance between each color axis
  38639. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38640. * @param scene defines the hosting scene
  38641. */
  38642. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38643. /**
  38644. * Gets camera class name
  38645. * @returns StereoscopicFreeCamera
  38646. */
  38647. getClassName(): string;
  38648. }
  38649. }
  38650. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38651. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38652. import { Scene } from "babylonjs/scene";
  38653. import { Vector3 } from "babylonjs/Maths/math";
  38654. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38655. /**
  38656. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38657. * @see http://doc.babylonjs.com/features/cameras
  38658. */
  38659. export class StereoscopicGamepadCamera extends GamepadCamera {
  38660. /**
  38661. * Creates a new StereoscopicGamepadCamera
  38662. * @param name defines camera name
  38663. * @param position defines initial position
  38664. * @param interaxialDistance defines distance between each color axis
  38665. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38666. * @param scene defines the hosting scene
  38667. */
  38668. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38669. /**
  38670. * Gets camera class name
  38671. * @returns StereoscopicGamepadCamera
  38672. */
  38673. getClassName(): string;
  38674. }
  38675. }
  38676. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38677. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38678. import { Scene } from "babylonjs/scene";
  38679. import { Vector3 } from "babylonjs/Maths/math";
  38680. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38681. /**
  38682. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38683. * @see http://doc.babylonjs.com/features/cameras
  38684. */
  38685. export class StereoscopicUniversalCamera extends UniversalCamera {
  38686. /**
  38687. * Creates a new StereoscopicUniversalCamera
  38688. * @param name defines camera name
  38689. * @param position defines initial position
  38690. * @param interaxialDistance defines distance between each color axis
  38691. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38692. * @param scene defines the hosting scene
  38693. */
  38694. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38695. /**
  38696. * Gets camera class name
  38697. * @returns StereoscopicUniversalCamera
  38698. */
  38699. getClassName(): string;
  38700. }
  38701. }
  38702. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38703. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38704. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38705. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38706. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38707. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38708. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38709. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38710. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38711. }
  38712. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38713. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38714. import { Scene } from "babylonjs/scene";
  38715. import { Vector3 } from "babylonjs/Maths/math";
  38716. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38717. /**
  38718. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38719. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38720. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38721. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38722. */
  38723. export class VirtualJoysticksCamera extends FreeCamera {
  38724. /**
  38725. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38726. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38727. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38728. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38729. * @param name Define the name of the camera in the scene
  38730. * @param position Define the start position of the camera in the scene
  38731. * @param scene Define the scene the camera belongs to
  38732. */
  38733. constructor(name: string, position: Vector3, scene: Scene);
  38734. /**
  38735. * Gets the current object class name.
  38736. * @return the class name
  38737. */
  38738. getClassName(): string;
  38739. }
  38740. }
  38741. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38742. import { Matrix } from "babylonjs/Maths/math";
  38743. /**
  38744. * This represents all the required metrics to create a VR camera.
  38745. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38746. */
  38747. export class VRCameraMetrics {
  38748. /**
  38749. * Define the horizontal resolution off the screen.
  38750. */
  38751. hResolution: number;
  38752. /**
  38753. * Define the vertical resolution off the screen.
  38754. */
  38755. vResolution: number;
  38756. /**
  38757. * Define the horizontal screen size.
  38758. */
  38759. hScreenSize: number;
  38760. /**
  38761. * Define the vertical screen size.
  38762. */
  38763. vScreenSize: number;
  38764. /**
  38765. * Define the vertical screen center position.
  38766. */
  38767. vScreenCenter: number;
  38768. /**
  38769. * Define the distance of the eyes to the screen.
  38770. */
  38771. eyeToScreenDistance: number;
  38772. /**
  38773. * Define the distance between both lenses
  38774. */
  38775. lensSeparationDistance: number;
  38776. /**
  38777. * Define the distance between both viewer's eyes.
  38778. */
  38779. interpupillaryDistance: number;
  38780. /**
  38781. * Define the distortion factor of the VR postprocess.
  38782. * Please, touch with care.
  38783. */
  38784. distortionK: number[];
  38785. /**
  38786. * Define the chromatic aberration correction factors for the VR post process.
  38787. */
  38788. chromaAbCorrection: number[];
  38789. /**
  38790. * Define the scale factor of the post process.
  38791. * The smaller the better but the slower.
  38792. */
  38793. postProcessScaleFactor: number;
  38794. /**
  38795. * Define an offset for the lens center.
  38796. */
  38797. lensCenterOffset: number;
  38798. /**
  38799. * Define if the current vr camera should compensate the distortion of the lense or not.
  38800. */
  38801. compensateDistortion: boolean;
  38802. /**
  38803. * Defines if multiview should be enabled when rendering (Default: false)
  38804. */
  38805. multiviewEnabled: boolean;
  38806. /**
  38807. * Gets the rendering aspect ratio based on the provided resolutions.
  38808. */
  38809. readonly aspectRatio: number;
  38810. /**
  38811. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38812. */
  38813. readonly aspectRatioFov: number;
  38814. /**
  38815. * @hidden
  38816. */
  38817. readonly leftHMatrix: Matrix;
  38818. /**
  38819. * @hidden
  38820. */
  38821. readonly rightHMatrix: Matrix;
  38822. /**
  38823. * @hidden
  38824. */
  38825. readonly leftPreViewMatrix: Matrix;
  38826. /**
  38827. * @hidden
  38828. */
  38829. readonly rightPreViewMatrix: Matrix;
  38830. /**
  38831. * Get the default VRMetrics based on the most generic setup.
  38832. * @returns the default vr metrics
  38833. */
  38834. static GetDefault(): VRCameraMetrics;
  38835. }
  38836. }
  38837. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38838. /** @hidden */
  38839. export var vrDistortionCorrectionPixelShader: {
  38840. name: string;
  38841. shader: string;
  38842. };
  38843. }
  38844. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38845. import { Camera } from "babylonjs/Cameras/camera";
  38846. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38847. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38848. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38849. /**
  38850. * VRDistortionCorrectionPostProcess used for mobile VR
  38851. */
  38852. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38853. private _isRightEye;
  38854. private _distortionFactors;
  38855. private _postProcessScaleFactor;
  38856. private _lensCenterOffset;
  38857. private _scaleIn;
  38858. private _scaleFactor;
  38859. private _lensCenter;
  38860. /**
  38861. * Initializes the VRDistortionCorrectionPostProcess
  38862. * @param name The name of the effect.
  38863. * @param camera The camera to apply the render pass to.
  38864. * @param isRightEye If this is for the right eye distortion
  38865. * @param vrMetrics All the required metrics for the VR camera
  38866. */
  38867. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38868. }
  38869. }
  38870. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38871. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38872. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38873. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38874. import { Scene } from "babylonjs/scene";
  38875. import { Vector3 } from "babylonjs/Maths/math";
  38876. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38877. import "babylonjs/Cameras/RigModes/vrRigMode";
  38878. /**
  38879. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38880. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38881. */
  38882. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38883. /**
  38884. * Creates a new VRDeviceOrientationArcRotateCamera
  38885. * @param name defines camera name
  38886. * @param alpha defines the camera rotation along the logitudinal axis
  38887. * @param beta defines the camera rotation along the latitudinal axis
  38888. * @param radius defines the camera distance from its target
  38889. * @param target defines the camera target
  38890. * @param scene defines the scene the camera belongs to
  38891. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38892. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38893. */
  38894. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38895. /**
  38896. * Gets camera class name
  38897. * @returns VRDeviceOrientationArcRotateCamera
  38898. */
  38899. getClassName(): string;
  38900. }
  38901. }
  38902. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38903. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38904. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38905. import { Scene } from "babylonjs/scene";
  38906. import { Vector3 } from "babylonjs/Maths/math";
  38907. import "babylonjs/Cameras/RigModes/vrRigMode";
  38908. /**
  38909. * Camera used to simulate VR rendering (based on FreeCamera)
  38910. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38911. */
  38912. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38913. /**
  38914. * Creates a new VRDeviceOrientationFreeCamera
  38915. * @param name defines camera name
  38916. * @param position defines the start position of the camera
  38917. * @param scene defines the scene the camera belongs to
  38918. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38919. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38920. */
  38921. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38922. /**
  38923. * Gets camera class name
  38924. * @returns VRDeviceOrientationFreeCamera
  38925. */
  38926. getClassName(): string;
  38927. }
  38928. }
  38929. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38930. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38931. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38932. import { Scene } from "babylonjs/scene";
  38933. import { Vector3 } from "babylonjs/Maths/math";
  38934. /**
  38935. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38936. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38937. */
  38938. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38939. /**
  38940. * Creates a new VRDeviceOrientationGamepadCamera
  38941. * @param name defines camera name
  38942. * @param position defines the start position of the camera
  38943. * @param scene defines the scene the camera belongs to
  38944. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38945. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38946. */
  38947. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38948. /**
  38949. * Gets camera class name
  38950. * @returns VRDeviceOrientationGamepadCamera
  38951. */
  38952. getClassName(): string;
  38953. }
  38954. }
  38955. declare module "babylonjs/Gamepads/xboxGamepad" {
  38956. import { Observable } from "babylonjs/Misc/observable";
  38957. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38958. /**
  38959. * Defines supported buttons for XBox360 compatible gamepads
  38960. */
  38961. export enum Xbox360Button {
  38962. /** A */
  38963. A = 0,
  38964. /** B */
  38965. B = 1,
  38966. /** X */
  38967. X = 2,
  38968. /** Y */
  38969. Y = 3,
  38970. /** Start */
  38971. Start = 4,
  38972. /** Back */
  38973. Back = 5,
  38974. /** Left button */
  38975. LB = 6,
  38976. /** Right button */
  38977. RB = 7,
  38978. /** Left stick */
  38979. LeftStick = 8,
  38980. /** Right stick */
  38981. RightStick = 9
  38982. }
  38983. /** Defines values for XBox360 DPad */
  38984. export enum Xbox360Dpad {
  38985. /** Up */
  38986. Up = 0,
  38987. /** Down */
  38988. Down = 1,
  38989. /** Left */
  38990. Left = 2,
  38991. /** Right */
  38992. Right = 3
  38993. }
  38994. /**
  38995. * Defines a XBox360 gamepad
  38996. */
  38997. export class Xbox360Pad extends Gamepad {
  38998. private _leftTrigger;
  38999. private _rightTrigger;
  39000. private _onlefttriggerchanged;
  39001. private _onrighttriggerchanged;
  39002. private _onbuttondown;
  39003. private _onbuttonup;
  39004. private _ondpaddown;
  39005. private _ondpadup;
  39006. /** Observable raised when a button is pressed */
  39007. onButtonDownObservable: Observable<Xbox360Button>;
  39008. /** Observable raised when a button is released */
  39009. onButtonUpObservable: Observable<Xbox360Button>;
  39010. /** Observable raised when a pad is pressed */
  39011. onPadDownObservable: Observable<Xbox360Dpad>;
  39012. /** Observable raised when a pad is released */
  39013. onPadUpObservable: Observable<Xbox360Dpad>;
  39014. private _buttonA;
  39015. private _buttonB;
  39016. private _buttonX;
  39017. private _buttonY;
  39018. private _buttonBack;
  39019. private _buttonStart;
  39020. private _buttonLB;
  39021. private _buttonRB;
  39022. private _buttonLeftStick;
  39023. private _buttonRightStick;
  39024. private _dPadUp;
  39025. private _dPadDown;
  39026. private _dPadLeft;
  39027. private _dPadRight;
  39028. private _isXboxOnePad;
  39029. /**
  39030. * Creates a new XBox360 gamepad object
  39031. * @param id defines the id of this gamepad
  39032. * @param index defines its index
  39033. * @param gamepad defines the internal HTML gamepad object
  39034. * @param xboxOne defines if it is a XBox One gamepad
  39035. */
  39036. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39037. /**
  39038. * Defines the callback to call when left trigger is pressed
  39039. * @param callback defines the callback to use
  39040. */
  39041. onlefttriggerchanged(callback: (value: number) => void): void;
  39042. /**
  39043. * Defines the callback to call when right trigger is pressed
  39044. * @param callback defines the callback to use
  39045. */
  39046. onrighttriggerchanged(callback: (value: number) => void): void;
  39047. /**
  39048. * Gets the left trigger value
  39049. */
  39050. /**
  39051. * Sets the left trigger value
  39052. */
  39053. leftTrigger: number;
  39054. /**
  39055. * Gets the right trigger value
  39056. */
  39057. /**
  39058. * Sets the right trigger value
  39059. */
  39060. rightTrigger: number;
  39061. /**
  39062. * Defines the callback to call when a button is pressed
  39063. * @param callback defines the callback to use
  39064. */
  39065. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39066. /**
  39067. * Defines the callback to call when a button is released
  39068. * @param callback defines the callback to use
  39069. */
  39070. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39071. /**
  39072. * Defines the callback to call when a pad is pressed
  39073. * @param callback defines the callback to use
  39074. */
  39075. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39076. /**
  39077. * Defines the callback to call when a pad is released
  39078. * @param callback defines the callback to use
  39079. */
  39080. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39081. private _setButtonValue;
  39082. private _setDPadValue;
  39083. /**
  39084. * Gets the value of the `A` button
  39085. */
  39086. /**
  39087. * Sets the value of the `A` button
  39088. */
  39089. buttonA: number;
  39090. /**
  39091. * Gets the value of the `B` button
  39092. */
  39093. /**
  39094. * Sets the value of the `B` button
  39095. */
  39096. buttonB: number;
  39097. /**
  39098. * Gets the value of the `X` button
  39099. */
  39100. /**
  39101. * Sets the value of the `X` button
  39102. */
  39103. buttonX: number;
  39104. /**
  39105. * Gets the value of the `Y` button
  39106. */
  39107. /**
  39108. * Sets the value of the `Y` button
  39109. */
  39110. buttonY: number;
  39111. /**
  39112. * Gets the value of the `Start` button
  39113. */
  39114. /**
  39115. * Sets the value of the `Start` button
  39116. */
  39117. buttonStart: number;
  39118. /**
  39119. * Gets the value of the `Back` button
  39120. */
  39121. /**
  39122. * Sets the value of the `Back` button
  39123. */
  39124. buttonBack: number;
  39125. /**
  39126. * Gets the value of the `Left` button
  39127. */
  39128. /**
  39129. * Sets the value of the `Left` button
  39130. */
  39131. buttonLB: number;
  39132. /**
  39133. * Gets the value of the `Right` button
  39134. */
  39135. /**
  39136. * Sets the value of the `Right` button
  39137. */
  39138. buttonRB: number;
  39139. /**
  39140. * Gets the value of the Left joystick
  39141. */
  39142. /**
  39143. * Sets the value of the Left joystick
  39144. */
  39145. buttonLeftStick: number;
  39146. /**
  39147. * Gets the value of the Right joystick
  39148. */
  39149. /**
  39150. * Sets the value of the Right joystick
  39151. */
  39152. buttonRightStick: number;
  39153. /**
  39154. * Gets the value of D-pad up
  39155. */
  39156. /**
  39157. * Sets the value of D-pad up
  39158. */
  39159. dPadUp: number;
  39160. /**
  39161. * Gets the value of D-pad down
  39162. */
  39163. /**
  39164. * Sets the value of D-pad down
  39165. */
  39166. dPadDown: number;
  39167. /**
  39168. * Gets the value of D-pad left
  39169. */
  39170. /**
  39171. * Sets the value of D-pad left
  39172. */
  39173. dPadLeft: number;
  39174. /**
  39175. * Gets the value of D-pad right
  39176. */
  39177. /**
  39178. * Sets the value of D-pad right
  39179. */
  39180. dPadRight: number;
  39181. /**
  39182. * Force the gamepad to synchronize with device values
  39183. */
  39184. update(): void;
  39185. /**
  39186. * Disposes the gamepad
  39187. */
  39188. dispose(): void;
  39189. }
  39190. }
  39191. declare module "babylonjs/Materials/pushMaterial" {
  39192. import { Nullable } from "babylonjs/types";
  39193. import { Scene } from "babylonjs/scene";
  39194. import { Matrix } from "babylonjs/Maths/math";
  39195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39196. import { Mesh } from "babylonjs/Meshes/mesh";
  39197. import { Material } from "babylonjs/Materials/material";
  39198. import { Effect } from "babylonjs/Materials/effect";
  39199. /**
  39200. * Base class of materials working in push mode in babylon JS
  39201. * @hidden
  39202. */
  39203. export class PushMaterial extends Material {
  39204. protected _activeEffect: Effect;
  39205. protected _normalMatrix: Matrix;
  39206. /**
  39207. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39208. * This means that the material can keep using a previous shader while a new one is being compiled.
  39209. * This is mostly used when shader parallel compilation is supported (true by default)
  39210. */
  39211. allowShaderHotSwapping: boolean;
  39212. constructor(name: string, scene: Scene);
  39213. getEffect(): Effect;
  39214. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39215. /**
  39216. * Binds the given world matrix to the active effect
  39217. *
  39218. * @param world the matrix to bind
  39219. */
  39220. bindOnlyWorldMatrix(world: Matrix): void;
  39221. /**
  39222. * Binds the given normal matrix to the active effect
  39223. *
  39224. * @param normalMatrix the matrix to bind
  39225. */
  39226. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39227. bind(world: Matrix, mesh?: Mesh): void;
  39228. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39229. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39230. }
  39231. }
  39232. declare module "babylonjs/Materials/materialFlags" {
  39233. /**
  39234. * This groups all the flags used to control the materials channel.
  39235. */
  39236. export class MaterialFlags {
  39237. private static _DiffuseTextureEnabled;
  39238. /**
  39239. * Are diffuse textures enabled in the application.
  39240. */
  39241. static DiffuseTextureEnabled: boolean;
  39242. private static _AmbientTextureEnabled;
  39243. /**
  39244. * Are ambient textures enabled in the application.
  39245. */
  39246. static AmbientTextureEnabled: boolean;
  39247. private static _OpacityTextureEnabled;
  39248. /**
  39249. * Are opacity textures enabled in the application.
  39250. */
  39251. static OpacityTextureEnabled: boolean;
  39252. private static _ReflectionTextureEnabled;
  39253. /**
  39254. * Are reflection textures enabled in the application.
  39255. */
  39256. static ReflectionTextureEnabled: boolean;
  39257. private static _EmissiveTextureEnabled;
  39258. /**
  39259. * Are emissive textures enabled in the application.
  39260. */
  39261. static EmissiveTextureEnabled: boolean;
  39262. private static _SpecularTextureEnabled;
  39263. /**
  39264. * Are specular textures enabled in the application.
  39265. */
  39266. static SpecularTextureEnabled: boolean;
  39267. private static _BumpTextureEnabled;
  39268. /**
  39269. * Are bump textures enabled in the application.
  39270. */
  39271. static BumpTextureEnabled: boolean;
  39272. private static _LightmapTextureEnabled;
  39273. /**
  39274. * Are lightmap textures enabled in the application.
  39275. */
  39276. static LightmapTextureEnabled: boolean;
  39277. private static _RefractionTextureEnabled;
  39278. /**
  39279. * Are refraction textures enabled in the application.
  39280. */
  39281. static RefractionTextureEnabled: boolean;
  39282. private static _ColorGradingTextureEnabled;
  39283. /**
  39284. * Are color grading textures enabled in the application.
  39285. */
  39286. static ColorGradingTextureEnabled: boolean;
  39287. private static _FresnelEnabled;
  39288. /**
  39289. * Are fresnels enabled in the application.
  39290. */
  39291. static FresnelEnabled: boolean;
  39292. private static _ClearCoatTextureEnabled;
  39293. /**
  39294. * Are clear coat textures enabled in the application.
  39295. */
  39296. static ClearCoatTextureEnabled: boolean;
  39297. private static _ClearCoatBumpTextureEnabled;
  39298. /**
  39299. * Are clear coat bump textures enabled in the application.
  39300. */
  39301. static ClearCoatBumpTextureEnabled: boolean;
  39302. private static _ClearCoatTintTextureEnabled;
  39303. /**
  39304. * Are clear coat tint textures enabled in the application.
  39305. */
  39306. static ClearCoatTintTextureEnabled: boolean;
  39307. private static _SheenTextureEnabled;
  39308. /**
  39309. * Are sheen textures enabled in the application.
  39310. */
  39311. static SheenTextureEnabled: boolean;
  39312. private static _AnisotropicTextureEnabled;
  39313. /**
  39314. * Are anisotropic textures enabled in the application.
  39315. */
  39316. static AnisotropicTextureEnabled: boolean;
  39317. private static _ThicknessTextureEnabled;
  39318. /**
  39319. * Are thickness textures enabled in the application.
  39320. */
  39321. static ThicknessTextureEnabled: boolean;
  39322. }
  39323. }
  39324. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39325. /** @hidden */
  39326. export var defaultFragmentDeclaration: {
  39327. name: string;
  39328. shader: string;
  39329. };
  39330. }
  39331. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39332. /** @hidden */
  39333. export var defaultUboDeclaration: {
  39334. name: string;
  39335. shader: string;
  39336. };
  39337. }
  39338. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39339. /** @hidden */
  39340. export var lightFragmentDeclaration: {
  39341. name: string;
  39342. shader: string;
  39343. };
  39344. }
  39345. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39346. /** @hidden */
  39347. export var lightUboDeclaration: {
  39348. name: string;
  39349. shader: string;
  39350. };
  39351. }
  39352. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39353. /** @hidden */
  39354. export var lightsFragmentFunctions: {
  39355. name: string;
  39356. shader: string;
  39357. };
  39358. }
  39359. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39360. /** @hidden */
  39361. export var shadowsFragmentFunctions: {
  39362. name: string;
  39363. shader: string;
  39364. };
  39365. }
  39366. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39367. /** @hidden */
  39368. export var fresnelFunction: {
  39369. name: string;
  39370. shader: string;
  39371. };
  39372. }
  39373. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39374. /** @hidden */
  39375. export var reflectionFunction: {
  39376. name: string;
  39377. shader: string;
  39378. };
  39379. }
  39380. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39381. /** @hidden */
  39382. export var bumpFragmentFunctions: {
  39383. name: string;
  39384. shader: string;
  39385. };
  39386. }
  39387. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39388. /** @hidden */
  39389. export var logDepthDeclaration: {
  39390. name: string;
  39391. shader: string;
  39392. };
  39393. }
  39394. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39395. /** @hidden */
  39396. export var bumpFragment: {
  39397. name: string;
  39398. shader: string;
  39399. };
  39400. }
  39401. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39402. /** @hidden */
  39403. export var depthPrePass: {
  39404. name: string;
  39405. shader: string;
  39406. };
  39407. }
  39408. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39409. /** @hidden */
  39410. export var lightFragment: {
  39411. name: string;
  39412. shader: string;
  39413. };
  39414. }
  39415. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39416. /** @hidden */
  39417. export var logDepthFragment: {
  39418. name: string;
  39419. shader: string;
  39420. };
  39421. }
  39422. declare module "babylonjs/Shaders/default.fragment" {
  39423. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39424. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39425. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39426. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39427. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39428. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39429. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39430. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39431. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39432. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39433. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39434. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39435. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39436. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39437. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39438. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39439. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39440. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39441. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39442. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39443. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39444. /** @hidden */
  39445. export var defaultPixelShader: {
  39446. name: string;
  39447. shader: string;
  39448. };
  39449. }
  39450. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39451. /** @hidden */
  39452. export var defaultVertexDeclaration: {
  39453. name: string;
  39454. shader: string;
  39455. };
  39456. }
  39457. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39458. /** @hidden */
  39459. export var bumpVertexDeclaration: {
  39460. name: string;
  39461. shader: string;
  39462. };
  39463. }
  39464. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39465. /** @hidden */
  39466. export var bumpVertex: {
  39467. name: string;
  39468. shader: string;
  39469. };
  39470. }
  39471. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39472. /** @hidden */
  39473. export var fogVertex: {
  39474. name: string;
  39475. shader: string;
  39476. };
  39477. }
  39478. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39479. /** @hidden */
  39480. export var shadowsVertex: {
  39481. name: string;
  39482. shader: string;
  39483. };
  39484. }
  39485. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39486. /** @hidden */
  39487. export var pointCloudVertex: {
  39488. name: string;
  39489. shader: string;
  39490. };
  39491. }
  39492. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39493. /** @hidden */
  39494. export var logDepthVertex: {
  39495. name: string;
  39496. shader: string;
  39497. };
  39498. }
  39499. declare module "babylonjs/Shaders/default.vertex" {
  39500. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39501. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39502. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39503. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39504. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39505. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39506. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39507. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39508. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39509. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39510. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39511. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39512. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39514. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39515. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39516. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39517. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39518. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39519. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39520. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39521. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39522. /** @hidden */
  39523. export var defaultVertexShader: {
  39524. name: string;
  39525. shader: string;
  39526. };
  39527. }
  39528. declare module "babylonjs/Materials/standardMaterial" {
  39529. import { SmartArray } from "babylonjs/Misc/smartArray";
  39530. import { IAnimatable } from "babylonjs/Misc/tools";
  39531. import { Nullable } from "babylonjs/types";
  39532. import { Scene } from "babylonjs/scene";
  39533. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39534. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39536. import { Mesh } from "babylonjs/Meshes/mesh";
  39537. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39538. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39539. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39540. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39541. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39542. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39543. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39544. import "babylonjs/Shaders/default.fragment";
  39545. import "babylonjs/Shaders/default.vertex";
  39546. /** @hidden */
  39547. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39548. MAINUV1: boolean;
  39549. MAINUV2: boolean;
  39550. DIFFUSE: boolean;
  39551. DIFFUSEDIRECTUV: number;
  39552. AMBIENT: boolean;
  39553. AMBIENTDIRECTUV: number;
  39554. OPACITY: boolean;
  39555. OPACITYDIRECTUV: number;
  39556. OPACITYRGB: boolean;
  39557. REFLECTION: boolean;
  39558. EMISSIVE: boolean;
  39559. EMISSIVEDIRECTUV: number;
  39560. SPECULAR: boolean;
  39561. SPECULARDIRECTUV: number;
  39562. BUMP: boolean;
  39563. BUMPDIRECTUV: number;
  39564. PARALLAX: boolean;
  39565. PARALLAXOCCLUSION: boolean;
  39566. SPECULAROVERALPHA: boolean;
  39567. CLIPPLANE: boolean;
  39568. CLIPPLANE2: boolean;
  39569. CLIPPLANE3: boolean;
  39570. CLIPPLANE4: boolean;
  39571. ALPHATEST: boolean;
  39572. DEPTHPREPASS: boolean;
  39573. ALPHAFROMDIFFUSE: boolean;
  39574. POINTSIZE: boolean;
  39575. FOG: boolean;
  39576. SPECULARTERM: boolean;
  39577. DIFFUSEFRESNEL: boolean;
  39578. OPACITYFRESNEL: boolean;
  39579. REFLECTIONFRESNEL: boolean;
  39580. REFRACTIONFRESNEL: boolean;
  39581. EMISSIVEFRESNEL: boolean;
  39582. FRESNEL: boolean;
  39583. NORMAL: boolean;
  39584. UV1: boolean;
  39585. UV2: boolean;
  39586. VERTEXCOLOR: boolean;
  39587. VERTEXALPHA: boolean;
  39588. NUM_BONE_INFLUENCERS: number;
  39589. BonesPerMesh: number;
  39590. BONETEXTURE: boolean;
  39591. INSTANCES: boolean;
  39592. GLOSSINESS: boolean;
  39593. ROUGHNESS: boolean;
  39594. EMISSIVEASILLUMINATION: boolean;
  39595. LINKEMISSIVEWITHDIFFUSE: boolean;
  39596. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39597. LIGHTMAP: boolean;
  39598. LIGHTMAPDIRECTUV: number;
  39599. OBJECTSPACE_NORMALMAP: boolean;
  39600. USELIGHTMAPASSHADOWMAP: boolean;
  39601. REFLECTIONMAP_3D: boolean;
  39602. REFLECTIONMAP_SPHERICAL: boolean;
  39603. REFLECTIONMAP_PLANAR: boolean;
  39604. REFLECTIONMAP_CUBIC: boolean;
  39605. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39606. REFLECTIONMAP_PROJECTION: boolean;
  39607. REFLECTIONMAP_SKYBOX: boolean;
  39608. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39609. REFLECTIONMAP_EXPLICIT: boolean;
  39610. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39611. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39612. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39613. INVERTCUBICMAP: boolean;
  39614. LOGARITHMICDEPTH: boolean;
  39615. REFRACTION: boolean;
  39616. REFRACTIONMAP_3D: boolean;
  39617. REFLECTIONOVERALPHA: boolean;
  39618. TWOSIDEDLIGHTING: boolean;
  39619. SHADOWFLOAT: boolean;
  39620. MORPHTARGETS: boolean;
  39621. MORPHTARGETS_NORMAL: boolean;
  39622. MORPHTARGETS_TANGENT: boolean;
  39623. NUM_MORPH_INFLUENCERS: number;
  39624. NONUNIFORMSCALING: boolean;
  39625. PREMULTIPLYALPHA: boolean;
  39626. IMAGEPROCESSING: boolean;
  39627. VIGNETTE: boolean;
  39628. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39629. VIGNETTEBLENDMODEOPAQUE: boolean;
  39630. TONEMAPPING: boolean;
  39631. TONEMAPPING_ACES: boolean;
  39632. CONTRAST: boolean;
  39633. COLORCURVES: boolean;
  39634. COLORGRADING: boolean;
  39635. COLORGRADING3D: boolean;
  39636. SAMPLER3DGREENDEPTH: boolean;
  39637. SAMPLER3DBGRMAP: boolean;
  39638. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39639. MULTIVIEW: boolean;
  39640. /**
  39641. * If the reflection texture on this material is in linear color space
  39642. * @hidden
  39643. */
  39644. IS_REFLECTION_LINEAR: boolean;
  39645. /**
  39646. * If the refraction texture on this material is in linear color space
  39647. * @hidden
  39648. */
  39649. IS_REFRACTION_LINEAR: boolean;
  39650. EXPOSURE: boolean;
  39651. constructor();
  39652. setReflectionMode(modeToEnable: string): void;
  39653. }
  39654. /**
  39655. * This is the default material used in Babylon. It is the best trade off between quality
  39656. * and performances.
  39657. * @see http://doc.babylonjs.com/babylon101/materials
  39658. */
  39659. export class StandardMaterial extends PushMaterial {
  39660. private _diffuseTexture;
  39661. /**
  39662. * The basic texture of the material as viewed under a light.
  39663. */
  39664. diffuseTexture: Nullable<BaseTexture>;
  39665. private _ambientTexture;
  39666. /**
  39667. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39668. */
  39669. ambientTexture: Nullable<BaseTexture>;
  39670. private _opacityTexture;
  39671. /**
  39672. * Define the transparency of the material from a texture.
  39673. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39674. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39675. */
  39676. opacityTexture: Nullable<BaseTexture>;
  39677. private _reflectionTexture;
  39678. /**
  39679. * Define the texture used to display the reflection.
  39680. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39681. */
  39682. reflectionTexture: Nullable<BaseTexture>;
  39683. private _emissiveTexture;
  39684. /**
  39685. * Define texture of the material as if self lit.
  39686. * This will be mixed in the final result even in the absence of light.
  39687. */
  39688. emissiveTexture: Nullable<BaseTexture>;
  39689. private _specularTexture;
  39690. /**
  39691. * Define how the color and intensity of the highlight given by the light in the material.
  39692. */
  39693. specularTexture: Nullable<BaseTexture>;
  39694. private _bumpTexture;
  39695. /**
  39696. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39697. * 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.
  39698. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39699. */
  39700. bumpTexture: Nullable<BaseTexture>;
  39701. private _lightmapTexture;
  39702. /**
  39703. * Complex lighting can be computationally expensive to compute at runtime.
  39704. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39705. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39706. */
  39707. lightmapTexture: Nullable<BaseTexture>;
  39708. private _refractionTexture;
  39709. /**
  39710. * Define the texture used to display the refraction.
  39711. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39712. */
  39713. refractionTexture: Nullable<BaseTexture>;
  39714. /**
  39715. * The color of the material lit by the environmental background lighting.
  39716. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39717. */
  39718. ambientColor: Color3;
  39719. /**
  39720. * The basic color of the material as viewed under a light.
  39721. */
  39722. diffuseColor: Color3;
  39723. /**
  39724. * Define how the color and intensity of the highlight given by the light in the material.
  39725. */
  39726. specularColor: Color3;
  39727. /**
  39728. * Define the color of the material as if self lit.
  39729. * This will be mixed in the final result even in the absence of light.
  39730. */
  39731. emissiveColor: Color3;
  39732. /**
  39733. * Defines how sharp are the highlights in the material.
  39734. * The bigger the value the sharper giving a more glossy feeling to the result.
  39735. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39736. */
  39737. specularPower: number;
  39738. private _useAlphaFromDiffuseTexture;
  39739. /**
  39740. * Does the transparency come from the diffuse texture alpha channel.
  39741. */
  39742. useAlphaFromDiffuseTexture: boolean;
  39743. private _useEmissiveAsIllumination;
  39744. /**
  39745. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39746. */
  39747. useEmissiveAsIllumination: boolean;
  39748. private _linkEmissiveWithDiffuse;
  39749. /**
  39750. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39751. * the emissive level when the final color is close to one.
  39752. */
  39753. linkEmissiveWithDiffuse: boolean;
  39754. private _useSpecularOverAlpha;
  39755. /**
  39756. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39757. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39758. */
  39759. useSpecularOverAlpha: boolean;
  39760. private _useReflectionOverAlpha;
  39761. /**
  39762. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39763. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39764. */
  39765. useReflectionOverAlpha: boolean;
  39766. private _disableLighting;
  39767. /**
  39768. * Does lights from the scene impacts this material.
  39769. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39770. */
  39771. disableLighting: boolean;
  39772. private _useObjectSpaceNormalMap;
  39773. /**
  39774. * Allows using an object space normal map (instead of tangent space).
  39775. */
  39776. useObjectSpaceNormalMap: boolean;
  39777. private _useParallax;
  39778. /**
  39779. * Is parallax enabled or not.
  39780. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39781. */
  39782. useParallax: boolean;
  39783. private _useParallaxOcclusion;
  39784. /**
  39785. * Is parallax occlusion enabled or not.
  39786. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39787. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39788. */
  39789. useParallaxOcclusion: boolean;
  39790. /**
  39791. * 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.
  39792. */
  39793. parallaxScaleBias: number;
  39794. private _roughness;
  39795. /**
  39796. * Helps to define how blurry the reflections should appears in the material.
  39797. */
  39798. roughness: number;
  39799. /**
  39800. * In case of refraction, define the value of the indice of refraction.
  39801. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39802. */
  39803. indexOfRefraction: number;
  39804. /**
  39805. * Invert the refraction texture alongside the y axis.
  39806. * It can be useful with procedural textures or probe for instance.
  39807. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39808. */
  39809. invertRefractionY: boolean;
  39810. /**
  39811. * Defines the alpha limits in alpha test mode.
  39812. */
  39813. alphaCutOff: number;
  39814. private _useLightmapAsShadowmap;
  39815. /**
  39816. * In case of light mapping, define whether the map contains light or shadow informations.
  39817. */
  39818. useLightmapAsShadowmap: boolean;
  39819. private _diffuseFresnelParameters;
  39820. /**
  39821. * Define the diffuse fresnel parameters of the material.
  39822. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39823. */
  39824. diffuseFresnelParameters: FresnelParameters;
  39825. private _opacityFresnelParameters;
  39826. /**
  39827. * Define the opacity fresnel parameters of the material.
  39828. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39829. */
  39830. opacityFresnelParameters: FresnelParameters;
  39831. private _reflectionFresnelParameters;
  39832. /**
  39833. * Define the reflection fresnel parameters of the material.
  39834. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39835. */
  39836. reflectionFresnelParameters: FresnelParameters;
  39837. private _refractionFresnelParameters;
  39838. /**
  39839. * Define the refraction fresnel parameters of the material.
  39840. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39841. */
  39842. refractionFresnelParameters: FresnelParameters;
  39843. private _emissiveFresnelParameters;
  39844. /**
  39845. * Define the emissive fresnel parameters of the material.
  39846. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39847. */
  39848. emissiveFresnelParameters: FresnelParameters;
  39849. private _useReflectionFresnelFromSpecular;
  39850. /**
  39851. * If true automatically deducts the fresnels values from the material specularity.
  39852. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39853. */
  39854. useReflectionFresnelFromSpecular: boolean;
  39855. private _useGlossinessFromSpecularMapAlpha;
  39856. /**
  39857. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39858. */
  39859. useGlossinessFromSpecularMapAlpha: boolean;
  39860. private _maxSimultaneousLights;
  39861. /**
  39862. * Defines the maximum number of lights that can be used in the material
  39863. */
  39864. maxSimultaneousLights: number;
  39865. private _invertNormalMapX;
  39866. /**
  39867. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39868. */
  39869. invertNormalMapX: boolean;
  39870. private _invertNormalMapY;
  39871. /**
  39872. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39873. */
  39874. invertNormalMapY: boolean;
  39875. private _twoSidedLighting;
  39876. /**
  39877. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39878. */
  39879. twoSidedLighting: boolean;
  39880. /**
  39881. * Default configuration related to image processing available in the standard Material.
  39882. */
  39883. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39884. /**
  39885. * Gets the image processing configuration used either in this material.
  39886. */
  39887. /**
  39888. * Sets the Default image processing configuration used either in the this material.
  39889. *
  39890. * If sets to null, the scene one is in use.
  39891. */
  39892. imageProcessingConfiguration: ImageProcessingConfiguration;
  39893. /**
  39894. * Keep track of the image processing observer to allow dispose and replace.
  39895. */
  39896. private _imageProcessingObserver;
  39897. /**
  39898. * Attaches a new image processing configuration to the Standard Material.
  39899. * @param configuration
  39900. */
  39901. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39902. /**
  39903. * Gets wether the color curves effect is enabled.
  39904. */
  39905. /**
  39906. * Sets wether the color curves effect is enabled.
  39907. */
  39908. cameraColorCurvesEnabled: boolean;
  39909. /**
  39910. * Gets wether the color grading effect is enabled.
  39911. */
  39912. /**
  39913. * Gets wether the color grading effect is enabled.
  39914. */
  39915. cameraColorGradingEnabled: boolean;
  39916. /**
  39917. * Gets wether tonemapping is enabled or not.
  39918. */
  39919. /**
  39920. * Sets wether tonemapping is enabled or not
  39921. */
  39922. cameraToneMappingEnabled: boolean;
  39923. /**
  39924. * The camera exposure used on this material.
  39925. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39926. * This corresponds to a photographic exposure.
  39927. */
  39928. /**
  39929. * The camera exposure used on this material.
  39930. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39931. * This corresponds to a photographic exposure.
  39932. */
  39933. cameraExposure: number;
  39934. /**
  39935. * Gets The camera contrast used on this material.
  39936. */
  39937. /**
  39938. * Sets The camera contrast used on this material.
  39939. */
  39940. cameraContrast: number;
  39941. /**
  39942. * Gets the Color Grading 2D Lookup Texture.
  39943. */
  39944. /**
  39945. * Sets the Color Grading 2D Lookup Texture.
  39946. */
  39947. cameraColorGradingTexture: Nullable<BaseTexture>;
  39948. /**
  39949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39951. * 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;
  39952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39953. */
  39954. /**
  39955. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39956. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39957. * 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;
  39958. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39959. */
  39960. cameraColorCurves: Nullable<ColorCurves>;
  39961. /**
  39962. * Custom callback helping to override the default shader used in the material.
  39963. */
  39964. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39965. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39966. protected _worldViewProjectionMatrix: Matrix;
  39967. protected _globalAmbientColor: Color3;
  39968. protected _useLogarithmicDepth: boolean;
  39969. /**
  39970. * Instantiates a new standard material.
  39971. * This is the default material used in Babylon. It is the best trade off between quality
  39972. * and performances.
  39973. * @see http://doc.babylonjs.com/babylon101/materials
  39974. * @param name Define the name of the material in the scene
  39975. * @param scene Define the scene the material belong to
  39976. */
  39977. constructor(name: string, scene: Scene);
  39978. /**
  39979. * Gets a boolean indicating that current material needs to register RTT
  39980. */
  39981. readonly hasRenderTargetTextures: boolean;
  39982. /**
  39983. * Gets the current class name of the material e.g. "StandardMaterial"
  39984. * Mainly use in serialization.
  39985. * @returns the class name
  39986. */
  39987. getClassName(): string;
  39988. /**
  39989. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39990. * You can try switching to logarithmic depth.
  39991. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39992. */
  39993. useLogarithmicDepth: boolean;
  39994. /**
  39995. * Specifies if the material will require alpha blending
  39996. * @returns a boolean specifying if alpha blending is needed
  39997. */
  39998. needAlphaBlending(): boolean;
  39999. /**
  40000. * Specifies if this material should be rendered in alpha test mode
  40001. * @returns a boolean specifying if an alpha test is needed.
  40002. */
  40003. needAlphaTesting(): boolean;
  40004. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40005. /**
  40006. * Get the texture used for alpha test purpose.
  40007. * @returns the diffuse texture in case of the standard material.
  40008. */
  40009. getAlphaTestTexture(): Nullable<BaseTexture>;
  40010. /**
  40011. * Get if the submesh is ready to be used and all its information available.
  40012. * Child classes can use it to update shaders
  40013. * @param mesh defines the mesh to check
  40014. * @param subMesh defines which submesh to check
  40015. * @param useInstances specifies that instances should be used
  40016. * @returns a boolean indicating that the submesh is ready or not
  40017. */
  40018. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40019. /**
  40020. * Builds the material UBO layouts.
  40021. * Used internally during the effect preparation.
  40022. */
  40023. buildUniformLayout(): void;
  40024. /**
  40025. * Unbinds the material from the mesh
  40026. */
  40027. unbind(): void;
  40028. /**
  40029. * Binds the submesh to this material by preparing the effect and shader to draw
  40030. * @param world defines the world transformation matrix
  40031. * @param mesh defines the mesh containing the submesh
  40032. * @param subMesh defines the submesh to bind the material to
  40033. */
  40034. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40035. /**
  40036. * Get the list of animatables in the material.
  40037. * @returns the list of animatables object used in the material
  40038. */
  40039. getAnimatables(): IAnimatable[];
  40040. /**
  40041. * Gets the active textures from the material
  40042. * @returns an array of textures
  40043. */
  40044. getActiveTextures(): BaseTexture[];
  40045. /**
  40046. * Specifies if the material uses a texture
  40047. * @param texture defines the texture to check against the material
  40048. * @returns a boolean specifying if the material uses the texture
  40049. */
  40050. hasTexture(texture: BaseTexture): boolean;
  40051. /**
  40052. * Disposes the material
  40053. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40054. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40055. */
  40056. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40057. /**
  40058. * Makes a duplicate of the material, and gives it a new name
  40059. * @param name defines the new name for the duplicated material
  40060. * @returns the cloned material
  40061. */
  40062. clone(name: string): StandardMaterial;
  40063. /**
  40064. * Serializes this material in a JSON representation
  40065. * @returns the serialized material object
  40066. */
  40067. serialize(): any;
  40068. /**
  40069. * Creates a standard material from parsed material data
  40070. * @param source defines the JSON representation of the material
  40071. * @param scene defines the hosting scene
  40072. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40073. * @returns a new standard material
  40074. */
  40075. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40076. /**
  40077. * Are diffuse textures enabled in the application.
  40078. */
  40079. static DiffuseTextureEnabled: boolean;
  40080. /**
  40081. * Are ambient textures enabled in the application.
  40082. */
  40083. static AmbientTextureEnabled: boolean;
  40084. /**
  40085. * Are opacity textures enabled in the application.
  40086. */
  40087. static OpacityTextureEnabled: boolean;
  40088. /**
  40089. * Are reflection textures enabled in the application.
  40090. */
  40091. static ReflectionTextureEnabled: boolean;
  40092. /**
  40093. * Are emissive textures enabled in the application.
  40094. */
  40095. static EmissiveTextureEnabled: boolean;
  40096. /**
  40097. * Are specular textures enabled in the application.
  40098. */
  40099. static SpecularTextureEnabled: boolean;
  40100. /**
  40101. * Are bump textures enabled in the application.
  40102. */
  40103. static BumpTextureEnabled: boolean;
  40104. /**
  40105. * Are lightmap textures enabled in the application.
  40106. */
  40107. static LightmapTextureEnabled: boolean;
  40108. /**
  40109. * Are refraction textures enabled in the application.
  40110. */
  40111. static RefractionTextureEnabled: boolean;
  40112. /**
  40113. * Are color grading textures enabled in the application.
  40114. */
  40115. static ColorGradingTextureEnabled: boolean;
  40116. /**
  40117. * Are fresnels enabled in the application.
  40118. */
  40119. static FresnelEnabled: boolean;
  40120. }
  40121. }
  40122. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40123. import { Scene } from "babylonjs/scene";
  40124. import { Texture } from "babylonjs/Materials/Textures/texture";
  40125. /**
  40126. * A class extending Texture allowing drawing on a texture
  40127. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40128. */
  40129. export class DynamicTexture extends Texture {
  40130. private _generateMipMaps;
  40131. private _canvas;
  40132. private _context;
  40133. private _engine;
  40134. /**
  40135. * Creates a DynamicTexture
  40136. * @param name defines the name of the texture
  40137. * @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
  40138. * @param scene defines the scene where you want the texture
  40139. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40140. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40141. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40142. */
  40143. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40144. /**
  40145. * Get the current class name of the texture useful for serialization or dynamic coding.
  40146. * @returns "DynamicTexture"
  40147. */
  40148. getClassName(): string;
  40149. /**
  40150. * Gets the current state of canRescale
  40151. */
  40152. readonly canRescale: boolean;
  40153. private _recreate;
  40154. /**
  40155. * Scales the texture
  40156. * @param ratio the scale factor to apply to both width and height
  40157. */
  40158. scale(ratio: number): void;
  40159. /**
  40160. * Resizes the texture
  40161. * @param width the new width
  40162. * @param height the new height
  40163. */
  40164. scaleTo(width: number, height: number): void;
  40165. /**
  40166. * Gets the context of the canvas used by the texture
  40167. * @returns the canvas context of the dynamic texture
  40168. */
  40169. getContext(): CanvasRenderingContext2D;
  40170. /**
  40171. * Clears the texture
  40172. */
  40173. clear(): void;
  40174. /**
  40175. * Updates the texture
  40176. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40177. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40178. */
  40179. update(invertY?: boolean, premulAlpha?: boolean): void;
  40180. /**
  40181. * Draws text onto the texture
  40182. * @param text defines the text to be drawn
  40183. * @param x defines the placement of the text from the left
  40184. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40185. * @param font defines the font to be used with font-style, font-size, font-name
  40186. * @param color defines the color used for the text
  40187. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40188. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40189. * @param update defines whether texture is immediately update (default is true)
  40190. */
  40191. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40192. /**
  40193. * Clones the texture
  40194. * @returns the clone of the texture.
  40195. */
  40196. clone(): DynamicTexture;
  40197. /**
  40198. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40199. * @returns a serialized dynamic texture object
  40200. */
  40201. serialize(): any;
  40202. /** @hidden */
  40203. _rebuild(): void;
  40204. }
  40205. }
  40206. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40207. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40209. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40210. /** @hidden */
  40211. export var imageProcessingPixelShader: {
  40212. name: string;
  40213. shader: string;
  40214. };
  40215. }
  40216. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40217. import { Nullable } from "babylonjs/types";
  40218. import { Color4 } from "babylonjs/Maths/math";
  40219. import { Camera } from "babylonjs/Cameras/camera";
  40220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40221. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40222. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40223. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40224. import { Engine } from "babylonjs/Engines/engine";
  40225. import "babylonjs/Shaders/imageProcessing.fragment";
  40226. import "babylonjs/Shaders/postprocess.vertex";
  40227. /**
  40228. * ImageProcessingPostProcess
  40229. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40230. */
  40231. export class ImageProcessingPostProcess extends PostProcess {
  40232. /**
  40233. * Default configuration related to image processing available in the PBR Material.
  40234. */
  40235. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40236. /**
  40237. * Gets the image processing configuration used either in this material.
  40238. */
  40239. /**
  40240. * Sets the Default image processing configuration used either in the this material.
  40241. *
  40242. * If sets to null, the scene one is in use.
  40243. */
  40244. imageProcessingConfiguration: ImageProcessingConfiguration;
  40245. /**
  40246. * Keep track of the image processing observer to allow dispose and replace.
  40247. */
  40248. private _imageProcessingObserver;
  40249. /**
  40250. * Attaches a new image processing configuration to the PBR Material.
  40251. * @param configuration
  40252. */
  40253. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40254. /**
  40255. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40256. */
  40257. /**
  40258. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40259. */
  40260. colorCurves: Nullable<ColorCurves>;
  40261. /**
  40262. * Gets wether the color curves effect is enabled.
  40263. */
  40264. /**
  40265. * Sets wether the color curves effect is enabled.
  40266. */
  40267. colorCurvesEnabled: boolean;
  40268. /**
  40269. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40270. */
  40271. /**
  40272. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40273. */
  40274. colorGradingTexture: Nullable<BaseTexture>;
  40275. /**
  40276. * Gets wether the color grading effect is enabled.
  40277. */
  40278. /**
  40279. * Gets wether the color grading effect is enabled.
  40280. */
  40281. colorGradingEnabled: boolean;
  40282. /**
  40283. * Gets exposure used in the effect.
  40284. */
  40285. /**
  40286. * Sets exposure used in the effect.
  40287. */
  40288. exposure: number;
  40289. /**
  40290. * Gets wether tonemapping is enabled or not.
  40291. */
  40292. /**
  40293. * Sets wether tonemapping is enabled or not
  40294. */
  40295. toneMappingEnabled: boolean;
  40296. /**
  40297. * Gets the type of tone mapping effect.
  40298. */
  40299. /**
  40300. * Sets the type of tone mapping effect.
  40301. */
  40302. toneMappingType: number;
  40303. /**
  40304. * Gets contrast used in the effect.
  40305. */
  40306. /**
  40307. * Sets contrast used in the effect.
  40308. */
  40309. contrast: number;
  40310. /**
  40311. * Gets Vignette stretch size.
  40312. */
  40313. /**
  40314. * Sets Vignette stretch size.
  40315. */
  40316. vignetteStretch: number;
  40317. /**
  40318. * Gets Vignette centre X Offset.
  40319. */
  40320. /**
  40321. * Sets Vignette centre X Offset.
  40322. */
  40323. vignetteCentreX: number;
  40324. /**
  40325. * Gets Vignette centre Y Offset.
  40326. */
  40327. /**
  40328. * Sets Vignette centre Y Offset.
  40329. */
  40330. vignetteCentreY: number;
  40331. /**
  40332. * Gets Vignette weight or intensity of the vignette effect.
  40333. */
  40334. /**
  40335. * Sets Vignette weight or intensity of the vignette effect.
  40336. */
  40337. vignetteWeight: number;
  40338. /**
  40339. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40340. * if vignetteEnabled is set to true.
  40341. */
  40342. /**
  40343. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40344. * if vignetteEnabled is set to true.
  40345. */
  40346. vignetteColor: Color4;
  40347. /**
  40348. * Gets Camera field of view used by the Vignette effect.
  40349. */
  40350. /**
  40351. * Sets Camera field of view used by the Vignette effect.
  40352. */
  40353. vignetteCameraFov: number;
  40354. /**
  40355. * Gets the vignette blend mode allowing different kind of effect.
  40356. */
  40357. /**
  40358. * Sets the vignette blend mode allowing different kind of effect.
  40359. */
  40360. vignetteBlendMode: number;
  40361. /**
  40362. * Gets wether the vignette effect is enabled.
  40363. */
  40364. /**
  40365. * Sets wether the vignette effect is enabled.
  40366. */
  40367. vignetteEnabled: boolean;
  40368. private _fromLinearSpace;
  40369. /**
  40370. * Gets wether the input of the processing is in Gamma or Linear Space.
  40371. */
  40372. /**
  40373. * Sets wether the input of the processing is in Gamma or Linear Space.
  40374. */
  40375. fromLinearSpace: boolean;
  40376. /**
  40377. * Defines cache preventing GC.
  40378. */
  40379. private _defines;
  40380. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40381. /**
  40382. * "ImageProcessingPostProcess"
  40383. * @returns "ImageProcessingPostProcess"
  40384. */
  40385. getClassName(): string;
  40386. protected _updateParameters(): void;
  40387. dispose(camera?: Camera): void;
  40388. }
  40389. }
  40390. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40391. import { Scene } from "babylonjs/scene";
  40392. import { Color3 } from "babylonjs/Maths/math";
  40393. import { Mesh } from "babylonjs/Meshes/mesh";
  40394. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40395. import { Nullable } from "babylonjs/types";
  40396. /**
  40397. * Class containing static functions to help procedurally build meshes
  40398. */
  40399. export class GroundBuilder {
  40400. /**
  40401. * Creates a ground mesh
  40402. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40403. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40405. * @param name defines the name of the mesh
  40406. * @param options defines the options used to create the mesh
  40407. * @param scene defines the hosting scene
  40408. * @returns the ground mesh
  40409. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40410. */
  40411. static CreateGround(name: string, options: {
  40412. width?: number;
  40413. height?: number;
  40414. subdivisions?: number;
  40415. subdivisionsX?: number;
  40416. subdivisionsY?: number;
  40417. updatable?: boolean;
  40418. }, scene: any): Mesh;
  40419. /**
  40420. * Creates a tiled ground mesh
  40421. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40422. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40423. * * 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
  40424. * * 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
  40425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40426. * @param name defines the name of the mesh
  40427. * @param options defines the options used to create the mesh
  40428. * @param scene defines the hosting scene
  40429. * @returns the tiled ground mesh
  40430. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40431. */
  40432. static CreateTiledGround(name: string, options: {
  40433. xmin: number;
  40434. zmin: number;
  40435. xmax: number;
  40436. zmax: number;
  40437. subdivisions?: {
  40438. w: number;
  40439. h: number;
  40440. };
  40441. precision?: {
  40442. w: number;
  40443. h: number;
  40444. };
  40445. updatable?: boolean;
  40446. }, scene?: Nullable<Scene>): Mesh;
  40447. /**
  40448. * Creates a ground mesh from a height map
  40449. * * The parameter `url` sets the URL of the height map image resource.
  40450. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40451. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40452. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40453. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40454. * * 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.
  40455. * * 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).
  40456. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40458. * @param name defines the name of the mesh
  40459. * @param url defines the url to the height map
  40460. * @param options defines the options used to create the mesh
  40461. * @param scene defines the hosting scene
  40462. * @returns the ground mesh
  40463. * @see https://doc.babylonjs.com/babylon101/height_map
  40464. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40465. */
  40466. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40467. width?: number;
  40468. height?: number;
  40469. subdivisions?: number;
  40470. minHeight?: number;
  40471. maxHeight?: number;
  40472. colorFilter?: Color3;
  40473. alphaFilter?: number;
  40474. updatable?: boolean;
  40475. onReady?: (mesh: GroundMesh) => void;
  40476. }, scene?: Nullable<Scene>): GroundMesh;
  40477. }
  40478. }
  40479. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40480. import { Vector4 } from "babylonjs/Maths/math";
  40481. import { Mesh } from "babylonjs/Meshes/mesh";
  40482. /**
  40483. * Class containing static functions to help procedurally build meshes
  40484. */
  40485. export class TorusBuilder {
  40486. /**
  40487. * Creates a torus mesh
  40488. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40489. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40490. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40494. * @param name defines the name of the mesh
  40495. * @param options defines the options used to create the mesh
  40496. * @param scene defines the hosting scene
  40497. * @returns the torus mesh
  40498. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40499. */
  40500. static CreateTorus(name: string, options: {
  40501. diameter?: number;
  40502. thickness?: number;
  40503. tessellation?: number;
  40504. updatable?: boolean;
  40505. sideOrientation?: number;
  40506. frontUVs?: Vector4;
  40507. backUVs?: Vector4;
  40508. }, scene: any): Mesh;
  40509. }
  40510. }
  40511. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40512. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40513. import { Mesh } from "babylonjs/Meshes/mesh";
  40514. /**
  40515. * Class containing static functions to help procedurally build meshes
  40516. */
  40517. export class CylinderBuilder {
  40518. /**
  40519. * Creates a cylinder or a cone mesh
  40520. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40521. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40522. * * 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.
  40523. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40524. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40525. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40526. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40527. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40528. * * 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).
  40529. * * 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
  40530. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40531. * * 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
  40532. * * 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.
  40533. * * If `enclose` is false, a ring surface is one element.
  40534. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40535. * * 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
  40536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40539. * @param name defines the name of the mesh
  40540. * @param options defines the options used to create the mesh
  40541. * @param scene defines the hosting scene
  40542. * @returns the cylinder mesh
  40543. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40544. */
  40545. static CreateCylinder(name: string, options: {
  40546. height?: number;
  40547. diameterTop?: number;
  40548. diameterBottom?: number;
  40549. diameter?: number;
  40550. tessellation?: number;
  40551. subdivisions?: number;
  40552. arc?: number;
  40553. faceColors?: Color4[];
  40554. faceUV?: Vector4[];
  40555. updatable?: boolean;
  40556. hasRings?: boolean;
  40557. enclose?: boolean;
  40558. sideOrientation?: number;
  40559. frontUVs?: Vector4;
  40560. backUVs?: Vector4;
  40561. }, scene: any): Mesh;
  40562. }
  40563. }
  40564. declare module "babylonjs/Gamepads/gamepadManager" {
  40565. import { Observable } from "babylonjs/Misc/observable";
  40566. import { Nullable } from "babylonjs/types";
  40567. import { Scene } from "babylonjs/scene";
  40568. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40569. /**
  40570. * Manager for handling gamepads
  40571. */
  40572. export class GamepadManager {
  40573. private _scene?;
  40574. private _babylonGamepads;
  40575. private _oneGamepadConnected;
  40576. /** @hidden */
  40577. _isMonitoring: boolean;
  40578. private _gamepadEventSupported;
  40579. private _gamepadSupport;
  40580. /**
  40581. * observable to be triggered when the gamepad controller has been connected
  40582. */
  40583. onGamepadConnectedObservable: Observable<Gamepad>;
  40584. /**
  40585. * observable to be triggered when the gamepad controller has been disconnected
  40586. */
  40587. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40588. private _onGamepadConnectedEvent;
  40589. private _onGamepadDisconnectedEvent;
  40590. /**
  40591. * Initializes the gamepad manager
  40592. * @param _scene BabylonJS scene
  40593. */
  40594. constructor(_scene?: Scene | undefined);
  40595. /**
  40596. * The gamepads in the game pad manager
  40597. */
  40598. readonly gamepads: Gamepad[];
  40599. /**
  40600. * Get the gamepad controllers based on type
  40601. * @param type The type of gamepad controller
  40602. * @returns Nullable gamepad
  40603. */
  40604. getGamepadByType(type?: number): Nullable<Gamepad>;
  40605. /**
  40606. * Disposes the gamepad manager
  40607. */
  40608. dispose(): void;
  40609. private _addNewGamepad;
  40610. private _startMonitoringGamepads;
  40611. private _stopMonitoringGamepads;
  40612. /** @hidden */
  40613. _checkGamepadsStatus(): void;
  40614. private _updateGamepadObjects;
  40615. }
  40616. }
  40617. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40618. import { Nullable } from "babylonjs/types";
  40619. import { Scene } from "babylonjs/scene";
  40620. import { ISceneComponent } from "babylonjs/sceneComponent";
  40621. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40622. module "babylonjs/scene" {
  40623. interface Scene {
  40624. /** @hidden */
  40625. _gamepadManager: Nullable<GamepadManager>;
  40626. /**
  40627. * Gets the gamepad manager associated with the scene
  40628. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40629. */
  40630. gamepadManager: GamepadManager;
  40631. }
  40632. }
  40633. module "babylonjs/Cameras/freeCameraInputsManager" {
  40634. /**
  40635. * Interface representing a free camera inputs manager
  40636. */
  40637. interface FreeCameraInputsManager {
  40638. /**
  40639. * Adds gamepad input support to the FreeCameraInputsManager.
  40640. * @returns the FreeCameraInputsManager
  40641. */
  40642. addGamepad(): FreeCameraInputsManager;
  40643. }
  40644. }
  40645. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40646. /**
  40647. * Interface representing an arc rotate camera inputs manager
  40648. */
  40649. interface ArcRotateCameraInputsManager {
  40650. /**
  40651. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40652. * @returns the camera inputs manager
  40653. */
  40654. addGamepad(): ArcRotateCameraInputsManager;
  40655. }
  40656. }
  40657. /**
  40658. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40659. */
  40660. export class GamepadSystemSceneComponent implements ISceneComponent {
  40661. /**
  40662. * The component name helpfull to identify the component in the list of scene components.
  40663. */
  40664. readonly name: string;
  40665. /**
  40666. * The scene the component belongs to.
  40667. */
  40668. scene: Scene;
  40669. /**
  40670. * Creates a new instance of the component for the given scene
  40671. * @param scene Defines the scene to register the component in
  40672. */
  40673. constructor(scene: Scene);
  40674. /**
  40675. * Registers the component in a given scene
  40676. */
  40677. register(): void;
  40678. /**
  40679. * Rebuilds the elements related to this component in case of
  40680. * context lost for instance.
  40681. */
  40682. rebuild(): void;
  40683. /**
  40684. * Disposes the component and the associated ressources
  40685. */
  40686. dispose(): void;
  40687. private _beforeCameraUpdate;
  40688. }
  40689. }
  40690. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40691. import { Observable } from "babylonjs/Misc/observable";
  40692. import { Nullable } from "babylonjs/types";
  40693. import { Camera } from "babylonjs/Cameras/camera";
  40694. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40695. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40696. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40697. import { Scene } from "babylonjs/scene";
  40698. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40699. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40701. import { Mesh } from "babylonjs/Meshes/mesh";
  40702. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40703. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40704. import "babylonjs/Meshes/Builders/groundBuilder";
  40705. import "babylonjs/Meshes/Builders/torusBuilder";
  40706. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40707. import "babylonjs/Gamepads/gamepadSceneComponent";
  40708. import "babylonjs/Animations/animatable";
  40709. /**
  40710. * Options to modify the vr teleportation behavior.
  40711. */
  40712. export interface VRTeleportationOptions {
  40713. /**
  40714. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40715. */
  40716. floorMeshName?: string;
  40717. /**
  40718. * A list of meshes to be used as the teleportation floor. (default: empty)
  40719. */
  40720. floorMeshes?: Mesh[];
  40721. }
  40722. /**
  40723. * Options to modify the vr experience helper's behavior.
  40724. */
  40725. export interface VRExperienceHelperOptions extends WebVROptions {
  40726. /**
  40727. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40728. */
  40729. createDeviceOrientationCamera?: boolean;
  40730. /**
  40731. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40732. */
  40733. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40734. /**
  40735. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40736. */
  40737. laserToggle?: boolean;
  40738. /**
  40739. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40740. */
  40741. floorMeshes?: Mesh[];
  40742. /**
  40743. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40744. */
  40745. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40746. }
  40747. /**
  40748. * Event containing information after VR has been entered
  40749. */
  40750. export class OnAfterEnteringVRObservableEvent {
  40751. /**
  40752. * If entering vr was successful
  40753. */
  40754. success: boolean;
  40755. }
  40756. /**
  40757. * Helps to quickly add VR support to an existing scene.
  40758. * See http://doc.babylonjs.com/how_to/webvr_helper
  40759. */
  40760. export class VRExperienceHelper {
  40761. /** Options to modify the vr experience helper's behavior. */
  40762. webVROptions: VRExperienceHelperOptions;
  40763. private _scene;
  40764. private _position;
  40765. private _btnVR;
  40766. private _btnVRDisplayed;
  40767. private _webVRsupported;
  40768. private _webVRready;
  40769. private _webVRrequesting;
  40770. private _webVRpresenting;
  40771. private _hasEnteredVR;
  40772. private _fullscreenVRpresenting;
  40773. private _canvas;
  40774. private _webVRCamera;
  40775. private _vrDeviceOrientationCamera;
  40776. private _deviceOrientationCamera;
  40777. private _existingCamera;
  40778. private _onKeyDown;
  40779. private _onVrDisplayPresentChange;
  40780. private _onVRDisplayChanged;
  40781. private _onVRRequestPresentStart;
  40782. private _onVRRequestPresentComplete;
  40783. /**
  40784. * Observable raised right before entering VR.
  40785. */
  40786. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40787. /**
  40788. * Observable raised when entering VR has completed.
  40789. */
  40790. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40791. /**
  40792. * Observable raised when exiting VR.
  40793. */
  40794. onExitingVRObservable: Observable<VRExperienceHelper>;
  40795. /**
  40796. * Observable raised when controller mesh is loaded.
  40797. */
  40798. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40799. /** Return this.onEnteringVRObservable
  40800. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40801. */
  40802. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40803. /** Return this.onExitingVRObservable
  40804. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40805. */
  40806. readonly onExitingVR: Observable<VRExperienceHelper>;
  40807. /** Return this.onControllerMeshLoadedObservable
  40808. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40809. */
  40810. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40811. private _rayLength;
  40812. private _useCustomVRButton;
  40813. private _teleportationRequested;
  40814. private _teleportActive;
  40815. private _floorMeshName;
  40816. private _floorMeshesCollection;
  40817. private _rotationAllowed;
  40818. private _teleportBackwardsVector;
  40819. private _teleportationTarget;
  40820. private _isDefaultTeleportationTarget;
  40821. private _postProcessMove;
  40822. private _teleportationFillColor;
  40823. private _teleportationBorderColor;
  40824. private _rotationAngle;
  40825. private _haloCenter;
  40826. private _cameraGazer;
  40827. private _padSensibilityUp;
  40828. private _padSensibilityDown;
  40829. private _leftController;
  40830. private _rightController;
  40831. /**
  40832. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40833. */
  40834. onNewMeshSelected: Observable<AbstractMesh>;
  40835. /**
  40836. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40837. */
  40838. onNewMeshPicked: Observable<PickingInfo>;
  40839. private _circleEase;
  40840. /**
  40841. * Observable raised before camera teleportation
  40842. */
  40843. onBeforeCameraTeleport: Observable<Vector3>;
  40844. /**
  40845. * Observable raised after camera teleportation
  40846. */
  40847. onAfterCameraTeleport: Observable<Vector3>;
  40848. /**
  40849. * Observable raised when current selected mesh gets unselected
  40850. */
  40851. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40852. private _raySelectionPredicate;
  40853. /**
  40854. * To be optionaly changed by user to define custom ray selection
  40855. */
  40856. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40857. /**
  40858. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40859. */
  40860. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40861. /**
  40862. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40863. */
  40864. teleportationEnabled: boolean;
  40865. private _defaultHeight;
  40866. private _teleportationInitialized;
  40867. private _interactionsEnabled;
  40868. private _interactionsRequested;
  40869. private _displayGaze;
  40870. private _displayLaserPointer;
  40871. /**
  40872. * The mesh used to display where the user is going to teleport.
  40873. */
  40874. /**
  40875. * Sets the mesh to be used to display where the user is going to teleport.
  40876. */
  40877. teleportationTarget: Mesh;
  40878. /**
  40879. * 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
  40880. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40881. * See http://doc.babylonjs.com/resources/baking_transformations
  40882. */
  40883. gazeTrackerMesh: Mesh;
  40884. /**
  40885. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40886. */
  40887. updateGazeTrackerScale: boolean;
  40888. /**
  40889. * If the gaze trackers color should be updated when selecting meshes
  40890. */
  40891. updateGazeTrackerColor: boolean;
  40892. /**
  40893. * The gaze tracking mesh corresponding to the left controller
  40894. */
  40895. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40896. /**
  40897. * The gaze tracking mesh corresponding to the right controller
  40898. */
  40899. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40900. /**
  40901. * If the ray of the gaze should be displayed.
  40902. */
  40903. /**
  40904. * Sets if the ray of the gaze should be displayed.
  40905. */
  40906. displayGaze: boolean;
  40907. /**
  40908. * If the ray of the LaserPointer should be displayed.
  40909. */
  40910. /**
  40911. * Sets if the ray of the LaserPointer should be displayed.
  40912. */
  40913. displayLaserPointer: boolean;
  40914. /**
  40915. * The deviceOrientationCamera used as the camera when not in VR.
  40916. */
  40917. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40918. /**
  40919. * Based on the current WebVR support, returns the current VR camera used.
  40920. */
  40921. readonly currentVRCamera: Nullable<Camera>;
  40922. /**
  40923. * The webVRCamera which is used when in VR.
  40924. */
  40925. readonly webVRCamera: WebVRFreeCamera;
  40926. /**
  40927. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40928. */
  40929. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40930. private readonly _teleportationRequestInitiated;
  40931. /**
  40932. * Defines wether or not Pointer lock should be requested when switching to
  40933. * full screen.
  40934. */
  40935. requestPointerLockOnFullScreen: boolean;
  40936. /**
  40937. * Instantiates a VRExperienceHelper.
  40938. * Helps to quickly add VR support to an existing scene.
  40939. * @param scene The scene the VRExperienceHelper belongs to.
  40940. * @param webVROptions Options to modify the vr experience helper's behavior.
  40941. */
  40942. constructor(scene: Scene,
  40943. /** Options to modify the vr experience helper's behavior. */
  40944. webVROptions?: VRExperienceHelperOptions);
  40945. private _onDefaultMeshLoaded;
  40946. private _onResize;
  40947. private _onFullscreenChange;
  40948. /**
  40949. * Gets a value indicating if we are currently in VR mode.
  40950. */
  40951. readonly isInVRMode: boolean;
  40952. private onVrDisplayPresentChange;
  40953. private onVRDisplayChanged;
  40954. private moveButtonToBottomRight;
  40955. private displayVRButton;
  40956. private updateButtonVisibility;
  40957. private _cachedAngularSensibility;
  40958. /**
  40959. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40960. * Otherwise, will use the fullscreen API.
  40961. */
  40962. enterVR(): void;
  40963. /**
  40964. * Attempt to exit VR, or fullscreen.
  40965. */
  40966. exitVR(): void;
  40967. /**
  40968. * The position of the vr experience helper.
  40969. */
  40970. /**
  40971. * Sets the position of the vr experience helper.
  40972. */
  40973. position: Vector3;
  40974. /**
  40975. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40976. */
  40977. enableInteractions(): void;
  40978. private readonly _noControllerIsActive;
  40979. private beforeRender;
  40980. private _isTeleportationFloor;
  40981. /**
  40982. * Adds a floor mesh to be used for teleportation.
  40983. * @param floorMesh the mesh to be used for teleportation.
  40984. */
  40985. addFloorMesh(floorMesh: Mesh): void;
  40986. /**
  40987. * Removes a floor mesh from being used for teleportation.
  40988. * @param floorMesh the mesh to be removed.
  40989. */
  40990. removeFloorMesh(floorMesh: Mesh): void;
  40991. /**
  40992. * Enables interactions and teleportation using the VR controllers and gaze.
  40993. * @param vrTeleportationOptions options to modify teleportation behavior.
  40994. */
  40995. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40996. private _onNewGamepadConnected;
  40997. private _tryEnableInteractionOnController;
  40998. private _onNewGamepadDisconnected;
  40999. private _enableInteractionOnController;
  41000. private _checkTeleportWithRay;
  41001. private _checkRotate;
  41002. private _checkTeleportBackwards;
  41003. private _enableTeleportationOnController;
  41004. private _createTeleportationCircles;
  41005. private _displayTeleportationTarget;
  41006. private _hideTeleportationTarget;
  41007. private _rotateCamera;
  41008. private _moveTeleportationSelectorTo;
  41009. private _workingVector;
  41010. private _workingQuaternion;
  41011. private _workingMatrix;
  41012. /**
  41013. * Teleports the users feet to the desired location
  41014. * @param location The location where the user's feet should be placed
  41015. */
  41016. teleportCamera(location: Vector3): void;
  41017. private _convertNormalToDirectionOfRay;
  41018. private _castRayAndSelectObject;
  41019. private _notifySelectedMeshUnselected;
  41020. /**
  41021. * Sets the color of the laser ray from the vr controllers.
  41022. * @param color new color for the ray.
  41023. */
  41024. changeLaserColor(color: Color3): void;
  41025. /**
  41026. * Sets the color of the ray from the vr headsets gaze.
  41027. * @param color new color for the ray.
  41028. */
  41029. changeGazeColor(color: Color3): void;
  41030. /**
  41031. * Exits VR and disposes of the vr experience helper
  41032. */
  41033. dispose(): void;
  41034. /**
  41035. * Gets the name of the VRExperienceHelper class
  41036. * @returns "VRExperienceHelper"
  41037. */
  41038. getClassName(): string;
  41039. }
  41040. }
  41041. declare module "babylonjs/Cameras/VR/index" {
  41042. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41043. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41044. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41045. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41046. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41047. export * from "babylonjs/Cameras/VR/webVRCamera";
  41048. }
  41049. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41050. import { Observable } from "babylonjs/Misc/observable";
  41051. import { Nullable } from "babylonjs/types";
  41052. import { IDisposable, Scene } from "babylonjs/scene";
  41053. import { Vector3 } from "babylonjs/Maths/math";
  41054. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41055. import { Ray } from "babylonjs/Culling/ray";
  41056. /**
  41057. * Manages an XRSession
  41058. * @see https://doc.babylonjs.com/how_to/webxr
  41059. */
  41060. export class WebXRSessionManager implements IDisposable {
  41061. private scene;
  41062. /**
  41063. * Fires every time a new xrFrame arrives which can be used to update the camera
  41064. */
  41065. onXRFrameObservable: Observable<any>;
  41066. /**
  41067. * Fires when the xr session is ended either by the device or manually done
  41068. */
  41069. onXRSessionEnded: Observable<any>;
  41070. /** @hidden */
  41071. _xrSession: XRSession;
  41072. /** @hidden */
  41073. _frameOfReference: XRFrameOfReference;
  41074. /** @hidden */
  41075. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41076. /** @hidden */
  41077. _currentXRFrame: Nullable<XRFrame>;
  41078. private _xrNavigator;
  41079. private _xrDevice;
  41080. private _tmpMatrix;
  41081. /**
  41082. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41083. * @param scene The scene which the session should be created for
  41084. */
  41085. constructor(scene: Scene);
  41086. /**
  41087. * Initializes the manager
  41088. * After initialization enterXR can be called to start an XR session
  41089. * @returns Promise which resolves after it is initialized
  41090. */
  41091. initializeAsync(): Promise<void>;
  41092. /**
  41093. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41094. * @param sessionCreationOptions xr options to create the session with
  41095. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41096. * @returns Promise which resolves after it enters XR
  41097. */
  41098. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41099. /**
  41100. * Stops the xrSession and restores the renderloop
  41101. * @returns Promise which resolves after it exits XR
  41102. */
  41103. exitXRAsync(): Promise<void>;
  41104. /**
  41105. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41106. * @param ray ray to cast into the environment
  41107. * @returns Promise which resolves with a collision point in the environment if it exists
  41108. */
  41109. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41110. /**
  41111. * Checks if a session would be supported for the creation options specified
  41112. * @param options creation options to check if they are supported
  41113. * @returns true if supported
  41114. */
  41115. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41116. /**
  41117. * @hidden
  41118. * Converts the render layer of xrSession to a render target
  41119. * @param session session to create render target for
  41120. * @param scene scene the new render target should be created for
  41121. */
  41122. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41123. /**
  41124. * Disposes of the session manager
  41125. */
  41126. dispose(): void;
  41127. }
  41128. }
  41129. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41130. import { Scene } from "babylonjs/scene";
  41131. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41132. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41133. /**
  41134. * WebXR Camera which holds the views for the xrSession
  41135. * @see https://doc.babylonjs.com/how_to/webxr
  41136. */
  41137. export class WebXRCamera extends FreeCamera {
  41138. private static _TmpMatrix;
  41139. /**
  41140. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41141. * @param name the name of the camera
  41142. * @param scene the scene to add the camera to
  41143. */
  41144. constructor(name: string, scene: Scene);
  41145. private _updateNumberOfRigCameras;
  41146. /** @hidden */
  41147. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41148. /**
  41149. * Updates the cameras position from the current pose information of the XR session
  41150. * @param xrSessionManager the session containing pose information
  41151. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41152. */
  41153. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41154. }
  41155. }
  41156. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41157. import { Nullable } from "babylonjs/types";
  41158. import { Observable } from "babylonjs/Misc/observable";
  41159. import { IDisposable, Scene } from "babylonjs/scene";
  41160. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41162. import { Ray } from "babylonjs/Culling/ray";
  41163. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41164. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41165. /**
  41166. * States of the webXR experience
  41167. */
  41168. export enum WebXRState {
  41169. /**
  41170. * Transitioning to being in XR mode
  41171. */
  41172. ENTERING_XR = 0,
  41173. /**
  41174. * Transitioning to non XR mode
  41175. */
  41176. EXITING_XR = 1,
  41177. /**
  41178. * In XR mode and presenting
  41179. */
  41180. IN_XR = 2,
  41181. /**
  41182. * Not entered XR mode
  41183. */
  41184. NOT_IN_XR = 3
  41185. }
  41186. /**
  41187. * Helper class used to enable XR
  41188. * @see https://doc.babylonjs.com/how_to/webxr
  41189. */
  41190. export class WebXRExperienceHelper implements IDisposable {
  41191. private scene;
  41192. /**
  41193. * 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
  41194. */
  41195. container: AbstractMesh;
  41196. /**
  41197. * Camera used to render xr content
  41198. */
  41199. camera: WebXRCamera;
  41200. /**
  41201. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41202. */
  41203. state: WebXRState;
  41204. private _setState;
  41205. private static _TmpVector;
  41206. /**
  41207. * Fires when the state of the experience helper has changed
  41208. */
  41209. onStateChangedObservable: Observable<WebXRState>;
  41210. /** @hidden */
  41211. _sessionManager: WebXRSessionManager;
  41212. private _nonVRCamera;
  41213. private _originalSceneAutoClear;
  41214. private _supported;
  41215. /**
  41216. * Creates the experience helper
  41217. * @param scene the scene to attach the experience helper to
  41218. * @returns a promise for the experience helper
  41219. */
  41220. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41221. /**
  41222. * Creates a WebXRExperienceHelper
  41223. * @param scene The scene the helper should be created in
  41224. */
  41225. private constructor();
  41226. /**
  41227. * Exits XR mode and returns the scene to its original state
  41228. * @returns promise that resolves after xr mode has exited
  41229. */
  41230. exitXRAsync(): Promise<void>;
  41231. /**
  41232. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41233. * @param sessionCreationOptions options for the XR session
  41234. * @param frameOfReference frame of reference of the XR session
  41235. * @returns promise that resolves after xr mode has entered
  41236. */
  41237. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41238. /**
  41239. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41240. * @param ray ray to cast into the environment
  41241. * @returns Promise which resolves with a collision point in the environment if it exists
  41242. */
  41243. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41244. /**
  41245. * Updates the global position of the camera by moving the camera's container
  41246. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41247. * @param position The desired global position of the camera
  41248. */
  41249. setPositionOfCameraUsingContainer(position: Vector3): void;
  41250. /**
  41251. * Rotates the xr camera by rotating the camera's container around the camera's position
  41252. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41253. * @param rotation the desired quaternion rotation to apply to the camera
  41254. */
  41255. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41256. /**
  41257. * Checks if the creation options are supported by the xr session
  41258. * @param options creation options
  41259. * @returns true if supported
  41260. */
  41261. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41262. /**
  41263. * Disposes of the experience helper
  41264. */
  41265. dispose(): void;
  41266. }
  41267. }
  41268. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41269. import { Nullable } from "babylonjs/types";
  41270. import { Observable } from "babylonjs/Misc/observable";
  41271. import { IDisposable, Scene } from "babylonjs/scene";
  41272. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41273. /**
  41274. * Button which can be used to enter a different mode of XR
  41275. */
  41276. export class WebXREnterExitUIButton {
  41277. /** button element */
  41278. element: HTMLElement;
  41279. /** XR initialization options for the button */
  41280. initializationOptions: XRSessionCreationOptions;
  41281. /**
  41282. * Creates a WebXREnterExitUIButton
  41283. * @param element button element
  41284. * @param initializationOptions XR initialization options for the button
  41285. */
  41286. constructor(
  41287. /** button element */
  41288. element: HTMLElement,
  41289. /** XR initialization options for the button */
  41290. initializationOptions: XRSessionCreationOptions);
  41291. /**
  41292. * Overwritable function which can be used to update the button's visuals when the state changes
  41293. * @param activeButton the current active button in the UI
  41294. */
  41295. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41296. }
  41297. /**
  41298. * Options to create the webXR UI
  41299. */
  41300. export class WebXREnterExitUIOptions {
  41301. /**
  41302. * Context to enter xr with
  41303. */
  41304. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41305. /**
  41306. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41307. */
  41308. customButtons?: Array<WebXREnterExitUIButton>;
  41309. }
  41310. /**
  41311. * UI to allow the user to enter/exit XR mode
  41312. */
  41313. export class WebXREnterExitUI implements IDisposable {
  41314. private scene;
  41315. private _overlay;
  41316. private _buttons;
  41317. private _activeButton;
  41318. /**
  41319. * Fired every time the active button is changed.
  41320. *
  41321. * When xr is entered via a button that launches xr that button will be the callback parameter
  41322. *
  41323. * When exiting xr the callback parameter will be null)
  41324. */
  41325. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41326. /**
  41327. * Creates UI to allow the user to enter/exit XR mode
  41328. * @param scene the scene to add the ui to
  41329. * @param helper the xr experience helper to enter/exit xr with
  41330. * @param options options to configure the UI
  41331. * @returns the created ui
  41332. */
  41333. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41334. private constructor();
  41335. private _updateButtons;
  41336. /**
  41337. * Disposes of the object
  41338. */
  41339. dispose(): void;
  41340. }
  41341. }
  41342. declare module "babylonjs/Cameras/XR/webXRInput" {
  41343. import { IDisposable, Scene } from "babylonjs/scene";
  41344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41345. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41346. /**
  41347. * Represents an XR input
  41348. */
  41349. export class WebXRController {
  41350. /**
  41351. * 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
  41352. */
  41353. grip?: AbstractMesh;
  41354. /**
  41355. * Pointer which can be used to select objects or attach a visible laser to
  41356. */
  41357. pointer: AbstractMesh;
  41358. /**
  41359. * Creates the controller
  41360. * @see https://doc.babylonjs.com/how_to/webxr
  41361. * @param scene the scene which the controller should be associated to
  41362. */
  41363. constructor(scene: Scene);
  41364. /**
  41365. * Disposes of the object
  41366. */
  41367. dispose(): void;
  41368. }
  41369. /**
  41370. * XR input used to track XR inputs such as controllers/rays
  41371. */
  41372. export class WebXRInput implements IDisposable {
  41373. private helper;
  41374. /**
  41375. * XR controllers being tracked
  41376. */
  41377. controllers: Array<WebXRController>;
  41378. private _tmpMatrix;
  41379. private _frameObserver;
  41380. /**
  41381. * Initializes the WebXRInput
  41382. * @param helper experience helper which the input should be created for
  41383. */
  41384. constructor(helper: WebXRExperienceHelper);
  41385. /**
  41386. * Disposes of the object
  41387. */
  41388. dispose(): void;
  41389. }
  41390. }
  41391. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41392. import { Nullable } from "babylonjs/types";
  41393. import { IDisposable } from "babylonjs/scene";
  41394. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41395. /**
  41396. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41397. */
  41398. export class WebXRManagedOutputCanvas implements IDisposable {
  41399. private _canvas;
  41400. /**
  41401. * xrpresent context of the canvas which can be used to display/mirror xr content
  41402. */
  41403. canvasContext: Nullable<WebGLRenderingContext>;
  41404. /**
  41405. * Initializes the canvas to be added/removed upon entering/exiting xr
  41406. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41407. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41408. */
  41409. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41410. /**
  41411. * Disposes of the object
  41412. */
  41413. dispose(): void;
  41414. private _setManagedOutputCanvas;
  41415. private _addCanvas;
  41416. private _removeCanvas;
  41417. }
  41418. }
  41419. declare module "babylonjs/Cameras/XR/index" {
  41420. export * from "babylonjs/Cameras/XR/webXRCamera";
  41421. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41422. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41423. export * from "babylonjs/Cameras/XR/webXRInput";
  41424. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41425. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41426. }
  41427. declare module "babylonjs/Cameras/RigModes/index" {
  41428. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41429. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41430. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41431. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41432. }
  41433. declare module "babylonjs/Cameras/index" {
  41434. export * from "babylonjs/Cameras/Inputs/index";
  41435. export * from "babylonjs/Cameras/cameraInputsManager";
  41436. export * from "babylonjs/Cameras/camera";
  41437. export * from "babylonjs/Cameras/targetCamera";
  41438. export * from "babylonjs/Cameras/freeCamera";
  41439. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41440. export * from "babylonjs/Cameras/touchCamera";
  41441. export * from "babylonjs/Cameras/arcRotateCamera";
  41442. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41443. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41444. export * from "babylonjs/Cameras/flyCamera";
  41445. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41446. export * from "babylonjs/Cameras/followCamera";
  41447. export * from "babylonjs/Cameras/gamepadCamera";
  41448. export * from "babylonjs/Cameras/Stereoscopic/index";
  41449. export * from "babylonjs/Cameras/universalCamera";
  41450. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41451. export * from "babylonjs/Cameras/VR/index";
  41452. export * from "babylonjs/Cameras/XR/index";
  41453. export * from "babylonjs/Cameras/RigModes/index";
  41454. }
  41455. declare module "babylonjs/Collisions/index" {
  41456. export * from "babylonjs/Collisions/collider";
  41457. export * from "babylonjs/Collisions/collisionCoordinator";
  41458. export * from "babylonjs/Collisions/pickingInfo";
  41459. export * from "babylonjs/Collisions/intersectionInfo";
  41460. }
  41461. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41462. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41463. import { Vector3, Plane } from "babylonjs/Maths/math";
  41464. import { Ray } from "babylonjs/Culling/ray";
  41465. /**
  41466. * Contains an array of blocks representing the octree
  41467. */
  41468. export interface IOctreeContainer<T> {
  41469. /**
  41470. * Blocks within the octree
  41471. */
  41472. blocks: Array<OctreeBlock<T>>;
  41473. }
  41474. /**
  41475. * Class used to store a cell in an octree
  41476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41477. */
  41478. export class OctreeBlock<T> {
  41479. /**
  41480. * Gets the content of the current block
  41481. */
  41482. entries: T[];
  41483. /**
  41484. * Gets the list of block children
  41485. */
  41486. blocks: Array<OctreeBlock<T>>;
  41487. private _depth;
  41488. private _maxDepth;
  41489. private _capacity;
  41490. private _minPoint;
  41491. private _maxPoint;
  41492. private _boundingVectors;
  41493. private _creationFunc;
  41494. /**
  41495. * Creates a new block
  41496. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41497. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41498. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41499. * @param depth defines the current depth of this block in the octree
  41500. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41501. * @param creationFunc defines a callback to call when an element is added to the block
  41502. */
  41503. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41504. /**
  41505. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41506. */
  41507. readonly capacity: number;
  41508. /**
  41509. * Gets the minimum vector (in world space) of the block's bounding box
  41510. */
  41511. readonly minPoint: Vector3;
  41512. /**
  41513. * Gets the maximum vector (in world space) of the block's bounding box
  41514. */
  41515. readonly maxPoint: Vector3;
  41516. /**
  41517. * Add a new element to this block
  41518. * @param entry defines the element to add
  41519. */
  41520. addEntry(entry: T): void;
  41521. /**
  41522. * Remove an element from this block
  41523. * @param entry defines the element to remove
  41524. */
  41525. removeEntry(entry: T): void;
  41526. /**
  41527. * Add an array of elements to this block
  41528. * @param entries defines the array of elements to add
  41529. */
  41530. addEntries(entries: T[]): void;
  41531. /**
  41532. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41533. * @param frustumPlanes defines the frustum planes to test
  41534. * @param selection defines the array to store current content if selection is positive
  41535. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41536. */
  41537. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41538. /**
  41539. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41540. * @param sphereCenter defines the bounding sphere center
  41541. * @param sphereRadius defines the bounding sphere radius
  41542. * @param selection defines the array to store current content if selection is positive
  41543. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41544. */
  41545. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41546. /**
  41547. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41548. * @param ray defines the ray to test with
  41549. * @param selection defines the array to store current content if selection is positive
  41550. */
  41551. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41552. /**
  41553. * Subdivide the content into child blocks (this block will then be empty)
  41554. */
  41555. createInnerBlocks(): void;
  41556. /**
  41557. * @hidden
  41558. */
  41559. 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;
  41560. }
  41561. }
  41562. declare module "babylonjs/Culling/Octrees/octree" {
  41563. import { SmartArray } from "babylonjs/Misc/smartArray";
  41564. import { Vector3, Plane } from "babylonjs/Maths/math";
  41565. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41567. import { Ray } from "babylonjs/Culling/ray";
  41568. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41569. /**
  41570. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41571. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41572. */
  41573. export class Octree<T> {
  41574. /** 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.) */
  41575. maxDepth: number;
  41576. /**
  41577. * Blocks within the octree containing objects
  41578. */
  41579. blocks: Array<OctreeBlock<T>>;
  41580. /**
  41581. * Content stored in the octree
  41582. */
  41583. dynamicContent: T[];
  41584. private _maxBlockCapacity;
  41585. private _selectionContent;
  41586. private _creationFunc;
  41587. /**
  41588. * Creates a octree
  41589. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41590. * @param creationFunc function to be used to instatiate the octree
  41591. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41592. * @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.)
  41593. */
  41594. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41595. /** 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.) */
  41596. maxDepth?: number);
  41597. /**
  41598. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41599. * @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);
  41600. * @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);
  41601. * @param entries meshes to be added to the octree blocks
  41602. */
  41603. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41604. /**
  41605. * Adds a mesh to the octree
  41606. * @param entry Mesh to add to the octree
  41607. */
  41608. addMesh(entry: T): void;
  41609. /**
  41610. * Remove an element from the octree
  41611. * @param entry defines the element to remove
  41612. */
  41613. removeMesh(entry: T): void;
  41614. /**
  41615. * Selects an array of meshes within the frustum
  41616. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41617. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41618. * @returns array of meshes within the frustum
  41619. */
  41620. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41621. /**
  41622. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41623. * @param sphereCenter defines the bounding sphere center
  41624. * @param sphereRadius defines the bounding sphere radius
  41625. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41626. * @returns an array of objects that intersect the sphere
  41627. */
  41628. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41629. /**
  41630. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41631. * @param ray defines the ray to test with
  41632. * @returns array of intersected objects
  41633. */
  41634. intersectsRay(ray: Ray): SmartArray<T>;
  41635. /**
  41636. * Adds a mesh into the octree block if it intersects the block
  41637. */
  41638. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41639. /**
  41640. * Adds a submesh into the octree block if it intersects the block
  41641. */
  41642. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41643. }
  41644. }
  41645. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41646. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41647. import { Scene } from "babylonjs/scene";
  41648. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41650. import { Ray } from "babylonjs/Culling/ray";
  41651. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41652. import { Collider } from "babylonjs/Collisions/collider";
  41653. module "babylonjs/scene" {
  41654. interface Scene {
  41655. /**
  41656. * @hidden
  41657. * Backing Filed
  41658. */
  41659. _selectionOctree: Octree<AbstractMesh>;
  41660. /**
  41661. * Gets the octree used to boost mesh selection (picking)
  41662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41663. */
  41664. selectionOctree: Octree<AbstractMesh>;
  41665. /**
  41666. * Creates or updates the octree used to boost selection (picking)
  41667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41668. * @param maxCapacity defines the maximum capacity per leaf
  41669. * @param maxDepth defines the maximum depth of the octree
  41670. * @returns an octree of AbstractMesh
  41671. */
  41672. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41673. }
  41674. }
  41675. module "babylonjs/Meshes/abstractMesh" {
  41676. interface AbstractMesh {
  41677. /**
  41678. * @hidden
  41679. * Backing Field
  41680. */
  41681. _submeshesOctree: Octree<SubMesh>;
  41682. /**
  41683. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41684. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41685. * @param maxCapacity defines the maximum size of each block (64 by default)
  41686. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41687. * @returns the new octree
  41688. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41689. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41690. */
  41691. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41692. }
  41693. }
  41694. /**
  41695. * Defines the octree scene component responsible to manage any octrees
  41696. * in a given scene.
  41697. */
  41698. export class OctreeSceneComponent {
  41699. /**
  41700. * The component name helpfull to identify the component in the list of scene components.
  41701. */
  41702. readonly name: string;
  41703. /**
  41704. * The scene the component belongs to.
  41705. */
  41706. scene: Scene;
  41707. /**
  41708. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41709. */
  41710. readonly checksIsEnabled: boolean;
  41711. /**
  41712. * Creates a new instance of the component for the given scene
  41713. * @param scene Defines the scene to register the component in
  41714. */
  41715. constructor(scene: Scene);
  41716. /**
  41717. * Registers the component in a given scene
  41718. */
  41719. register(): void;
  41720. /**
  41721. * Return the list of active meshes
  41722. * @returns the list of active meshes
  41723. */
  41724. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41725. /**
  41726. * Return the list of active sub meshes
  41727. * @param mesh The mesh to get the candidates sub meshes from
  41728. * @returns the list of active sub meshes
  41729. */
  41730. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41731. private _tempRay;
  41732. /**
  41733. * Return the list of sub meshes intersecting with a given local ray
  41734. * @param mesh defines the mesh to find the submesh for
  41735. * @param localRay defines the ray in local space
  41736. * @returns the list of intersecting sub meshes
  41737. */
  41738. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41739. /**
  41740. * Return the list of sub meshes colliding with a collider
  41741. * @param mesh defines the mesh to find the submesh for
  41742. * @param collider defines the collider to evaluate the collision against
  41743. * @returns the list of colliding sub meshes
  41744. */
  41745. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41746. /**
  41747. * Rebuilds the elements related to this component in case of
  41748. * context lost for instance.
  41749. */
  41750. rebuild(): void;
  41751. /**
  41752. * Disposes the component and the associated ressources.
  41753. */
  41754. dispose(): void;
  41755. }
  41756. }
  41757. declare module "babylonjs/Culling/Octrees/index" {
  41758. export * from "babylonjs/Culling/Octrees/octree";
  41759. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41760. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41761. }
  41762. declare module "babylonjs/Culling/index" {
  41763. export * from "babylonjs/Culling/boundingBox";
  41764. export * from "babylonjs/Culling/boundingInfo";
  41765. export * from "babylonjs/Culling/boundingSphere";
  41766. export * from "babylonjs/Culling/Octrees/index";
  41767. export * from "babylonjs/Culling/ray";
  41768. }
  41769. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41770. import { IDisposable, Scene } from "babylonjs/scene";
  41771. import { Nullable } from "babylonjs/types";
  41772. import { Observable } from "babylonjs/Misc/observable";
  41773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41774. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  41775. /**
  41776. * Renders a layer on top of an existing scene
  41777. */
  41778. export class UtilityLayerRenderer implements IDisposable {
  41779. /** the original scene that will be rendered on top of */
  41780. originalScene: Scene;
  41781. private _pointerCaptures;
  41782. private _lastPointerEvents;
  41783. private static _DefaultUtilityLayer;
  41784. private static _DefaultKeepDepthUtilityLayer;
  41785. private _sharedGizmoLight;
  41786. /**
  41787. * @hidden
  41788. * Light which used by gizmos to get light shading
  41789. */
  41790. _getSharedGizmoLight(): HemisphericLight;
  41791. /**
  41792. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41793. */
  41794. pickUtilitySceneFirst: boolean;
  41795. /**
  41796. * 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)
  41797. */
  41798. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41799. /**
  41800. * 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)
  41801. */
  41802. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41803. /**
  41804. * The scene that is rendered on top of the original scene
  41805. */
  41806. utilityLayerScene: Scene;
  41807. /**
  41808. * If the utility layer should automatically be rendered on top of existing scene
  41809. */
  41810. shouldRender: boolean;
  41811. /**
  41812. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41813. */
  41814. onlyCheckPointerDownEvents: boolean;
  41815. /**
  41816. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41817. */
  41818. processAllEvents: boolean;
  41819. /**
  41820. * Observable raised when the pointer move from the utility layer scene to the main scene
  41821. */
  41822. onPointerOutObservable: Observable<number>;
  41823. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41824. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41825. private _afterRenderObserver;
  41826. private _sceneDisposeObserver;
  41827. private _originalPointerObserver;
  41828. /**
  41829. * Instantiates a UtilityLayerRenderer
  41830. * @param originalScene the original scene that will be rendered on top of
  41831. * @param handleEvents boolean indicating if the utility layer should handle events
  41832. */
  41833. constructor(
  41834. /** the original scene that will be rendered on top of */
  41835. originalScene: Scene, handleEvents?: boolean);
  41836. private _notifyObservers;
  41837. /**
  41838. * Renders the utility layers scene on top of the original scene
  41839. */
  41840. render(): void;
  41841. /**
  41842. * Disposes of the renderer
  41843. */
  41844. dispose(): void;
  41845. private _updateCamera;
  41846. }
  41847. }
  41848. declare module "babylonjs/Gizmos/gizmo" {
  41849. import { Nullable } from "babylonjs/types";
  41850. import { IDisposable } from "babylonjs/scene";
  41851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41852. import { Mesh } from "babylonjs/Meshes/mesh";
  41853. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41854. /**
  41855. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41856. */
  41857. export class Gizmo implements IDisposable {
  41858. /** The utility layer the gizmo will be added to */
  41859. gizmoLayer: UtilityLayerRenderer;
  41860. /**
  41861. * The root mesh of the gizmo
  41862. */
  41863. _rootMesh: Mesh;
  41864. private _attachedMesh;
  41865. /**
  41866. * Ratio for the scale of the gizmo (Default: 1)
  41867. */
  41868. scaleRatio: number;
  41869. /**
  41870. * If a custom mesh has been set (Default: false)
  41871. */
  41872. protected _customMeshSet: boolean;
  41873. /**
  41874. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41875. * * When set, interactions will be enabled
  41876. */
  41877. attachedMesh: Nullable<AbstractMesh>;
  41878. /**
  41879. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41880. * @param mesh The mesh to replace the default mesh of the gizmo
  41881. */
  41882. setCustomMesh(mesh: Mesh): void;
  41883. /**
  41884. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41885. */
  41886. updateGizmoRotationToMatchAttachedMesh: boolean;
  41887. /**
  41888. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41889. */
  41890. updateGizmoPositionToMatchAttachedMesh: boolean;
  41891. /**
  41892. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41893. */
  41894. protected _updateScale: boolean;
  41895. protected _interactionsEnabled: boolean;
  41896. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41897. private _beforeRenderObserver;
  41898. private _tempVector;
  41899. /**
  41900. * Creates a gizmo
  41901. * @param gizmoLayer The utility layer the gizmo will be added to
  41902. */
  41903. constructor(
  41904. /** The utility layer the gizmo will be added to */
  41905. gizmoLayer?: UtilityLayerRenderer);
  41906. /**
  41907. * Updates the gizmo to match the attached mesh's position/rotation
  41908. */
  41909. protected _update(): void;
  41910. /**
  41911. * Disposes of the gizmo
  41912. */
  41913. dispose(): void;
  41914. }
  41915. }
  41916. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41917. import { Observable } from "babylonjs/Misc/observable";
  41918. import { Nullable } from "babylonjs/types";
  41919. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41920. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41922. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41923. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41924. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41925. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41926. import { Scene } from "babylonjs/scene";
  41927. /**
  41928. * Single axis drag gizmo
  41929. */
  41930. export class AxisDragGizmo extends Gizmo {
  41931. /**
  41932. * Drag behavior responsible for the gizmos dragging interactions
  41933. */
  41934. dragBehavior: PointerDragBehavior;
  41935. private _pointerObserver;
  41936. /**
  41937. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41938. */
  41939. snapDistance: number;
  41940. /**
  41941. * Event that fires each time the gizmo snaps to a new location.
  41942. * * snapDistance is the the change in distance
  41943. */
  41944. onSnapObservable: Observable<{
  41945. snapDistance: number;
  41946. }>;
  41947. /** @hidden */
  41948. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41949. /** @hidden */
  41950. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41951. /**
  41952. * Creates an AxisDragGizmo
  41953. * @param gizmoLayer The utility layer the gizmo will be added to
  41954. * @param dragAxis The axis which the gizmo will be able to drag on
  41955. * @param color The color of the gizmo
  41956. */
  41957. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41958. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41959. /**
  41960. * Disposes of the gizmo
  41961. */
  41962. dispose(): void;
  41963. }
  41964. }
  41965. declare module "babylonjs/Debug/axesViewer" {
  41966. import { Vector3 } from "babylonjs/Maths/math";
  41967. import { Nullable } from "babylonjs/types";
  41968. import { Scene } from "babylonjs/scene";
  41969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41970. /**
  41971. * The Axes viewer will show 3 axes in a specific point in space
  41972. */
  41973. export class AxesViewer {
  41974. private _xAxis;
  41975. private _yAxis;
  41976. private _zAxis;
  41977. private _scaleLinesFactor;
  41978. private _instanced;
  41979. /**
  41980. * Gets the hosting scene
  41981. */
  41982. scene: Scene;
  41983. /**
  41984. * Gets or sets a number used to scale line length
  41985. */
  41986. scaleLines: number;
  41987. /** Gets the node hierarchy used to render x-axis */
  41988. readonly xAxis: TransformNode;
  41989. /** Gets the node hierarchy used to render y-axis */
  41990. readonly yAxis: TransformNode;
  41991. /** Gets the node hierarchy used to render z-axis */
  41992. readonly zAxis: TransformNode;
  41993. /**
  41994. * Creates a new AxesViewer
  41995. * @param scene defines the hosting scene
  41996. * @param scaleLines defines a number used to scale line length (1 by default)
  41997. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41998. * @param xAxis defines the node hierarchy used to render the x-axis
  41999. * @param yAxis defines the node hierarchy used to render the y-axis
  42000. * @param zAxis defines the node hierarchy used to render the z-axis
  42001. */
  42002. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42003. /**
  42004. * Force the viewer to update
  42005. * @param position defines the position of the viewer
  42006. * @param xaxis defines the x axis of the viewer
  42007. * @param yaxis defines the y axis of the viewer
  42008. * @param zaxis defines the z axis of the viewer
  42009. */
  42010. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42011. /**
  42012. * Creates an instance of this axes viewer.
  42013. * @returns a new axes viewer with instanced meshes
  42014. */
  42015. createInstance(): AxesViewer;
  42016. /** Releases resources */
  42017. dispose(): void;
  42018. private static _SetRenderingGroupId;
  42019. }
  42020. }
  42021. declare module "babylonjs/Debug/boneAxesViewer" {
  42022. import { Nullable } from "babylonjs/types";
  42023. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42024. import { Vector3 } from "babylonjs/Maths/math";
  42025. import { Mesh } from "babylonjs/Meshes/mesh";
  42026. import { Bone } from "babylonjs/Bones/bone";
  42027. import { Scene } from "babylonjs/scene";
  42028. /**
  42029. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42030. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42031. */
  42032. export class BoneAxesViewer extends AxesViewer {
  42033. /**
  42034. * Gets or sets the target mesh where to display the axes viewer
  42035. */
  42036. mesh: Nullable<Mesh>;
  42037. /**
  42038. * Gets or sets the target bone where to display the axes viewer
  42039. */
  42040. bone: Nullable<Bone>;
  42041. /** Gets current position */
  42042. pos: Vector3;
  42043. /** Gets direction of X axis */
  42044. xaxis: Vector3;
  42045. /** Gets direction of Y axis */
  42046. yaxis: Vector3;
  42047. /** Gets direction of Z axis */
  42048. zaxis: Vector3;
  42049. /**
  42050. * Creates a new BoneAxesViewer
  42051. * @param scene defines the hosting scene
  42052. * @param bone defines the target bone
  42053. * @param mesh defines the target mesh
  42054. * @param scaleLines defines a scaling factor for line length (1 by default)
  42055. */
  42056. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42057. /**
  42058. * Force the viewer to update
  42059. */
  42060. update(): void;
  42061. /** Releases resources */
  42062. dispose(): void;
  42063. }
  42064. }
  42065. declare module "babylonjs/Debug/debugLayer" {
  42066. import { Observable } from "babylonjs/Misc/observable";
  42067. import { Scene } from "babylonjs/scene";
  42068. /**
  42069. * Interface used to define scene explorer extensibility option
  42070. */
  42071. export interface IExplorerExtensibilityOption {
  42072. /**
  42073. * Define the option label
  42074. */
  42075. label: string;
  42076. /**
  42077. * Defines the action to execute on click
  42078. */
  42079. action: (entity: any) => void;
  42080. }
  42081. /**
  42082. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42083. */
  42084. export interface IExplorerExtensibilityGroup {
  42085. /**
  42086. * Defines a predicate to test if a given type mut be extended
  42087. */
  42088. predicate: (entity: any) => boolean;
  42089. /**
  42090. * Gets the list of options added to a type
  42091. */
  42092. entries: IExplorerExtensibilityOption[];
  42093. }
  42094. /**
  42095. * Interface used to define the options to use to create the Inspector
  42096. */
  42097. export interface IInspectorOptions {
  42098. /**
  42099. * Display in overlay mode (default: false)
  42100. */
  42101. overlay?: boolean;
  42102. /**
  42103. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42104. */
  42105. globalRoot?: HTMLElement;
  42106. /**
  42107. * Display the Scene explorer
  42108. */
  42109. showExplorer?: boolean;
  42110. /**
  42111. * Display the property inspector
  42112. */
  42113. showInspector?: boolean;
  42114. /**
  42115. * Display in embed mode (both panes on the right)
  42116. */
  42117. embedMode?: boolean;
  42118. /**
  42119. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42120. */
  42121. handleResize?: boolean;
  42122. /**
  42123. * Allow the panes to popup (default: true)
  42124. */
  42125. enablePopup?: boolean;
  42126. /**
  42127. * Allow the panes to be closed by users (default: true)
  42128. */
  42129. enableClose?: boolean;
  42130. /**
  42131. * Optional list of extensibility entries
  42132. */
  42133. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42134. /**
  42135. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42136. */
  42137. inspectorURL?: string;
  42138. }
  42139. module "babylonjs/scene" {
  42140. interface Scene {
  42141. /**
  42142. * @hidden
  42143. * Backing field
  42144. */
  42145. _debugLayer: DebugLayer;
  42146. /**
  42147. * Gets the debug layer (aka Inspector) associated with the scene
  42148. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42149. */
  42150. debugLayer: DebugLayer;
  42151. }
  42152. }
  42153. /**
  42154. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42155. * what is happening in your scene
  42156. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42157. */
  42158. export class DebugLayer {
  42159. /**
  42160. * Define the url to get the inspector script from.
  42161. * By default it uses the babylonjs CDN.
  42162. * @ignoreNaming
  42163. */
  42164. static InspectorURL: string;
  42165. private _scene;
  42166. private BJSINSPECTOR;
  42167. /**
  42168. * Observable triggered when a property is changed through the inspector.
  42169. */
  42170. onPropertyChangedObservable: Observable<{
  42171. object: any;
  42172. property: string;
  42173. value: any;
  42174. initialValue: any;
  42175. }>;
  42176. /**
  42177. * Instantiates a new debug layer.
  42178. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42179. * what is happening in your scene
  42180. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42181. * @param scene Defines the scene to inspect
  42182. */
  42183. constructor(scene: Scene);
  42184. /** Creates the inspector window. */
  42185. private _createInspector;
  42186. /**
  42187. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42188. * @param entity defines the entity to select
  42189. * @param lineContainerTitle defines the specific block to highlight
  42190. */
  42191. select(entity: any, lineContainerTitle?: string): void;
  42192. /** Get the inspector from bundle or global */
  42193. private _getGlobalInspector;
  42194. /**
  42195. * Get if the inspector is visible or not.
  42196. * @returns true if visible otherwise, false
  42197. */
  42198. isVisible(): boolean;
  42199. /**
  42200. * Hide the inspector and close its window.
  42201. */
  42202. hide(): void;
  42203. /**
  42204. * Launch the debugLayer.
  42205. * @param config Define the configuration of the inspector
  42206. * @return a promise fulfilled when the debug layer is visible
  42207. */
  42208. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42209. }
  42210. }
  42211. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42212. import { Nullable } from "babylonjs/types";
  42213. import { Scene } from "babylonjs/scene";
  42214. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42215. import { Mesh } from "babylonjs/Meshes/mesh";
  42216. /**
  42217. * Class containing static functions to help procedurally build meshes
  42218. */
  42219. export class BoxBuilder {
  42220. /**
  42221. * Creates a box mesh
  42222. * * The parameter `size` sets the size (float) of each box side (default 1)
  42223. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42224. * * 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)
  42225. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42229. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42230. * @param name defines the name of the mesh
  42231. * @param options defines the options used to create the mesh
  42232. * @param scene defines the hosting scene
  42233. * @returns the box mesh
  42234. */
  42235. static CreateBox(name: string, options: {
  42236. size?: number;
  42237. width?: number;
  42238. height?: number;
  42239. depth?: number;
  42240. faceUV?: Vector4[];
  42241. faceColors?: Color4[];
  42242. sideOrientation?: number;
  42243. frontUVs?: Vector4;
  42244. backUVs?: Vector4;
  42245. wrap?: boolean;
  42246. topBaseAt?: number;
  42247. bottomBaseAt?: number;
  42248. updatable?: boolean;
  42249. }, scene?: Nullable<Scene>): Mesh;
  42250. }
  42251. }
  42252. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42253. import { Vector4 } from "babylonjs/Maths/math";
  42254. import { Mesh } from "babylonjs/Meshes/mesh";
  42255. /**
  42256. * Class containing static functions to help procedurally build meshes
  42257. */
  42258. export class SphereBuilder {
  42259. /**
  42260. * Creates a sphere mesh
  42261. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42262. * * 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`)
  42263. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42264. * * 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
  42265. * * 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)
  42266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42269. * @param name defines the name of the mesh
  42270. * @param options defines the options used to create the mesh
  42271. * @param scene defines the hosting scene
  42272. * @returns the sphere mesh
  42273. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42274. */
  42275. static CreateSphere(name: string, options: {
  42276. segments?: number;
  42277. diameter?: number;
  42278. diameterX?: number;
  42279. diameterY?: number;
  42280. diameterZ?: number;
  42281. arc?: number;
  42282. slice?: number;
  42283. sideOrientation?: number;
  42284. frontUVs?: Vector4;
  42285. backUVs?: Vector4;
  42286. updatable?: boolean;
  42287. }, scene: any): Mesh;
  42288. }
  42289. }
  42290. declare module "babylonjs/Debug/physicsViewer" {
  42291. import { Nullable } from "babylonjs/types";
  42292. import { Scene } from "babylonjs/scene";
  42293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42294. import { Mesh } from "babylonjs/Meshes/mesh";
  42295. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42296. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42297. /**
  42298. * Used to show the physics impostor around the specific mesh
  42299. */
  42300. export class PhysicsViewer {
  42301. /** @hidden */
  42302. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42303. /** @hidden */
  42304. protected _meshes: Array<Nullable<AbstractMesh>>;
  42305. /** @hidden */
  42306. protected _scene: Nullable<Scene>;
  42307. /** @hidden */
  42308. protected _numMeshes: number;
  42309. /** @hidden */
  42310. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42311. private _renderFunction;
  42312. private _utilityLayer;
  42313. private _debugBoxMesh;
  42314. private _debugSphereMesh;
  42315. private _debugCylinderMesh;
  42316. private _debugMaterial;
  42317. private _debugMeshMeshes;
  42318. /**
  42319. * Creates a new PhysicsViewer
  42320. * @param scene defines the hosting scene
  42321. */
  42322. constructor(scene: Scene);
  42323. /** @hidden */
  42324. protected _updateDebugMeshes(): void;
  42325. /**
  42326. * Renders a specified physic impostor
  42327. * @param impostor defines the impostor to render
  42328. * @param targetMesh defines the mesh represented by the impostor
  42329. * @returns the new debug mesh used to render the impostor
  42330. */
  42331. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42332. /**
  42333. * Hides a specified physic impostor
  42334. * @param impostor defines the impostor to hide
  42335. */
  42336. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42337. private _getDebugMaterial;
  42338. private _getDebugBoxMesh;
  42339. private _getDebugSphereMesh;
  42340. private _getDebugCylinderMesh;
  42341. private _getDebugMeshMesh;
  42342. private _getDebugMesh;
  42343. /** Releases all resources */
  42344. dispose(): void;
  42345. }
  42346. }
  42347. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42348. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42349. import { Nullable } from "babylonjs/types";
  42350. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42351. import { Scene } from "babylonjs/scene";
  42352. /**
  42353. * Class containing static functions to help procedurally build meshes
  42354. */
  42355. export class LinesBuilder {
  42356. /**
  42357. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42358. * * 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
  42359. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42360. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42361. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42362. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42363. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42364. * * 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
  42365. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42368. * @param name defines the name of the new line system
  42369. * @param options defines the options used to create the line system
  42370. * @param scene defines the hosting scene
  42371. * @returns a new line system mesh
  42372. */
  42373. static CreateLineSystem(name: string, options: {
  42374. lines: Vector3[][];
  42375. updatable?: boolean;
  42376. instance?: Nullable<LinesMesh>;
  42377. colors?: Nullable<Color4[][]>;
  42378. useVertexAlpha?: boolean;
  42379. }, scene: Nullable<Scene>): LinesMesh;
  42380. /**
  42381. * Creates a line mesh
  42382. * 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
  42383. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42384. * * The parameter `points` is an array successive Vector3
  42385. * * 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
  42386. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42387. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42388. * * When updating an instance, remember that only point positions can change, not the number of points
  42389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42391. * @param name defines the name of the new line system
  42392. * @param options defines the options used to create the line system
  42393. * @param scene defines the hosting scene
  42394. * @returns a new line mesh
  42395. */
  42396. static CreateLines(name: string, options: {
  42397. points: Vector3[];
  42398. updatable?: boolean;
  42399. instance?: Nullable<LinesMesh>;
  42400. colors?: Color4[];
  42401. useVertexAlpha?: boolean;
  42402. }, scene?: Nullable<Scene>): LinesMesh;
  42403. /**
  42404. * Creates a dashed line mesh
  42405. * * 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
  42406. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42407. * * The parameter `points` is an array successive Vector3
  42408. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42409. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42410. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42411. * * 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
  42412. * * When updating an instance, remember that only point positions can change, not the number of points
  42413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42414. * @param name defines the name of the mesh
  42415. * @param options defines the options used to create the mesh
  42416. * @param scene defines the hosting scene
  42417. * @returns the dashed line mesh
  42418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42419. */
  42420. static CreateDashedLines(name: string, options: {
  42421. points: Vector3[];
  42422. dashSize?: number;
  42423. gapSize?: number;
  42424. dashNb?: number;
  42425. updatable?: boolean;
  42426. instance?: LinesMesh;
  42427. }, scene?: Nullable<Scene>): LinesMesh;
  42428. }
  42429. }
  42430. declare module "babylonjs/Debug/rayHelper" {
  42431. import { Nullable } from "babylonjs/types";
  42432. import { Ray } from "babylonjs/Culling/ray";
  42433. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42434. import { Scene } from "babylonjs/scene";
  42435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42436. import "babylonjs/Meshes/Builders/linesBuilder";
  42437. /**
  42438. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42439. * in order to better appreciate the issue one might have.
  42440. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42441. */
  42442. export class RayHelper {
  42443. /**
  42444. * Defines the ray we are currently tryin to visualize.
  42445. */
  42446. ray: Nullable<Ray>;
  42447. private _renderPoints;
  42448. private _renderLine;
  42449. private _renderFunction;
  42450. private _scene;
  42451. private _updateToMeshFunction;
  42452. private _attachedToMesh;
  42453. private _meshSpaceDirection;
  42454. private _meshSpaceOrigin;
  42455. /**
  42456. * Helper function to create a colored helper in a scene in one line.
  42457. * @param ray Defines the ray we are currently tryin to visualize
  42458. * @param scene Defines the scene the ray is used in
  42459. * @param color Defines the color we want to see the ray in
  42460. * @returns The newly created ray helper.
  42461. */
  42462. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42463. /**
  42464. * Instantiate a new ray helper.
  42465. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42466. * in order to better appreciate the issue one might have.
  42467. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42468. * @param ray Defines the ray we are currently tryin to visualize
  42469. */
  42470. constructor(ray: Ray);
  42471. /**
  42472. * Shows the ray we are willing to debug.
  42473. * @param scene Defines the scene the ray needs to be rendered in
  42474. * @param color Defines the color the ray needs to be rendered in
  42475. */
  42476. show(scene: Scene, color?: Color3): void;
  42477. /**
  42478. * Hides the ray we are debugging.
  42479. */
  42480. hide(): void;
  42481. private _render;
  42482. /**
  42483. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42484. * @param mesh Defines the mesh we want the helper attached to
  42485. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42486. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42487. * @param length Defines the length of the ray
  42488. */
  42489. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42490. /**
  42491. * Detach the ray helper from the mesh it has previously been attached to.
  42492. */
  42493. detachFromMesh(): void;
  42494. private _updateToMesh;
  42495. /**
  42496. * Dispose the helper and release its associated resources.
  42497. */
  42498. dispose(): void;
  42499. }
  42500. }
  42501. declare module "babylonjs/Debug/skeletonViewer" {
  42502. import { Color3 } from "babylonjs/Maths/math";
  42503. import { Scene } from "babylonjs/scene";
  42504. import { Nullable } from "babylonjs/types";
  42505. import { Skeleton } from "babylonjs/Bones/skeleton";
  42506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42507. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42508. /**
  42509. * Class used to render a debug view of a given skeleton
  42510. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42511. */
  42512. export class SkeletonViewer {
  42513. /** defines the skeleton to render */
  42514. skeleton: Skeleton;
  42515. /** defines the mesh attached to the skeleton */
  42516. mesh: AbstractMesh;
  42517. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42518. autoUpdateBonesMatrices: boolean;
  42519. /** defines the rendering group id to use with the viewer */
  42520. renderingGroupId: number;
  42521. /** Gets or sets the color used to render the skeleton */
  42522. color: Color3;
  42523. private _scene;
  42524. private _debugLines;
  42525. private _debugMesh;
  42526. private _isEnabled;
  42527. private _renderFunction;
  42528. private _utilityLayer;
  42529. /**
  42530. * Returns the mesh used to render the bones
  42531. */
  42532. readonly debugMesh: Nullable<LinesMesh>;
  42533. /**
  42534. * Creates a new SkeletonViewer
  42535. * @param skeleton defines the skeleton to render
  42536. * @param mesh defines the mesh attached to the skeleton
  42537. * @param scene defines the hosting scene
  42538. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42539. * @param renderingGroupId defines the rendering group id to use with the viewer
  42540. */
  42541. constructor(
  42542. /** defines the skeleton to render */
  42543. skeleton: Skeleton,
  42544. /** defines the mesh attached to the skeleton */
  42545. mesh: AbstractMesh, scene: Scene,
  42546. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42547. autoUpdateBonesMatrices?: boolean,
  42548. /** defines the rendering group id to use with the viewer */
  42549. renderingGroupId?: number);
  42550. /** Gets or sets a boolean indicating if the viewer is enabled */
  42551. isEnabled: boolean;
  42552. private _getBonePosition;
  42553. private _getLinesForBonesWithLength;
  42554. private _getLinesForBonesNoLength;
  42555. /** Update the viewer to sync with current skeleton state */
  42556. update(): void;
  42557. /** Release associated resources */
  42558. dispose(): void;
  42559. }
  42560. }
  42561. declare module "babylonjs/Debug/index" {
  42562. export * from "babylonjs/Debug/axesViewer";
  42563. export * from "babylonjs/Debug/boneAxesViewer";
  42564. export * from "babylonjs/Debug/debugLayer";
  42565. export * from "babylonjs/Debug/physicsViewer";
  42566. export * from "babylonjs/Debug/rayHelper";
  42567. export * from "babylonjs/Debug/skeletonViewer";
  42568. }
  42569. declare module "babylonjs/Engines/nullEngine" {
  42570. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42571. import { Scene } from "babylonjs/scene";
  42572. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42573. import { Engine } from "babylonjs/Engines/engine";
  42574. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42575. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42576. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42577. import { Effect } from "babylonjs/Materials/effect";
  42578. /**
  42579. * Options to create the null engine
  42580. */
  42581. export class NullEngineOptions {
  42582. /**
  42583. * Render width (Default: 512)
  42584. */
  42585. renderWidth: number;
  42586. /**
  42587. * Render height (Default: 256)
  42588. */
  42589. renderHeight: number;
  42590. /**
  42591. * Texture size (Default: 512)
  42592. */
  42593. textureSize: number;
  42594. /**
  42595. * If delta time between frames should be constant
  42596. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42597. */
  42598. deterministicLockstep: boolean;
  42599. /**
  42600. * Maximum about of steps between frames (Default: 4)
  42601. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42602. */
  42603. lockstepMaxSteps: number;
  42604. }
  42605. /**
  42606. * The null engine class provides support for headless version of babylon.js.
  42607. * This can be used in server side scenario or for testing purposes
  42608. */
  42609. export class NullEngine extends Engine {
  42610. private _options;
  42611. /**
  42612. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42613. */
  42614. isDeterministicLockStep(): boolean;
  42615. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42616. getLockstepMaxSteps(): number;
  42617. /**
  42618. * Sets hardware scaling, used to save performance if needed
  42619. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42620. */
  42621. getHardwareScalingLevel(): number;
  42622. constructor(options?: NullEngineOptions);
  42623. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42624. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42625. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42626. getRenderWidth(useScreen?: boolean): number;
  42627. getRenderHeight(useScreen?: boolean): number;
  42628. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42629. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42630. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42631. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42632. bindSamplers(effect: Effect): void;
  42633. enableEffect(effect: Effect): void;
  42634. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42635. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42636. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42637. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42638. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42639. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42640. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42641. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42642. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42643. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42644. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42645. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42646. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42647. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42648. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42649. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42650. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42651. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42652. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42653. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42654. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42655. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42656. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42657. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42658. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42659. bindBuffers(vertexBuffers: {
  42660. [key: string]: VertexBuffer;
  42661. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42662. wipeCaches(bruteForce?: boolean): void;
  42663. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42664. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42665. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42666. /** @hidden */
  42667. _createTexture(): WebGLTexture;
  42668. /** @hidden */
  42669. _releaseTexture(texture: InternalTexture): void;
  42670. 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;
  42671. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42672. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42673. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42674. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42675. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42676. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42677. areAllEffectsReady(): boolean;
  42678. /**
  42679. * @hidden
  42680. * Get the current error code of the webGL context
  42681. * @returns the error code
  42682. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42683. */
  42684. getError(): number;
  42685. /** @hidden */
  42686. _getUnpackAlignement(): number;
  42687. /** @hidden */
  42688. _unpackFlipY(value: boolean): void;
  42689. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42690. /**
  42691. * Updates a dynamic vertex buffer.
  42692. * @param vertexBuffer the vertex buffer to update
  42693. * @param data the data used to update the vertex buffer
  42694. * @param byteOffset the byte offset of the data (optional)
  42695. * @param byteLength the byte length of the data (optional)
  42696. */
  42697. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42698. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42699. /** @hidden */
  42700. _bindTexture(channel: number, texture: InternalTexture): void;
  42701. /** @hidden */
  42702. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42703. releaseEffects(): void;
  42704. displayLoadingUI(): void;
  42705. hideLoadingUI(): void;
  42706. /** @hidden */
  42707. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42708. /** @hidden */
  42709. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42710. /** @hidden */
  42711. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42712. /** @hidden */
  42713. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42714. }
  42715. }
  42716. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42717. import { Nullable, int } from "babylonjs/types";
  42718. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42719. /** @hidden */
  42720. export class _OcclusionDataStorage {
  42721. /** @hidden */
  42722. occlusionInternalRetryCounter: number;
  42723. /** @hidden */
  42724. isOcclusionQueryInProgress: boolean;
  42725. /** @hidden */
  42726. isOccluded: boolean;
  42727. /** @hidden */
  42728. occlusionRetryCount: number;
  42729. /** @hidden */
  42730. occlusionType: number;
  42731. /** @hidden */
  42732. occlusionQueryAlgorithmType: number;
  42733. }
  42734. module "babylonjs/Engines/engine" {
  42735. interface Engine {
  42736. /**
  42737. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42738. * @return the new query
  42739. */
  42740. createQuery(): WebGLQuery;
  42741. /**
  42742. * Delete and release a webGL query
  42743. * @param query defines the query to delete
  42744. * @return the current engine
  42745. */
  42746. deleteQuery(query: WebGLQuery): Engine;
  42747. /**
  42748. * Check if a given query has resolved and got its value
  42749. * @param query defines the query to check
  42750. * @returns true if the query got its value
  42751. */
  42752. isQueryResultAvailable(query: WebGLQuery): boolean;
  42753. /**
  42754. * Gets the value of a given query
  42755. * @param query defines the query to check
  42756. * @returns the value of the query
  42757. */
  42758. getQueryResult(query: WebGLQuery): number;
  42759. /**
  42760. * Initiates an occlusion query
  42761. * @param algorithmType defines the algorithm to use
  42762. * @param query defines the query to use
  42763. * @returns the current engine
  42764. * @see http://doc.babylonjs.com/features/occlusionquery
  42765. */
  42766. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42767. /**
  42768. * Ends an occlusion query
  42769. * @see http://doc.babylonjs.com/features/occlusionquery
  42770. * @param algorithmType defines the algorithm to use
  42771. * @returns the current engine
  42772. */
  42773. endOcclusionQuery(algorithmType: number): Engine;
  42774. /**
  42775. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42776. * Please note that only one query can be issued at a time
  42777. * @returns a time token used to track the time span
  42778. */
  42779. startTimeQuery(): Nullable<_TimeToken>;
  42780. /**
  42781. * Ends a time query
  42782. * @param token defines the token used to measure the time span
  42783. * @returns the time spent (in ns)
  42784. */
  42785. endTimeQuery(token: _TimeToken): int;
  42786. /** @hidden */
  42787. _currentNonTimestampToken: Nullable<_TimeToken>;
  42788. /** @hidden */
  42789. _createTimeQuery(): WebGLQuery;
  42790. /** @hidden */
  42791. _deleteTimeQuery(query: WebGLQuery): void;
  42792. /** @hidden */
  42793. _getGlAlgorithmType(algorithmType: number): number;
  42794. /** @hidden */
  42795. _getTimeQueryResult(query: WebGLQuery): any;
  42796. /** @hidden */
  42797. _getTimeQueryAvailability(query: WebGLQuery): any;
  42798. }
  42799. }
  42800. module "babylonjs/Meshes/abstractMesh" {
  42801. interface AbstractMesh {
  42802. /**
  42803. * Backing filed
  42804. * @hidden
  42805. */
  42806. __occlusionDataStorage: _OcclusionDataStorage;
  42807. /**
  42808. * Access property
  42809. * @hidden
  42810. */
  42811. _occlusionDataStorage: _OcclusionDataStorage;
  42812. /**
  42813. * 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.
  42814. * The default value is -1 which means don't break the query and wait till the result
  42815. * @see http://doc.babylonjs.com/features/occlusionquery
  42816. */
  42817. occlusionRetryCount: number;
  42818. /**
  42819. * 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:
  42820. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42821. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42822. * * 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.
  42823. * @see http://doc.babylonjs.com/features/occlusionquery
  42824. */
  42825. occlusionType: number;
  42826. /**
  42827. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42828. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42829. * * 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.
  42830. * @see http://doc.babylonjs.com/features/occlusionquery
  42831. */
  42832. occlusionQueryAlgorithmType: number;
  42833. /**
  42834. * 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
  42835. * @see http://doc.babylonjs.com/features/occlusionquery
  42836. */
  42837. isOccluded: boolean;
  42838. /**
  42839. * Flag to check the progress status of the query
  42840. * @see http://doc.babylonjs.com/features/occlusionquery
  42841. */
  42842. isOcclusionQueryInProgress: boolean;
  42843. }
  42844. }
  42845. }
  42846. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42847. import { Nullable } from "babylonjs/types";
  42848. /** @hidden */
  42849. export var _forceTransformFeedbackToBundle: boolean;
  42850. module "babylonjs/Engines/engine" {
  42851. interface Engine {
  42852. /**
  42853. * Creates a webGL transform feedback object
  42854. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42855. * @returns the webGL transform feedback object
  42856. */
  42857. createTransformFeedback(): WebGLTransformFeedback;
  42858. /**
  42859. * Delete a webGL transform feedback object
  42860. * @param value defines the webGL transform feedback object to delete
  42861. */
  42862. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42863. /**
  42864. * Bind a webGL transform feedback object to the webgl context
  42865. * @param value defines the webGL transform feedback object to bind
  42866. */
  42867. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42868. /**
  42869. * Begins a transform feedback operation
  42870. * @param usePoints defines if points or triangles must be used
  42871. */
  42872. beginTransformFeedback(usePoints: boolean): void;
  42873. /**
  42874. * Ends a transform feedback operation
  42875. */
  42876. endTransformFeedback(): void;
  42877. /**
  42878. * Specify the varyings to use with transform feedback
  42879. * @param program defines the associated webGL program
  42880. * @param value defines the list of strings representing the varying names
  42881. */
  42882. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42883. /**
  42884. * Bind a webGL buffer for a transform feedback operation
  42885. * @param value defines the webGL buffer to bind
  42886. */
  42887. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42888. }
  42889. }
  42890. }
  42891. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  42892. import { Scene } from "babylonjs/scene";
  42893. import { Engine } from "babylonjs/Engines/engine";
  42894. import { Texture } from "babylonjs/Materials/Textures/texture";
  42895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42896. import "babylonjs/Engines/Extensions/engine.multiRender";
  42897. /**
  42898. * Creation options of the multi render target texture.
  42899. */
  42900. export interface IMultiRenderTargetOptions {
  42901. /**
  42902. * Define if the texture needs to create mip maps after render.
  42903. */
  42904. generateMipMaps?: boolean;
  42905. /**
  42906. * Define the types of all the draw buffers we want to create
  42907. */
  42908. types?: number[];
  42909. /**
  42910. * Define the sampling modes of all the draw buffers we want to create
  42911. */
  42912. samplingModes?: number[];
  42913. /**
  42914. * Define if a depth buffer is required
  42915. */
  42916. generateDepthBuffer?: boolean;
  42917. /**
  42918. * Define if a stencil buffer is required
  42919. */
  42920. generateStencilBuffer?: boolean;
  42921. /**
  42922. * Define if a depth texture is required instead of a depth buffer
  42923. */
  42924. generateDepthTexture?: boolean;
  42925. /**
  42926. * Define the number of desired draw buffers
  42927. */
  42928. textureCount?: number;
  42929. /**
  42930. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42931. */
  42932. doNotChangeAspectRatio?: boolean;
  42933. /**
  42934. * Define the default type of the buffers we are creating
  42935. */
  42936. defaultType?: number;
  42937. }
  42938. /**
  42939. * A multi render target, like a render target provides the ability to render to a texture.
  42940. * Unlike the render target, it can render to several draw buffers in one draw.
  42941. * This is specially interesting in deferred rendering or for any effects requiring more than
  42942. * just one color from a single pass.
  42943. */
  42944. export class MultiRenderTarget extends RenderTargetTexture {
  42945. private _internalTextures;
  42946. private _textures;
  42947. private _multiRenderTargetOptions;
  42948. /**
  42949. * Get if draw buffers are currently supported by the used hardware and browser.
  42950. */
  42951. readonly isSupported: boolean;
  42952. /**
  42953. * Get the list of textures generated by the multi render target.
  42954. */
  42955. readonly textures: Texture[];
  42956. /**
  42957. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42958. */
  42959. readonly depthTexture: Texture;
  42960. /**
  42961. * Set the wrapping mode on U of all the textures we are rendering to.
  42962. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42963. */
  42964. wrapU: number;
  42965. /**
  42966. * Set the wrapping mode on V of all the textures we are rendering to.
  42967. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42968. */
  42969. wrapV: number;
  42970. /**
  42971. * Instantiate a new multi render target texture.
  42972. * A multi render target, like a render target provides the ability to render to a texture.
  42973. * Unlike the render target, it can render to several draw buffers in one draw.
  42974. * This is specially interesting in deferred rendering or for any effects requiring more than
  42975. * just one color from a single pass.
  42976. * @param name Define the name of the texture
  42977. * @param size Define the size of the buffers to render to
  42978. * @param count Define the number of target we are rendering into
  42979. * @param scene Define the scene the texture belongs to
  42980. * @param options Define the options used to create the multi render target
  42981. */
  42982. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42983. /** @hidden */
  42984. _rebuild(): void;
  42985. private _createInternalTextures;
  42986. private _createTextures;
  42987. /**
  42988. * Define the number of samples used if MSAA is enabled.
  42989. */
  42990. samples: number;
  42991. /**
  42992. * Resize all the textures in the multi render target.
  42993. * Be carrefull as it will recreate all the data in the new texture.
  42994. * @param size Define the new size
  42995. */
  42996. resize(size: any): void;
  42997. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42998. /**
  42999. * Dispose the render targets and their associated resources
  43000. */
  43001. dispose(): void;
  43002. /**
  43003. * Release all the underlying texture used as draw buffers.
  43004. */
  43005. releaseInternalTextures(): void;
  43006. }
  43007. }
  43008. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43009. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43010. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43011. import { Nullable } from "babylonjs/types";
  43012. module "babylonjs/Engines/engine" {
  43013. interface Engine {
  43014. /**
  43015. * Unbind a list of render target textures from the webGL context
  43016. * This is used only when drawBuffer extension or webGL2 are active
  43017. * @param textures defines the render target textures to unbind
  43018. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43019. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43020. */
  43021. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43022. /**
  43023. * Create a multi render target texture
  43024. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43025. * @param size defines the size of the texture
  43026. * @param options defines the creation options
  43027. * @returns the cube texture as an InternalTexture
  43028. */
  43029. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43030. /**
  43031. * Update the sample count for a given multiple render target texture
  43032. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43033. * @param textures defines the textures to update
  43034. * @param samples defines the sample count to set
  43035. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43036. */
  43037. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43038. }
  43039. }
  43040. }
  43041. declare module "babylonjs/Engines/Extensions/index" {
  43042. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43043. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43044. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43045. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43046. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43047. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43048. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43049. }
  43050. declare module "babylonjs/Engines/index" {
  43051. export * from "babylonjs/Engines/constants";
  43052. export * from "babylonjs/Engines/engine";
  43053. export * from "babylonjs/Engines/engineStore";
  43054. export * from "babylonjs/Engines/nullEngine";
  43055. export * from "babylonjs/Engines/Extensions/index";
  43056. }
  43057. declare module "babylonjs/Events/clipboardEvents" {
  43058. /**
  43059. * Gather the list of clipboard event types as constants.
  43060. */
  43061. export class ClipboardEventTypes {
  43062. /**
  43063. * The clipboard event is fired when a copy command is active (pressed).
  43064. */
  43065. static readonly COPY: number;
  43066. /**
  43067. * The clipboard event is fired when a cut command is active (pressed).
  43068. */
  43069. static readonly CUT: number;
  43070. /**
  43071. * The clipboard event is fired when a paste command is active (pressed).
  43072. */
  43073. static readonly PASTE: number;
  43074. }
  43075. /**
  43076. * This class is used to store clipboard related info for the onClipboardObservable event.
  43077. */
  43078. export class ClipboardInfo {
  43079. /**
  43080. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43081. */
  43082. type: number;
  43083. /**
  43084. * Defines the related dom event
  43085. */
  43086. event: ClipboardEvent;
  43087. /**
  43088. *Creates an instance of ClipboardInfo.
  43089. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43090. * @param event Defines the related dom event
  43091. */
  43092. constructor(
  43093. /**
  43094. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43095. */
  43096. type: number,
  43097. /**
  43098. * Defines the related dom event
  43099. */
  43100. event: ClipboardEvent);
  43101. /**
  43102. * Get the clipboard event's type from the keycode.
  43103. * @param keyCode Defines the keyCode for the current keyboard event.
  43104. * @return {number}
  43105. */
  43106. static GetTypeFromCharacter(keyCode: number): number;
  43107. }
  43108. }
  43109. declare module "babylonjs/Events/index" {
  43110. export * from "babylonjs/Events/keyboardEvents";
  43111. export * from "babylonjs/Events/pointerEvents";
  43112. export * from "babylonjs/Events/clipboardEvents";
  43113. }
  43114. declare module "babylonjs/Loading/sceneLoader" {
  43115. import { Observable } from "babylonjs/Misc/observable";
  43116. import { Nullable } from "babylonjs/types";
  43117. import { Scene } from "babylonjs/scene";
  43118. import { Engine } from "babylonjs/Engines/engine";
  43119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43120. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43121. import { AssetContainer } from "babylonjs/assetContainer";
  43122. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43123. import { Skeleton } from "babylonjs/Bones/skeleton";
  43124. /**
  43125. * Class used to represent data loading progression
  43126. */
  43127. export class SceneLoaderProgressEvent {
  43128. /** defines if data length to load can be evaluated */
  43129. readonly lengthComputable: boolean;
  43130. /** defines the loaded data length */
  43131. readonly loaded: number;
  43132. /** defines the data length to load */
  43133. readonly total: number;
  43134. /**
  43135. * Create a new progress event
  43136. * @param lengthComputable defines if data length to load can be evaluated
  43137. * @param loaded defines the loaded data length
  43138. * @param total defines the data length to load
  43139. */
  43140. constructor(
  43141. /** defines if data length to load can be evaluated */
  43142. lengthComputable: boolean,
  43143. /** defines the loaded data length */
  43144. loaded: number,
  43145. /** defines the data length to load */
  43146. total: number);
  43147. /**
  43148. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43149. * @param event defines the source event
  43150. * @returns a new SceneLoaderProgressEvent
  43151. */
  43152. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43153. }
  43154. /**
  43155. * Interface used by SceneLoader plugins to define supported file extensions
  43156. */
  43157. export interface ISceneLoaderPluginExtensions {
  43158. /**
  43159. * Defines the list of supported extensions
  43160. */
  43161. [extension: string]: {
  43162. isBinary: boolean;
  43163. };
  43164. }
  43165. /**
  43166. * Interface used by SceneLoader plugin factory
  43167. */
  43168. export interface ISceneLoaderPluginFactory {
  43169. /**
  43170. * Defines the name of the factory
  43171. */
  43172. name: string;
  43173. /**
  43174. * Function called to create a new plugin
  43175. * @return the new plugin
  43176. */
  43177. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43178. /**
  43179. * Boolean indicating if the plugin can direct load specific data
  43180. */
  43181. canDirectLoad?: (data: string) => boolean;
  43182. }
  43183. /**
  43184. * Interface used to define a SceneLoader plugin
  43185. */
  43186. export interface ISceneLoaderPlugin {
  43187. /**
  43188. * The friendly name of this plugin.
  43189. */
  43190. name: string;
  43191. /**
  43192. * The file extensions supported by this plugin.
  43193. */
  43194. extensions: string | ISceneLoaderPluginExtensions;
  43195. /**
  43196. * Import meshes into a scene.
  43197. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43198. * @param scene The scene to import into
  43199. * @param data The data to import
  43200. * @param rootUrl The root url for scene and resources
  43201. * @param meshes The meshes array to import into
  43202. * @param particleSystems The particle systems array to import into
  43203. * @param skeletons The skeletons array to import into
  43204. * @param onError The callback when import fails
  43205. * @returns True if successful or false otherwise
  43206. */
  43207. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43208. /**
  43209. * Load into a scene.
  43210. * @param scene The scene to load into
  43211. * @param data The data to import
  43212. * @param rootUrl The root url for scene and resources
  43213. * @param onError The callback when import fails
  43214. * @returns true if successful or false otherwise
  43215. */
  43216. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43217. /**
  43218. * The callback that returns true if the data can be directly loaded.
  43219. */
  43220. canDirectLoad?: (data: string) => boolean;
  43221. /**
  43222. * The callback that allows custom handling of the root url based on the response url.
  43223. */
  43224. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43225. /**
  43226. * Load into an asset container.
  43227. * @param scene The scene to load into
  43228. * @param data The data to import
  43229. * @param rootUrl The root url for scene and resources
  43230. * @param onError The callback when import fails
  43231. * @returns The loaded asset container
  43232. */
  43233. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43234. }
  43235. /**
  43236. * Interface used to define an async SceneLoader plugin
  43237. */
  43238. export interface ISceneLoaderPluginAsync {
  43239. /**
  43240. * The friendly name of this plugin.
  43241. */
  43242. name: string;
  43243. /**
  43244. * The file extensions supported by this plugin.
  43245. */
  43246. extensions: string | ISceneLoaderPluginExtensions;
  43247. /**
  43248. * Import meshes into a scene.
  43249. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43250. * @param scene The scene to import into
  43251. * @param data The data to import
  43252. * @param rootUrl The root url for scene and resources
  43253. * @param onProgress The callback when the load progresses
  43254. * @param fileName Defines the name of the file to load
  43255. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43256. */
  43257. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43258. meshes: AbstractMesh[];
  43259. particleSystems: IParticleSystem[];
  43260. skeletons: Skeleton[];
  43261. animationGroups: AnimationGroup[];
  43262. }>;
  43263. /**
  43264. * Load into a scene.
  43265. * @param scene The scene to load into
  43266. * @param data The data to import
  43267. * @param rootUrl The root url for scene and resources
  43268. * @param onProgress The callback when the load progresses
  43269. * @param fileName Defines the name of the file to load
  43270. * @returns Nothing
  43271. */
  43272. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43273. /**
  43274. * The callback that returns true if the data can be directly loaded.
  43275. */
  43276. canDirectLoad?: (data: string) => boolean;
  43277. /**
  43278. * The callback that allows custom handling of the root url based on the response url.
  43279. */
  43280. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43281. /**
  43282. * Load into an asset container.
  43283. * @param scene The scene to load into
  43284. * @param data The data to import
  43285. * @param rootUrl The root url for scene and resources
  43286. * @param onProgress The callback when the load progresses
  43287. * @param fileName Defines the name of the file to load
  43288. * @returns The loaded asset container
  43289. */
  43290. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43291. }
  43292. /**
  43293. * Class used to load scene from various file formats using registered plugins
  43294. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43295. */
  43296. export class SceneLoader {
  43297. /**
  43298. * No logging while loading
  43299. */
  43300. static readonly NO_LOGGING: number;
  43301. /**
  43302. * Minimal logging while loading
  43303. */
  43304. static readonly MINIMAL_LOGGING: number;
  43305. /**
  43306. * Summary logging while loading
  43307. */
  43308. static readonly SUMMARY_LOGGING: number;
  43309. /**
  43310. * Detailled logging while loading
  43311. */
  43312. static readonly DETAILED_LOGGING: number;
  43313. /**
  43314. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43315. */
  43316. static ForceFullSceneLoadingForIncremental: boolean;
  43317. /**
  43318. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43319. */
  43320. static ShowLoadingScreen: boolean;
  43321. /**
  43322. * Defines the current logging level (while loading the scene)
  43323. * @ignorenaming
  43324. */
  43325. static loggingLevel: number;
  43326. /**
  43327. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43328. */
  43329. static CleanBoneMatrixWeights: boolean;
  43330. /**
  43331. * Event raised when a plugin is used to load a scene
  43332. */
  43333. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43334. private static _registeredPlugins;
  43335. private static _getDefaultPlugin;
  43336. private static _getPluginForExtension;
  43337. private static _getPluginForDirectLoad;
  43338. private static _getPluginForFilename;
  43339. private static _getDirectLoad;
  43340. private static _loadData;
  43341. private static _getFileInfo;
  43342. /**
  43343. * Gets a plugin that can load the given extension
  43344. * @param extension defines the extension to load
  43345. * @returns a plugin or null if none works
  43346. */
  43347. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43348. /**
  43349. * Gets a boolean indicating that the given extension can be loaded
  43350. * @param extension defines the extension to load
  43351. * @returns true if the extension is supported
  43352. */
  43353. static IsPluginForExtensionAvailable(extension: string): boolean;
  43354. /**
  43355. * Adds a new plugin to the list of registered plugins
  43356. * @param plugin defines the plugin to add
  43357. */
  43358. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43359. /**
  43360. * Import meshes into a scene
  43361. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43362. * @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)
  43363. * @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)
  43364. * @param scene the instance of BABYLON.Scene to append to
  43365. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43366. * @param onProgress a callback with a progress event for each file being loaded
  43367. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43368. * @param pluginExtension the extension used to determine the plugin
  43369. * @returns The loaded plugin
  43370. */
  43371. 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>;
  43372. /**
  43373. * Import meshes into a scene
  43374. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43375. * @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)
  43376. * @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)
  43377. * @param scene the instance of BABYLON.Scene to append to
  43378. * @param onProgress a callback with a progress event for each file being loaded
  43379. * @param pluginExtension the extension used to determine the plugin
  43380. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43381. */
  43382. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43383. meshes: AbstractMesh[];
  43384. particleSystems: IParticleSystem[];
  43385. skeletons: Skeleton[];
  43386. animationGroups: AnimationGroup[];
  43387. }>;
  43388. /**
  43389. * Load a scene
  43390. * @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)
  43391. * @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)
  43392. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43393. * @param onSuccess a callback with the scene when import succeeds
  43394. * @param onProgress a callback with a progress event for each file being loaded
  43395. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43396. * @param pluginExtension the extension used to determine the plugin
  43397. * @returns The loaded plugin
  43398. */
  43399. 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>;
  43400. /**
  43401. * Load a scene
  43402. * @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)
  43403. * @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)
  43404. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43405. * @param onProgress a callback with a progress event for each file being loaded
  43406. * @param pluginExtension the extension used to determine the plugin
  43407. * @returns The loaded scene
  43408. */
  43409. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43410. /**
  43411. * Append a scene
  43412. * @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)
  43413. * @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)
  43414. * @param scene is the instance of BABYLON.Scene to append to
  43415. * @param onSuccess a callback with the scene when import succeeds
  43416. * @param onProgress a callback with a progress event for each file being loaded
  43417. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43418. * @param pluginExtension the extension used to determine the plugin
  43419. * @returns The loaded plugin
  43420. */
  43421. 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>;
  43422. /**
  43423. * Append a scene
  43424. * @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)
  43425. * @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)
  43426. * @param scene is the instance of BABYLON.Scene to append to
  43427. * @param onProgress a callback with a progress event for each file being loaded
  43428. * @param pluginExtension the extension used to determine the plugin
  43429. * @returns The given scene
  43430. */
  43431. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43432. /**
  43433. * Load a scene into an asset container
  43434. * @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)
  43435. * @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)
  43436. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43437. * @param onSuccess a callback with the scene when import succeeds
  43438. * @param onProgress a callback with a progress event for each file being loaded
  43439. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43440. * @param pluginExtension the extension used to determine the plugin
  43441. * @returns The loaded plugin
  43442. */
  43443. 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>;
  43444. /**
  43445. * Load a scene into an asset container
  43446. * @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)
  43447. * @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)
  43448. * @param scene is the instance of Scene to append to
  43449. * @param onProgress a callback with a progress event for each file being loaded
  43450. * @param pluginExtension the extension used to determine the plugin
  43451. * @returns The loaded asset container
  43452. */
  43453. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43454. }
  43455. }
  43456. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43457. import { Scene } from "babylonjs/scene";
  43458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43459. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43460. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43461. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43462. /**
  43463. * Google Daydream controller
  43464. */
  43465. export class DaydreamController extends WebVRController {
  43466. /**
  43467. * Base Url for the controller model.
  43468. */
  43469. static MODEL_BASE_URL: string;
  43470. /**
  43471. * File name for the controller model.
  43472. */
  43473. static MODEL_FILENAME: string;
  43474. /**
  43475. * Gamepad Id prefix used to identify Daydream Controller.
  43476. */
  43477. static readonly GAMEPAD_ID_PREFIX: string;
  43478. /**
  43479. * Creates a new DaydreamController from a gamepad
  43480. * @param vrGamepad the gamepad that the controller should be created from
  43481. */
  43482. constructor(vrGamepad: any);
  43483. /**
  43484. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43485. * @param scene scene in which to add meshes
  43486. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43487. */
  43488. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43489. /**
  43490. * Called once for each button that changed state since the last frame
  43491. * @param buttonIdx Which button index changed
  43492. * @param state New state of the button
  43493. * @param changes Which properties on the state changed since last frame
  43494. */
  43495. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43496. }
  43497. }
  43498. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43499. import { Scene } from "babylonjs/scene";
  43500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43501. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43502. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43503. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43504. /**
  43505. * Gear VR Controller
  43506. */
  43507. export class GearVRController extends WebVRController {
  43508. /**
  43509. * Base Url for the controller model.
  43510. */
  43511. static MODEL_BASE_URL: string;
  43512. /**
  43513. * File name for the controller model.
  43514. */
  43515. static MODEL_FILENAME: string;
  43516. /**
  43517. * Gamepad Id prefix used to identify this controller.
  43518. */
  43519. static readonly GAMEPAD_ID_PREFIX: string;
  43520. private readonly _buttonIndexToObservableNameMap;
  43521. /**
  43522. * Creates a new GearVRController from a gamepad
  43523. * @param vrGamepad the gamepad that the controller should be created from
  43524. */
  43525. constructor(vrGamepad: any);
  43526. /**
  43527. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43528. * @param scene scene in which to add meshes
  43529. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43530. */
  43531. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43532. /**
  43533. * Called once for each button that changed state since the last frame
  43534. * @param buttonIdx Which button index changed
  43535. * @param state New state of the button
  43536. * @param changes Which properties on the state changed since last frame
  43537. */
  43538. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43539. }
  43540. }
  43541. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43542. import { Scene } from "babylonjs/scene";
  43543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43544. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43545. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43546. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43547. /**
  43548. * Generic Controller
  43549. */
  43550. export class GenericController extends WebVRController {
  43551. /**
  43552. * Base Url for the controller model.
  43553. */
  43554. static readonly MODEL_BASE_URL: string;
  43555. /**
  43556. * File name for the controller model.
  43557. */
  43558. static readonly MODEL_FILENAME: string;
  43559. /**
  43560. * Creates a new GenericController from a gamepad
  43561. * @param vrGamepad the gamepad that the controller should be created from
  43562. */
  43563. constructor(vrGamepad: any);
  43564. /**
  43565. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43566. * @param scene scene in which to add meshes
  43567. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43568. */
  43569. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43570. /**
  43571. * Called once for each button that changed state since the last frame
  43572. * @param buttonIdx Which button index changed
  43573. * @param state New state of the button
  43574. * @param changes Which properties on the state changed since last frame
  43575. */
  43576. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43577. }
  43578. }
  43579. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43580. import { Observable } from "babylonjs/Misc/observable";
  43581. import { Scene } from "babylonjs/scene";
  43582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43583. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43584. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43585. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43586. /**
  43587. * Oculus Touch Controller
  43588. */
  43589. export class OculusTouchController extends WebVRController {
  43590. /**
  43591. * Base Url for the controller model.
  43592. */
  43593. static MODEL_BASE_URL: string;
  43594. /**
  43595. * File name for the left controller model.
  43596. */
  43597. static MODEL_LEFT_FILENAME: string;
  43598. /**
  43599. * File name for the right controller model.
  43600. */
  43601. static MODEL_RIGHT_FILENAME: string;
  43602. /**
  43603. * Fired when the secondary trigger on this controller is modified
  43604. */
  43605. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43606. /**
  43607. * Fired when the thumb rest on this controller is modified
  43608. */
  43609. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43610. /**
  43611. * Creates a new OculusTouchController from a gamepad
  43612. * @param vrGamepad the gamepad that the controller should be created from
  43613. */
  43614. constructor(vrGamepad: any);
  43615. /**
  43616. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43617. * @param scene scene in which to add meshes
  43618. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43619. */
  43620. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43621. /**
  43622. * Fired when the A button on this controller is modified
  43623. */
  43624. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43625. /**
  43626. * Fired when the B button on this controller is modified
  43627. */
  43628. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43629. /**
  43630. * Fired when the X button on this controller is modified
  43631. */
  43632. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43633. /**
  43634. * Fired when the Y button on this controller is modified
  43635. */
  43636. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43637. /**
  43638. * Called once for each button that changed state since the last frame
  43639. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43640. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43641. * 2) secondary trigger (same)
  43642. * 3) A (right) X (left), touch, pressed = value
  43643. * 4) B / Y
  43644. * 5) thumb rest
  43645. * @param buttonIdx Which button index changed
  43646. * @param state New state of the button
  43647. * @param changes Which properties on the state changed since last frame
  43648. */
  43649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43650. }
  43651. }
  43652. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43653. import { Scene } from "babylonjs/scene";
  43654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43655. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43656. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43657. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43658. import { Observable } from "babylonjs/Misc/observable";
  43659. /**
  43660. * Vive Controller
  43661. */
  43662. export class ViveController extends WebVRController {
  43663. /**
  43664. * Base Url for the controller model.
  43665. */
  43666. static MODEL_BASE_URL: string;
  43667. /**
  43668. * File name for the controller model.
  43669. */
  43670. static MODEL_FILENAME: string;
  43671. /**
  43672. * Creates a new ViveController from a gamepad
  43673. * @param vrGamepad the gamepad that the controller should be created from
  43674. */
  43675. constructor(vrGamepad: any);
  43676. /**
  43677. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43678. * @param scene scene in which to add meshes
  43679. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43680. */
  43681. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43682. /**
  43683. * Fired when the left button on this controller is modified
  43684. */
  43685. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43686. /**
  43687. * Fired when the right button on this controller is modified
  43688. */
  43689. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43690. /**
  43691. * Fired when the menu button on this controller is modified
  43692. */
  43693. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43694. /**
  43695. * Called once for each button that changed state since the last frame
  43696. * Vive mapping:
  43697. * 0: touchpad
  43698. * 1: trigger
  43699. * 2: left AND right buttons
  43700. * 3: menu button
  43701. * @param buttonIdx Which button index changed
  43702. * @param state New state of the button
  43703. * @param changes Which properties on the state changed since last frame
  43704. */
  43705. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43706. }
  43707. }
  43708. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43709. import { Observable } from "babylonjs/Misc/observable";
  43710. import { Scene } from "babylonjs/scene";
  43711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43712. import { Ray } from "babylonjs/Culling/ray";
  43713. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43714. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43715. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43716. /**
  43717. * Defines the WindowsMotionController object that the state of the windows motion controller
  43718. */
  43719. export class WindowsMotionController extends WebVRController {
  43720. /**
  43721. * The base url used to load the left and right controller models
  43722. */
  43723. static MODEL_BASE_URL: string;
  43724. /**
  43725. * The name of the left controller model file
  43726. */
  43727. static MODEL_LEFT_FILENAME: string;
  43728. /**
  43729. * The name of the right controller model file
  43730. */
  43731. static MODEL_RIGHT_FILENAME: string;
  43732. /**
  43733. * The controller name prefix for this controller type
  43734. */
  43735. static readonly GAMEPAD_ID_PREFIX: string;
  43736. /**
  43737. * The controller id pattern for this controller type
  43738. */
  43739. private static readonly GAMEPAD_ID_PATTERN;
  43740. private _loadedMeshInfo;
  43741. private readonly _mapping;
  43742. /**
  43743. * Fired when the trackpad on this controller is clicked
  43744. */
  43745. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43746. /**
  43747. * Fired when the trackpad on this controller is modified
  43748. */
  43749. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43750. /**
  43751. * The current x and y values of this controller's trackpad
  43752. */
  43753. trackpad: StickValues;
  43754. /**
  43755. * Creates a new WindowsMotionController from a gamepad
  43756. * @param vrGamepad the gamepad that the controller should be created from
  43757. */
  43758. constructor(vrGamepad: any);
  43759. /**
  43760. * Fired when the trigger on this controller is modified
  43761. */
  43762. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43763. /**
  43764. * Fired when the menu button on this controller is modified
  43765. */
  43766. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43767. /**
  43768. * Fired when the grip button on this controller is modified
  43769. */
  43770. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43771. /**
  43772. * Fired when the thumbstick button on this controller is modified
  43773. */
  43774. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43775. /**
  43776. * Fired when the touchpad button on this controller is modified
  43777. */
  43778. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43779. /**
  43780. * Fired when the touchpad values on this controller are modified
  43781. */
  43782. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43783. private _updateTrackpad;
  43784. /**
  43785. * Called once per frame by the engine.
  43786. */
  43787. update(): void;
  43788. /**
  43789. * Called once for each button that changed state since the last frame
  43790. * @param buttonIdx Which button index changed
  43791. * @param state New state of the button
  43792. * @param changes Which properties on the state changed since last frame
  43793. */
  43794. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43795. /**
  43796. * Moves the buttons on the controller mesh based on their current state
  43797. * @param buttonName the name of the button to move
  43798. * @param buttonValue the value of the button which determines the buttons new position
  43799. */
  43800. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43801. /**
  43802. * Moves the axis on the controller mesh based on its current state
  43803. * @param axis the index of the axis
  43804. * @param axisValue the value of the axis which determines the meshes new position
  43805. * @hidden
  43806. */
  43807. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43808. /**
  43809. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43810. * @param scene scene in which to add meshes
  43811. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43812. */
  43813. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43814. /**
  43815. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43816. * can be transformed by button presses and axes values, based on this._mapping.
  43817. *
  43818. * @param scene scene in which the meshes exist
  43819. * @param meshes list of meshes that make up the controller model to process
  43820. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43821. */
  43822. private processModel;
  43823. private createMeshInfo;
  43824. /**
  43825. * Gets the ray of the controller in the direction the controller is pointing
  43826. * @param length the length the resulting ray should be
  43827. * @returns a ray in the direction the controller is pointing
  43828. */
  43829. getForwardRay(length?: number): Ray;
  43830. /**
  43831. * Disposes of the controller
  43832. */
  43833. dispose(): void;
  43834. }
  43835. }
  43836. declare module "babylonjs/Gamepads/Controllers/index" {
  43837. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43838. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43839. export * from "babylonjs/Gamepads/Controllers/genericController";
  43840. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43841. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43842. export * from "babylonjs/Gamepads/Controllers/viveController";
  43843. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43844. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43845. }
  43846. declare module "babylonjs/Gamepads/index" {
  43847. export * from "babylonjs/Gamepads/Controllers/index";
  43848. export * from "babylonjs/Gamepads/gamepad";
  43849. export * from "babylonjs/Gamepads/gamepadManager";
  43850. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43851. export * from "babylonjs/Gamepads/xboxGamepad";
  43852. }
  43853. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43854. import { Observable } from "babylonjs/Misc/observable";
  43855. import { Nullable } from "babylonjs/types";
  43856. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43858. import { Mesh } from "babylonjs/Meshes/mesh";
  43859. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43860. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43861. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43862. /**
  43863. * Single axis scale gizmo
  43864. */
  43865. export class AxisScaleGizmo extends Gizmo {
  43866. private _coloredMaterial;
  43867. /**
  43868. * Drag behavior responsible for the gizmos dragging interactions
  43869. */
  43870. dragBehavior: PointerDragBehavior;
  43871. private _pointerObserver;
  43872. /**
  43873. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43874. */
  43875. snapDistance: number;
  43876. /**
  43877. * Event that fires each time the gizmo snaps to a new location.
  43878. * * snapDistance is the the change in distance
  43879. */
  43880. onSnapObservable: Observable<{
  43881. snapDistance: number;
  43882. }>;
  43883. /**
  43884. * If the scaling operation should be done on all axis (default: false)
  43885. */
  43886. uniformScaling: boolean;
  43887. /**
  43888. * Creates an AxisScaleGizmo
  43889. * @param gizmoLayer The utility layer the gizmo will be added to
  43890. * @param dragAxis The axis which the gizmo will be able to scale on
  43891. * @param color The color of the gizmo
  43892. */
  43893. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43894. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43895. /**
  43896. * Disposes of the gizmo
  43897. */
  43898. dispose(): void;
  43899. /**
  43900. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43901. * @param mesh The mesh to replace the default mesh of the gizmo
  43902. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43903. */
  43904. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43905. }
  43906. }
  43907. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43908. import { Observable } from "babylonjs/Misc/observable";
  43909. import { Nullable } from "babylonjs/types";
  43910. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43912. import { Mesh } from "babylonjs/Meshes/mesh";
  43913. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43914. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43915. import "babylonjs/Meshes/Builders/boxBuilder";
  43916. /**
  43917. * Bounding box gizmo
  43918. */
  43919. export class BoundingBoxGizmo extends Gizmo {
  43920. private _lineBoundingBox;
  43921. private _rotateSpheresParent;
  43922. private _scaleBoxesParent;
  43923. private _boundingDimensions;
  43924. private _renderObserver;
  43925. private _pointerObserver;
  43926. private _scaleDragSpeed;
  43927. private _tmpQuaternion;
  43928. private _tmpVector;
  43929. private _tmpRotationMatrix;
  43930. /**
  43931. * 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)
  43932. */
  43933. ignoreChildren: boolean;
  43934. /**
  43935. * 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)
  43936. */
  43937. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43938. /**
  43939. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43940. */
  43941. rotationSphereSize: number;
  43942. /**
  43943. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43944. */
  43945. scaleBoxSize: number;
  43946. /**
  43947. * 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)
  43948. */
  43949. fixedDragMeshScreenSize: boolean;
  43950. /**
  43951. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43952. */
  43953. fixedDragMeshScreenSizeDistanceFactor: number;
  43954. /**
  43955. * Fired when a rotation sphere or scale box is dragged
  43956. */
  43957. onDragStartObservable: Observable<{}>;
  43958. /**
  43959. * Fired when a scale box is dragged
  43960. */
  43961. onScaleBoxDragObservable: Observable<{}>;
  43962. /**
  43963. * Fired when a scale box drag is ended
  43964. */
  43965. onScaleBoxDragEndObservable: Observable<{}>;
  43966. /**
  43967. * Fired when a rotation sphere is dragged
  43968. */
  43969. onRotationSphereDragObservable: Observable<{}>;
  43970. /**
  43971. * Fired when a rotation sphere drag is ended
  43972. */
  43973. onRotationSphereDragEndObservable: Observable<{}>;
  43974. /**
  43975. * 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)
  43976. */
  43977. scalePivot: Nullable<Vector3>;
  43978. /**
  43979. * Mesh used as a pivot to rotate the attached mesh
  43980. */
  43981. private _anchorMesh;
  43982. private _existingMeshScale;
  43983. private _dragMesh;
  43984. private pointerDragBehavior;
  43985. private coloredMaterial;
  43986. private hoverColoredMaterial;
  43987. /**
  43988. * Sets the color of the bounding box gizmo
  43989. * @param color the color to set
  43990. */
  43991. setColor(color: Color3): void;
  43992. /**
  43993. * Creates an BoundingBoxGizmo
  43994. * @param gizmoLayer The utility layer the gizmo will be added to
  43995. * @param color The color of the gizmo
  43996. */
  43997. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43998. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43999. private _selectNode;
  44000. /**
  44001. * Updates the bounding box information for the Gizmo
  44002. */
  44003. updateBoundingBox(): void;
  44004. private _updateRotationSpheres;
  44005. private _updateScaleBoxes;
  44006. /**
  44007. * Enables rotation on the specified axis and disables rotation on the others
  44008. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44009. */
  44010. setEnabledRotationAxis(axis: string): void;
  44011. /**
  44012. * Enables/disables scaling
  44013. * @param enable if scaling should be enabled
  44014. */
  44015. setEnabledScaling(enable: boolean): void;
  44016. private _updateDummy;
  44017. /**
  44018. * Enables a pointer drag behavior on the bounding box of the gizmo
  44019. */
  44020. enableDragBehavior(): void;
  44021. /**
  44022. * Disposes of the gizmo
  44023. */
  44024. dispose(): void;
  44025. /**
  44026. * 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)
  44027. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44028. * @returns the bounding box mesh with the passed in mesh as a child
  44029. */
  44030. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44031. /**
  44032. * CustomMeshes are not supported by this gizmo
  44033. * @param mesh The mesh to replace the default mesh of the gizmo
  44034. */
  44035. setCustomMesh(mesh: Mesh): void;
  44036. }
  44037. }
  44038. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44039. import { Observable } from "babylonjs/Misc/observable";
  44040. import { Nullable } from "babylonjs/types";
  44041. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44043. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44044. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44045. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44046. import "babylonjs/Meshes/Builders/linesBuilder";
  44047. /**
  44048. * Single plane rotation gizmo
  44049. */
  44050. export class PlaneRotationGizmo extends Gizmo {
  44051. /**
  44052. * Drag behavior responsible for the gizmos dragging interactions
  44053. */
  44054. dragBehavior: PointerDragBehavior;
  44055. private _pointerObserver;
  44056. /**
  44057. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44058. */
  44059. snapDistance: number;
  44060. /**
  44061. * Event that fires each time the gizmo snaps to a new location.
  44062. * * snapDistance is the the change in distance
  44063. */
  44064. onSnapObservable: Observable<{
  44065. snapDistance: number;
  44066. }>;
  44067. /**
  44068. * Creates a PlaneRotationGizmo
  44069. * @param gizmoLayer The utility layer the gizmo will be added to
  44070. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44071. * @param color The color of the gizmo
  44072. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44073. */
  44074. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44075. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44076. /**
  44077. * Disposes of the gizmo
  44078. */
  44079. dispose(): void;
  44080. }
  44081. }
  44082. declare module "babylonjs/Gizmos/rotationGizmo" {
  44083. import { Observable } from "babylonjs/Misc/observable";
  44084. import { Nullable } from "babylonjs/types";
  44085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44086. import { Mesh } from "babylonjs/Meshes/mesh";
  44087. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44088. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44089. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44090. /**
  44091. * Gizmo that enables rotating a mesh along 3 axis
  44092. */
  44093. export class RotationGizmo extends Gizmo {
  44094. /**
  44095. * Internal gizmo used for interactions on the x axis
  44096. */
  44097. xGizmo: PlaneRotationGizmo;
  44098. /**
  44099. * Internal gizmo used for interactions on the y axis
  44100. */
  44101. yGizmo: PlaneRotationGizmo;
  44102. /**
  44103. * Internal gizmo used for interactions on the z axis
  44104. */
  44105. zGizmo: PlaneRotationGizmo;
  44106. /** Fires an event when any of it's sub gizmos are dragged */
  44107. onDragStartObservable: Observable<{}>;
  44108. /** Fires an event when any of it's sub gizmos are released from dragging */
  44109. onDragEndObservable: Observable<{}>;
  44110. attachedMesh: Nullable<AbstractMesh>;
  44111. /**
  44112. * Creates a RotationGizmo
  44113. * @param gizmoLayer The utility layer the gizmo will be added to
  44114. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44115. */
  44116. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44117. updateGizmoRotationToMatchAttachedMesh: boolean;
  44118. /**
  44119. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44120. */
  44121. snapDistance: number;
  44122. /**
  44123. * Ratio for the scale of the gizmo (Default: 1)
  44124. */
  44125. scaleRatio: number;
  44126. /**
  44127. * Disposes of the gizmo
  44128. */
  44129. dispose(): void;
  44130. /**
  44131. * CustomMeshes are not supported by this gizmo
  44132. * @param mesh The mesh to replace the default mesh of the gizmo
  44133. */
  44134. setCustomMesh(mesh: Mesh): void;
  44135. }
  44136. }
  44137. declare module "babylonjs/Gizmos/positionGizmo" {
  44138. import { Observable } from "babylonjs/Misc/observable";
  44139. import { Nullable } from "babylonjs/types";
  44140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44141. import { Mesh } from "babylonjs/Meshes/mesh";
  44142. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44143. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44144. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44145. /**
  44146. * Gizmo that enables dragging a mesh along 3 axis
  44147. */
  44148. export class PositionGizmo extends Gizmo {
  44149. /**
  44150. * Internal gizmo used for interactions on the x axis
  44151. */
  44152. xGizmo: AxisDragGizmo;
  44153. /**
  44154. * Internal gizmo used for interactions on the y axis
  44155. */
  44156. yGizmo: AxisDragGizmo;
  44157. /**
  44158. * Internal gizmo used for interactions on the z axis
  44159. */
  44160. zGizmo: AxisDragGizmo;
  44161. /** Fires an event when any of it's sub gizmos are dragged */
  44162. onDragStartObservable: Observable<{}>;
  44163. /** Fires an event when any of it's sub gizmos are released from dragging */
  44164. onDragEndObservable: Observable<{}>;
  44165. attachedMesh: Nullable<AbstractMesh>;
  44166. /**
  44167. * Creates a PositionGizmo
  44168. * @param gizmoLayer The utility layer the gizmo will be added to
  44169. */
  44170. constructor(gizmoLayer?: UtilityLayerRenderer);
  44171. updateGizmoRotationToMatchAttachedMesh: boolean;
  44172. /**
  44173. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44174. */
  44175. snapDistance: number;
  44176. /**
  44177. * Ratio for the scale of the gizmo (Default: 1)
  44178. */
  44179. scaleRatio: number;
  44180. /**
  44181. * Disposes of the gizmo
  44182. */
  44183. dispose(): void;
  44184. /**
  44185. * CustomMeshes are not supported by this gizmo
  44186. * @param mesh The mesh to replace the default mesh of the gizmo
  44187. */
  44188. setCustomMesh(mesh: Mesh): void;
  44189. }
  44190. }
  44191. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44192. import { Scene } from "babylonjs/scene";
  44193. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44194. import { Mesh } from "babylonjs/Meshes/mesh";
  44195. import { Nullable } from "babylonjs/types";
  44196. /**
  44197. * Class containing static functions to help procedurally build meshes
  44198. */
  44199. export class PolyhedronBuilder {
  44200. /**
  44201. * Creates a polyhedron mesh
  44202. * * 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
  44203. * * The parameter `size` (positive float, default 1) sets the polygon size
  44204. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44205. * * 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`
  44206. * * 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
  44207. * * 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)`)
  44208. * * 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
  44209. * * 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
  44210. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44211. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44213. * @param name defines the name of the mesh
  44214. * @param options defines the options used to create the mesh
  44215. * @param scene defines the hosting scene
  44216. * @returns the polyhedron mesh
  44217. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44218. */
  44219. static CreatePolyhedron(name: string, options: {
  44220. type?: number;
  44221. size?: number;
  44222. sizeX?: number;
  44223. sizeY?: number;
  44224. sizeZ?: number;
  44225. custom?: any;
  44226. faceUV?: Vector4[];
  44227. faceColors?: Color4[];
  44228. flat?: boolean;
  44229. updatable?: boolean;
  44230. sideOrientation?: number;
  44231. frontUVs?: Vector4;
  44232. backUVs?: Vector4;
  44233. }, scene?: Nullable<Scene>): Mesh;
  44234. }
  44235. }
  44236. declare module "babylonjs/Gizmos/scaleGizmo" {
  44237. import { Observable } from "babylonjs/Misc/observable";
  44238. import { Nullable } from "babylonjs/types";
  44239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44240. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44241. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44242. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44243. /**
  44244. * Gizmo that enables scaling a mesh along 3 axis
  44245. */
  44246. export class ScaleGizmo extends Gizmo {
  44247. /**
  44248. * Internal gizmo used for interactions on the x axis
  44249. */
  44250. xGizmo: AxisScaleGizmo;
  44251. /**
  44252. * Internal gizmo used for interactions on the y axis
  44253. */
  44254. yGizmo: AxisScaleGizmo;
  44255. /**
  44256. * Internal gizmo used for interactions on the z axis
  44257. */
  44258. zGizmo: AxisScaleGizmo;
  44259. /**
  44260. * Internal gizmo used to scale all axis equally
  44261. */
  44262. uniformScaleGizmo: AxisScaleGizmo;
  44263. /** Fires an event when any of it's sub gizmos are dragged */
  44264. onDragStartObservable: Observable<{}>;
  44265. /** Fires an event when any of it's sub gizmos are released from dragging */
  44266. onDragEndObservable: Observable<{}>;
  44267. attachedMesh: Nullable<AbstractMesh>;
  44268. /**
  44269. * Creates a ScaleGizmo
  44270. * @param gizmoLayer The utility layer the gizmo will be added to
  44271. */
  44272. constructor(gizmoLayer?: UtilityLayerRenderer);
  44273. updateGizmoRotationToMatchAttachedMesh: boolean;
  44274. /**
  44275. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44276. */
  44277. snapDistance: number;
  44278. /**
  44279. * Ratio for the scale of the gizmo (Default: 1)
  44280. */
  44281. scaleRatio: number;
  44282. /**
  44283. * Disposes of the gizmo
  44284. */
  44285. dispose(): void;
  44286. }
  44287. }
  44288. declare module "babylonjs/Gizmos/gizmoManager" {
  44289. import { Observable } from "babylonjs/Misc/observable";
  44290. import { Nullable } from "babylonjs/types";
  44291. import { Scene, IDisposable } from "babylonjs/scene";
  44292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44293. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44294. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44295. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44296. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44297. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44298. /**
  44299. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44300. */
  44301. export class GizmoManager implements IDisposable {
  44302. private scene;
  44303. /**
  44304. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44305. */
  44306. gizmos: {
  44307. positionGizmo: Nullable<PositionGizmo>;
  44308. rotationGizmo: Nullable<RotationGizmo>;
  44309. scaleGizmo: Nullable<ScaleGizmo>;
  44310. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44311. };
  44312. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44313. clearGizmoOnEmptyPointerEvent: boolean;
  44314. /** Fires an event when the manager is attached to a mesh */
  44315. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44316. private _gizmosEnabled;
  44317. private _pointerObserver;
  44318. private _attachedMesh;
  44319. private _boundingBoxColor;
  44320. private _defaultUtilityLayer;
  44321. private _defaultKeepDepthUtilityLayer;
  44322. /**
  44323. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44324. */
  44325. boundingBoxDragBehavior: SixDofDragBehavior;
  44326. /**
  44327. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44328. */
  44329. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44330. /**
  44331. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44332. */
  44333. usePointerToAttachGizmos: boolean;
  44334. /**
  44335. * Instatiates a gizmo manager
  44336. * @param scene the scene to overlay the gizmos on top of
  44337. */
  44338. constructor(scene: Scene);
  44339. /**
  44340. * Attaches a set of gizmos to the specified mesh
  44341. * @param mesh The mesh the gizmo's should be attached to
  44342. */
  44343. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44344. /**
  44345. * If the position gizmo is enabled
  44346. */
  44347. positionGizmoEnabled: boolean;
  44348. /**
  44349. * If the rotation gizmo is enabled
  44350. */
  44351. rotationGizmoEnabled: boolean;
  44352. /**
  44353. * If the scale gizmo is enabled
  44354. */
  44355. scaleGizmoEnabled: boolean;
  44356. /**
  44357. * If the boundingBox gizmo is enabled
  44358. */
  44359. boundingBoxGizmoEnabled: boolean;
  44360. /**
  44361. * Disposes of the gizmo manager
  44362. */
  44363. dispose(): void;
  44364. }
  44365. }
  44366. declare module "babylonjs/Lights/directionalLight" {
  44367. import { Camera } from "babylonjs/Cameras/camera";
  44368. import { Scene } from "babylonjs/scene";
  44369. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44371. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44372. import { Effect } from "babylonjs/Materials/effect";
  44373. /**
  44374. * A directional light is defined by a direction (what a surprise!).
  44375. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44376. * 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.
  44377. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44378. */
  44379. export class DirectionalLight extends ShadowLight {
  44380. private _shadowFrustumSize;
  44381. /**
  44382. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44383. */
  44384. /**
  44385. * Specifies a fix frustum size for the shadow generation.
  44386. */
  44387. shadowFrustumSize: number;
  44388. private _shadowOrthoScale;
  44389. /**
  44390. * Gets the shadow projection scale against the optimal computed one.
  44391. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44392. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44393. */
  44394. /**
  44395. * Sets the shadow projection scale against the optimal computed one.
  44396. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44397. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44398. */
  44399. shadowOrthoScale: number;
  44400. /**
  44401. * Automatically compute the projection matrix to best fit (including all the casters)
  44402. * on each frame.
  44403. */
  44404. autoUpdateExtends: boolean;
  44405. private _orthoLeft;
  44406. private _orthoRight;
  44407. private _orthoTop;
  44408. private _orthoBottom;
  44409. /**
  44410. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44411. * The directional light is emitted from everywhere in the given direction.
  44412. * It can cast shadows.
  44413. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44414. * @param name The friendly name of the light
  44415. * @param direction The direction of the light
  44416. * @param scene The scene the light belongs to
  44417. */
  44418. constructor(name: string, direction: Vector3, scene: Scene);
  44419. /**
  44420. * Returns the string "DirectionalLight".
  44421. * @return The class name
  44422. */
  44423. getClassName(): string;
  44424. /**
  44425. * Returns the integer 1.
  44426. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44427. */
  44428. getTypeID(): number;
  44429. /**
  44430. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44431. * Returns the DirectionalLight Shadow projection matrix.
  44432. */
  44433. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44434. /**
  44435. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44436. * Returns the DirectionalLight Shadow projection matrix.
  44437. */
  44438. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44439. /**
  44440. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44441. * Returns the DirectionalLight Shadow projection matrix.
  44442. */
  44443. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44444. protected _buildUniformLayout(): void;
  44445. /**
  44446. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44447. * @param effect The effect to update
  44448. * @param lightIndex The index of the light in the effect to update
  44449. * @returns The directional light
  44450. */
  44451. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44452. /**
  44453. * Gets the minZ used for shadow according to both the scene and the light.
  44454. *
  44455. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44456. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44457. * @param activeCamera The camera we are returning the min for
  44458. * @returns the depth min z
  44459. */
  44460. getDepthMinZ(activeCamera: Camera): number;
  44461. /**
  44462. * Gets the maxZ used for shadow according to both the scene and the light.
  44463. *
  44464. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44465. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44466. * @param activeCamera The camera we are returning the max for
  44467. * @returns the depth max z
  44468. */
  44469. getDepthMaxZ(activeCamera: Camera): number;
  44470. /**
  44471. * Prepares the list of defines specific to the light type.
  44472. * @param defines the list of defines
  44473. * @param lightIndex defines the index of the light for the effect
  44474. */
  44475. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44476. }
  44477. }
  44478. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44479. import { Mesh } from "babylonjs/Meshes/mesh";
  44480. /**
  44481. * Class containing static functions to help procedurally build meshes
  44482. */
  44483. export class HemisphereBuilder {
  44484. /**
  44485. * Creates a hemisphere mesh
  44486. * @param name defines the name of the mesh
  44487. * @param options defines the options used to create the mesh
  44488. * @param scene defines the hosting scene
  44489. * @returns the hemisphere mesh
  44490. */
  44491. static CreateHemisphere(name: string, options: {
  44492. segments?: number;
  44493. diameter?: number;
  44494. sideOrientation?: number;
  44495. }, scene: any): Mesh;
  44496. }
  44497. }
  44498. declare module "babylonjs/Lights/spotLight" {
  44499. import { Nullable } from "babylonjs/types";
  44500. import { Scene } from "babylonjs/scene";
  44501. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44503. import { Effect } from "babylonjs/Materials/effect";
  44504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44505. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44506. /**
  44507. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44508. * These values define a cone of light starting from the position, emitting toward the direction.
  44509. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44510. * and the exponent defines the speed of the decay of the light with distance (reach).
  44511. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44512. */
  44513. export class SpotLight extends ShadowLight {
  44514. private _angle;
  44515. private _innerAngle;
  44516. private _cosHalfAngle;
  44517. private _lightAngleScale;
  44518. private _lightAngleOffset;
  44519. /**
  44520. * Gets the cone angle of the spot light in Radians.
  44521. */
  44522. /**
  44523. * Sets the cone angle of the spot light in Radians.
  44524. */
  44525. angle: number;
  44526. /**
  44527. * Only used in gltf falloff mode, this defines the angle where
  44528. * the directional falloff will start before cutting at angle which could be seen
  44529. * as outer angle.
  44530. */
  44531. /**
  44532. * Only used in gltf falloff mode, this defines the angle where
  44533. * the directional falloff will start before cutting at angle which could be seen
  44534. * as outer angle.
  44535. */
  44536. innerAngle: number;
  44537. private _shadowAngleScale;
  44538. /**
  44539. * Allows scaling the angle of the light for shadow generation only.
  44540. */
  44541. /**
  44542. * Allows scaling the angle of the light for shadow generation only.
  44543. */
  44544. shadowAngleScale: number;
  44545. /**
  44546. * The light decay speed with the distance from the emission spot.
  44547. */
  44548. exponent: number;
  44549. private _projectionTextureMatrix;
  44550. /**
  44551. * Allows reading the projecton texture
  44552. */
  44553. readonly projectionTextureMatrix: Matrix;
  44554. protected _projectionTextureLightNear: number;
  44555. /**
  44556. * Gets the near clip of the Spotlight for texture projection.
  44557. */
  44558. /**
  44559. * Sets the near clip of the Spotlight for texture projection.
  44560. */
  44561. projectionTextureLightNear: number;
  44562. protected _projectionTextureLightFar: number;
  44563. /**
  44564. * Gets the far clip of the Spotlight for texture projection.
  44565. */
  44566. /**
  44567. * Sets the far clip of the Spotlight for texture projection.
  44568. */
  44569. projectionTextureLightFar: number;
  44570. protected _projectionTextureUpDirection: Vector3;
  44571. /**
  44572. * Gets the Up vector of the Spotlight for texture projection.
  44573. */
  44574. /**
  44575. * Sets the Up vector of the Spotlight for texture projection.
  44576. */
  44577. projectionTextureUpDirection: Vector3;
  44578. private _projectionTexture;
  44579. /**
  44580. * Gets the projection texture of the light.
  44581. */
  44582. /**
  44583. * Sets the projection texture of the light.
  44584. */
  44585. projectionTexture: Nullable<BaseTexture>;
  44586. private _projectionTextureViewLightDirty;
  44587. private _projectionTextureProjectionLightDirty;
  44588. private _projectionTextureDirty;
  44589. private _projectionTextureViewTargetVector;
  44590. private _projectionTextureViewLightMatrix;
  44591. private _projectionTextureProjectionLightMatrix;
  44592. private _projectionTextureScalingMatrix;
  44593. /**
  44594. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44595. * It can cast shadows.
  44596. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44597. * @param name The light friendly name
  44598. * @param position The position of the spot light in the scene
  44599. * @param direction The direction of the light in the scene
  44600. * @param angle The cone angle of the light in Radians
  44601. * @param exponent The light decay speed with the distance from the emission spot
  44602. * @param scene The scene the lights belongs to
  44603. */
  44604. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44605. /**
  44606. * Returns the string "SpotLight".
  44607. * @returns the class name
  44608. */
  44609. getClassName(): string;
  44610. /**
  44611. * Returns the integer 2.
  44612. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44613. */
  44614. getTypeID(): number;
  44615. /**
  44616. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44617. */
  44618. protected _setDirection(value: Vector3): void;
  44619. /**
  44620. * Overrides the position setter to recompute the projection texture view light Matrix.
  44621. */
  44622. protected _setPosition(value: Vector3): void;
  44623. /**
  44624. * 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.
  44625. * Returns the SpotLight.
  44626. */
  44627. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44628. protected _computeProjectionTextureViewLightMatrix(): void;
  44629. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44630. /**
  44631. * Main function for light texture projection matrix computing.
  44632. */
  44633. protected _computeProjectionTextureMatrix(): void;
  44634. protected _buildUniformLayout(): void;
  44635. private _computeAngleValues;
  44636. /**
  44637. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44638. * @param effect The effect to update
  44639. * @param lightIndex The index of the light in the effect to update
  44640. * @returns The spot light
  44641. */
  44642. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44643. /**
  44644. * Disposes the light and the associated resources.
  44645. */
  44646. dispose(): void;
  44647. /**
  44648. * Prepares the list of defines specific to the light type.
  44649. * @param defines the list of defines
  44650. * @param lightIndex defines the index of the light for the effect
  44651. */
  44652. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44653. }
  44654. }
  44655. declare module "babylonjs/Gizmos/lightGizmo" {
  44656. import { Nullable } from "babylonjs/types";
  44657. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44658. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44659. import { Light } from "babylonjs/Lights/light";
  44660. /**
  44661. * Gizmo that enables viewing a light
  44662. */
  44663. export class LightGizmo extends Gizmo {
  44664. private _lightMesh;
  44665. private _material;
  44666. /**
  44667. * Creates a LightGizmo
  44668. * @param gizmoLayer The utility layer the gizmo will be added to
  44669. */
  44670. constructor(gizmoLayer?: UtilityLayerRenderer);
  44671. private _light;
  44672. /**
  44673. * The light that the gizmo is attached to
  44674. */
  44675. light: Nullable<Light>;
  44676. /**
  44677. * @hidden
  44678. * Updates the gizmo to match the attached mesh's position/rotation
  44679. */
  44680. protected _update(): void;
  44681. private static _Scale;
  44682. /**
  44683. * Creates the lines for a light mesh
  44684. */
  44685. private static _createLightLines;
  44686. private static _CreateHemisphericLightMesh;
  44687. private static _CreatePointLightMesh;
  44688. private static _CreateSpotLightMesh;
  44689. private static _CreateDirectionalLightMesh;
  44690. }
  44691. }
  44692. declare module "babylonjs/Gizmos/index" {
  44693. export * from "babylonjs/Gizmos/axisDragGizmo";
  44694. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44695. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44696. export * from "babylonjs/Gizmos/gizmo";
  44697. export * from "babylonjs/Gizmos/gizmoManager";
  44698. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44699. export * from "babylonjs/Gizmos/positionGizmo";
  44700. export * from "babylonjs/Gizmos/rotationGizmo";
  44701. export * from "babylonjs/Gizmos/scaleGizmo";
  44702. export * from "babylonjs/Gizmos/lightGizmo";
  44703. }
  44704. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44705. /** @hidden */
  44706. export var backgroundFragmentDeclaration: {
  44707. name: string;
  44708. shader: string;
  44709. };
  44710. }
  44711. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44712. /** @hidden */
  44713. export var backgroundUboDeclaration: {
  44714. name: string;
  44715. shader: string;
  44716. };
  44717. }
  44718. declare module "babylonjs/Shaders/background.fragment" {
  44719. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44720. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44721. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44722. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44723. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44724. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44725. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44726. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44727. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44728. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44729. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44730. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44731. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44732. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44733. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44734. /** @hidden */
  44735. export var backgroundPixelShader: {
  44736. name: string;
  44737. shader: string;
  44738. };
  44739. }
  44740. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44741. /** @hidden */
  44742. export var backgroundVertexDeclaration: {
  44743. name: string;
  44744. shader: string;
  44745. };
  44746. }
  44747. declare module "babylonjs/Shaders/background.vertex" {
  44748. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44749. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44750. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44751. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44752. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44753. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44754. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44755. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44756. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44757. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44758. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44759. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44760. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44761. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44762. /** @hidden */
  44763. export var backgroundVertexShader: {
  44764. name: string;
  44765. shader: string;
  44766. };
  44767. }
  44768. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44769. import { Nullable, int, float } from "babylonjs/types";
  44770. import { Scene } from "babylonjs/scene";
  44771. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44772. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44774. import { Mesh } from "babylonjs/Meshes/mesh";
  44775. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44776. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44777. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44778. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44779. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44780. import "babylonjs/Shaders/background.fragment";
  44781. import "babylonjs/Shaders/background.vertex";
  44782. /**
  44783. * Background material used to create an efficient environement around your scene.
  44784. */
  44785. export class BackgroundMaterial extends PushMaterial {
  44786. /**
  44787. * Standard reflectance value at parallel view angle.
  44788. */
  44789. static StandardReflectance0: number;
  44790. /**
  44791. * Standard reflectance value at grazing angle.
  44792. */
  44793. static StandardReflectance90: number;
  44794. protected _primaryColor: Color3;
  44795. /**
  44796. * Key light Color (multiply against the environement texture)
  44797. */
  44798. primaryColor: Color3;
  44799. protected __perceptualColor: Nullable<Color3>;
  44800. /**
  44801. * Experimental Internal Use Only.
  44802. *
  44803. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44804. * This acts as a helper to set the primary color to a more "human friendly" value.
  44805. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44806. * output color as close as possible from the chosen value.
  44807. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44808. * part of lighting setup.)
  44809. */
  44810. _perceptualColor: Nullable<Color3>;
  44811. protected _primaryColorShadowLevel: float;
  44812. /**
  44813. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44814. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44815. */
  44816. primaryColorShadowLevel: float;
  44817. protected _primaryColorHighlightLevel: float;
  44818. /**
  44819. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44820. * The primary color is used at the level chosen to define what the white area would look.
  44821. */
  44822. primaryColorHighlightLevel: float;
  44823. protected _reflectionTexture: Nullable<BaseTexture>;
  44824. /**
  44825. * Reflection Texture used in the material.
  44826. * Should be author in a specific way for the best result (refer to the documentation).
  44827. */
  44828. reflectionTexture: Nullable<BaseTexture>;
  44829. protected _reflectionBlur: float;
  44830. /**
  44831. * Reflection Texture level of blur.
  44832. *
  44833. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44834. * texture twice.
  44835. */
  44836. reflectionBlur: float;
  44837. protected _diffuseTexture: Nullable<BaseTexture>;
  44838. /**
  44839. * Diffuse Texture used in the material.
  44840. * Should be author in a specific way for the best result (refer to the documentation).
  44841. */
  44842. diffuseTexture: Nullable<BaseTexture>;
  44843. protected _shadowLights: Nullable<IShadowLight[]>;
  44844. /**
  44845. * Specify the list of lights casting shadow on the material.
  44846. * All scene shadow lights will be included if null.
  44847. */
  44848. shadowLights: Nullable<IShadowLight[]>;
  44849. protected _shadowLevel: float;
  44850. /**
  44851. * Helps adjusting the shadow to a softer level if required.
  44852. * 0 means black shadows and 1 means no shadows.
  44853. */
  44854. shadowLevel: float;
  44855. protected _sceneCenter: Vector3;
  44856. /**
  44857. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44858. * It is usually zero but might be interesting to modify according to your setup.
  44859. */
  44860. sceneCenter: Vector3;
  44861. protected _opacityFresnel: boolean;
  44862. /**
  44863. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44864. * This helps ensuring a nice transition when the camera goes under the ground.
  44865. */
  44866. opacityFresnel: boolean;
  44867. protected _reflectionFresnel: boolean;
  44868. /**
  44869. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44870. * This helps adding a mirror texture on the ground.
  44871. */
  44872. reflectionFresnel: boolean;
  44873. protected _reflectionFalloffDistance: number;
  44874. /**
  44875. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44876. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44877. */
  44878. reflectionFalloffDistance: number;
  44879. protected _reflectionAmount: number;
  44880. /**
  44881. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44882. */
  44883. reflectionAmount: number;
  44884. protected _reflectionReflectance0: number;
  44885. /**
  44886. * This specifies the weight of the reflection at grazing angle.
  44887. */
  44888. reflectionReflectance0: number;
  44889. protected _reflectionReflectance90: number;
  44890. /**
  44891. * This specifies the weight of the reflection at a perpendicular point of view.
  44892. */
  44893. reflectionReflectance90: number;
  44894. /**
  44895. * Sets the reflection reflectance fresnel values according to the default standard
  44896. * empirically know to work well :-)
  44897. */
  44898. reflectionStandardFresnelWeight: number;
  44899. protected _useRGBColor: boolean;
  44900. /**
  44901. * Helps to directly use the maps channels instead of their level.
  44902. */
  44903. useRGBColor: boolean;
  44904. protected _enableNoise: boolean;
  44905. /**
  44906. * This helps reducing the banding effect that could occur on the background.
  44907. */
  44908. enableNoise: boolean;
  44909. /**
  44910. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44911. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44912. * Recommended to be keep at 1.0 except for special cases.
  44913. */
  44914. fovMultiplier: number;
  44915. private _fovMultiplier;
  44916. /**
  44917. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44918. */
  44919. useEquirectangularFOV: boolean;
  44920. private _maxSimultaneousLights;
  44921. /**
  44922. * Number of Simultaneous lights allowed on the material.
  44923. */
  44924. maxSimultaneousLights: int;
  44925. /**
  44926. * Default configuration related to image processing available in the Background Material.
  44927. */
  44928. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44929. /**
  44930. * Keep track of the image processing observer to allow dispose and replace.
  44931. */
  44932. private _imageProcessingObserver;
  44933. /**
  44934. * Attaches a new image processing configuration to the PBR Material.
  44935. * @param configuration (if null the scene configuration will be use)
  44936. */
  44937. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44938. /**
  44939. * Gets the image processing configuration used either in this material.
  44940. */
  44941. /**
  44942. * Sets the Default image processing configuration used either in the this material.
  44943. *
  44944. * If sets to null, the scene one is in use.
  44945. */
  44946. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44947. /**
  44948. * Gets wether the color curves effect is enabled.
  44949. */
  44950. /**
  44951. * Sets wether the color curves effect is enabled.
  44952. */
  44953. cameraColorCurvesEnabled: boolean;
  44954. /**
  44955. * Gets wether the color grading effect is enabled.
  44956. */
  44957. /**
  44958. * Gets wether the color grading effect is enabled.
  44959. */
  44960. cameraColorGradingEnabled: boolean;
  44961. /**
  44962. * Gets wether tonemapping is enabled or not.
  44963. */
  44964. /**
  44965. * Sets wether tonemapping is enabled or not
  44966. */
  44967. cameraToneMappingEnabled: boolean;
  44968. /**
  44969. * The camera exposure used on this material.
  44970. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44971. * This corresponds to a photographic exposure.
  44972. */
  44973. /**
  44974. * The camera exposure used on this material.
  44975. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44976. * This corresponds to a photographic exposure.
  44977. */
  44978. cameraExposure: float;
  44979. /**
  44980. * Gets The camera contrast used on this material.
  44981. */
  44982. /**
  44983. * Sets The camera contrast used on this material.
  44984. */
  44985. cameraContrast: float;
  44986. /**
  44987. * Gets the Color Grading 2D Lookup Texture.
  44988. */
  44989. /**
  44990. * Sets the Color Grading 2D Lookup Texture.
  44991. */
  44992. cameraColorGradingTexture: Nullable<BaseTexture>;
  44993. /**
  44994. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44995. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44996. * 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;
  44997. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44998. */
  44999. /**
  45000. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45001. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45002. * 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;
  45003. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45004. */
  45005. cameraColorCurves: Nullable<ColorCurves>;
  45006. /**
  45007. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45008. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45009. */
  45010. switchToBGR: boolean;
  45011. private _renderTargets;
  45012. private _reflectionControls;
  45013. private _white;
  45014. private _primaryShadowColor;
  45015. private _primaryHighlightColor;
  45016. /**
  45017. * Instantiates a Background Material in the given scene
  45018. * @param name The friendly name of the material
  45019. * @param scene The scene to add the material to
  45020. */
  45021. constructor(name: string, scene: Scene);
  45022. /**
  45023. * Gets a boolean indicating that current material needs to register RTT
  45024. */
  45025. readonly hasRenderTargetTextures: boolean;
  45026. /**
  45027. * The entire material has been created in order to prevent overdraw.
  45028. * @returns false
  45029. */
  45030. needAlphaTesting(): boolean;
  45031. /**
  45032. * The entire material has been created in order to prevent overdraw.
  45033. * @returns true if blending is enable
  45034. */
  45035. needAlphaBlending(): boolean;
  45036. /**
  45037. * Checks wether the material is ready to be rendered for a given mesh.
  45038. * @param mesh The mesh to render
  45039. * @param subMesh The submesh to check against
  45040. * @param useInstances Specify wether or not the material is used with instances
  45041. * @returns true if all the dependencies are ready (Textures, Effects...)
  45042. */
  45043. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45044. /**
  45045. * Compute the primary color according to the chosen perceptual color.
  45046. */
  45047. private _computePrimaryColorFromPerceptualColor;
  45048. /**
  45049. * Compute the highlights and shadow colors according to their chosen levels.
  45050. */
  45051. private _computePrimaryColors;
  45052. /**
  45053. * Build the uniform buffer used in the material.
  45054. */
  45055. buildUniformLayout(): void;
  45056. /**
  45057. * Unbind the material.
  45058. */
  45059. unbind(): void;
  45060. /**
  45061. * Bind only the world matrix to the material.
  45062. * @param world The world matrix to bind.
  45063. */
  45064. bindOnlyWorldMatrix(world: Matrix): void;
  45065. /**
  45066. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45067. * @param world The world matrix to bind.
  45068. * @param subMesh The submesh to bind for.
  45069. */
  45070. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45071. /**
  45072. * Dispose the material.
  45073. * @param forceDisposeEffect Force disposal of the associated effect.
  45074. * @param forceDisposeTextures Force disposal of the associated textures.
  45075. */
  45076. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45077. /**
  45078. * Clones the material.
  45079. * @param name The cloned name.
  45080. * @returns The cloned material.
  45081. */
  45082. clone(name: string): BackgroundMaterial;
  45083. /**
  45084. * Serializes the current material to its JSON representation.
  45085. * @returns The JSON representation.
  45086. */
  45087. serialize(): any;
  45088. /**
  45089. * Gets the class name of the material
  45090. * @returns "BackgroundMaterial"
  45091. */
  45092. getClassName(): string;
  45093. /**
  45094. * Parse a JSON input to create back a background material.
  45095. * @param source The JSON data to parse
  45096. * @param scene The scene to create the parsed material in
  45097. * @param rootUrl The root url of the assets the material depends upon
  45098. * @returns the instantiated BackgroundMaterial.
  45099. */
  45100. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45101. }
  45102. }
  45103. declare module "babylonjs/Helpers/environmentHelper" {
  45104. import { Observable } from "babylonjs/Misc/observable";
  45105. import { Nullable } from "babylonjs/types";
  45106. import { Scene } from "babylonjs/scene";
  45107. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45109. import { Mesh } from "babylonjs/Meshes/mesh";
  45110. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45111. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45112. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45113. import "babylonjs/Meshes/Builders/planeBuilder";
  45114. import "babylonjs/Meshes/Builders/boxBuilder";
  45115. /**
  45116. * Represents the different options available during the creation of
  45117. * a Environment helper.
  45118. *
  45119. * This can control the default ground, skybox and image processing setup of your scene.
  45120. */
  45121. export interface IEnvironmentHelperOptions {
  45122. /**
  45123. * Specifies wether or not to create a ground.
  45124. * True by default.
  45125. */
  45126. createGround: boolean;
  45127. /**
  45128. * Specifies the ground size.
  45129. * 15 by default.
  45130. */
  45131. groundSize: number;
  45132. /**
  45133. * The texture used on the ground for the main color.
  45134. * Comes from the BabylonJS CDN by default.
  45135. *
  45136. * Remarks: Can be either a texture or a url.
  45137. */
  45138. groundTexture: string | BaseTexture;
  45139. /**
  45140. * The color mixed in the ground texture by default.
  45141. * BabylonJS clearColor by default.
  45142. */
  45143. groundColor: Color3;
  45144. /**
  45145. * Specifies the ground opacity.
  45146. * 1 by default.
  45147. */
  45148. groundOpacity: number;
  45149. /**
  45150. * Enables the ground to receive shadows.
  45151. * True by default.
  45152. */
  45153. enableGroundShadow: boolean;
  45154. /**
  45155. * Helps preventing the shadow to be fully black on the ground.
  45156. * 0.5 by default.
  45157. */
  45158. groundShadowLevel: number;
  45159. /**
  45160. * Creates a mirror texture attach to the ground.
  45161. * false by default.
  45162. */
  45163. enableGroundMirror: boolean;
  45164. /**
  45165. * Specifies the ground mirror size ratio.
  45166. * 0.3 by default as the default kernel is 64.
  45167. */
  45168. groundMirrorSizeRatio: number;
  45169. /**
  45170. * Specifies the ground mirror blur kernel size.
  45171. * 64 by default.
  45172. */
  45173. groundMirrorBlurKernel: number;
  45174. /**
  45175. * Specifies the ground mirror visibility amount.
  45176. * 1 by default
  45177. */
  45178. groundMirrorAmount: number;
  45179. /**
  45180. * Specifies the ground mirror reflectance weight.
  45181. * This uses the standard weight of the background material to setup the fresnel effect
  45182. * of the mirror.
  45183. * 1 by default.
  45184. */
  45185. groundMirrorFresnelWeight: number;
  45186. /**
  45187. * Specifies the ground mirror Falloff distance.
  45188. * This can helps reducing the size of the reflection.
  45189. * 0 by Default.
  45190. */
  45191. groundMirrorFallOffDistance: number;
  45192. /**
  45193. * Specifies the ground mirror texture type.
  45194. * Unsigned Int by Default.
  45195. */
  45196. groundMirrorTextureType: number;
  45197. /**
  45198. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45199. * the shown objects.
  45200. */
  45201. groundYBias: number;
  45202. /**
  45203. * Specifies wether or not to create a skybox.
  45204. * True by default.
  45205. */
  45206. createSkybox: boolean;
  45207. /**
  45208. * Specifies the skybox size.
  45209. * 20 by default.
  45210. */
  45211. skyboxSize: number;
  45212. /**
  45213. * The texture used on the skybox for the main color.
  45214. * Comes from the BabylonJS CDN by default.
  45215. *
  45216. * Remarks: Can be either a texture or a url.
  45217. */
  45218. skyboxTexture: string | BaseTexture;
  45219. /**
  45220. * The color mixed in the skybox texture by default.
  45221. * BabylonJS clearColor by default.
  45222. */
  45223. skyboxColor: Color3;
  45224. /**
  45225. * The background rotation around the Y axis of the scene.
  45226. * This helps aligning the key lights of your scene with the background.
  45227. * 0 by default.
  45228. */
  45229. backgroundYRotation: number;
  45230. /**
  45231. * Compute automatically the size of the elements to best fit with the scene.
  45232. */
  45233. sizeAuto: boolean;
  45234. /**
  45235. * Default position of the rootMesh if autoSize is not true.
  45236. */
  45237. rootPosition: Vector3;
  45238. /**
  45239. * Sets up the image processing in the scene.
  45240. * true by default.
  45241. */
  45242. setupImageProcessing: boolean;
  45243. /**
  45244. * The texture used as your environment texture in the scene.
  45245. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45246. *
  45247. * Remarks: Can be either a texture or a url.
  45248. */
  45249. environmentTexture: string | BaseTexture;
  45250. /**
  45251. * The value of the exposure to apply to the scene.
  45252. * 0.6 by default if setupImageProcessing is true.
  45253. */
  45254. cameraExposure: number;
  45255. /**
  45256. * The value of the contrast to apply to the scene.
  45257. * 1.6 by default if setupImageProcessing is true.
  45258. */
  45259. cameraContrast: number;
  45260. /**
  45261. * Specifies wether or not tonemapping should be enabled in the scene.
  45262. * true by default if setupImageProcessing is true.
  45263. */
  45264. toneMappingEnabled: boolean;
  45265. }
  45266. /**
  45267. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45268. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45269. * It also helps with the default setup of your imageProcessing configuration.
  45270. */
  45271. export class EnvironmentHelper {
  45272. /**
  45273. * Default ground texture URL.
  45274. */
  45275. private static _groundTextureCDNUrl;
  45276. /**
  45277. * Default skybox texture URL.
  45278. */
  45279. private static _skyboxTextureCDNUrl;
  45280. /**
  45281. * Default environment texture URL.
  45282. */
  45283. private static _environmentTextureCDNUrl;
  45284. /**
  45285. * Creates the default options for the helper.
  45286. */
  45287. private static _getDefaultOptions;
  45288. private _rootMesh;
  45289. /**
  45290. * Gets the root mesh created by the helper.
  45291. */
  45292. readonly rootMesh: Mesh;
  45293. private _skybox;
  45294. /**
  45295. * Gets the skybox created by the helper.
  45296. */
  45297. readonly skybox: Nullable<Mesh>;
  45298. private _skyboxTexture;
  45299. /**
  45300. * Gets the skybox texture created by the helper.
  45301. */
  45302. readonly skyboxTexture: Nullable<BaseTexture>;
  45303. private _skyboxMaterial;
  45304. /**
  45305. * Gets the skybox material created by the helper.
  45306. */
  45307. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45308. private _ground;
  45309. /**
  45310. * Gets the ground mesh created by the helper.
  45311. */
  45312. readonly ground: Nullable<Mesh>;
  45313. private _groundTexture;
  45314. /**
  45315. * Gets the ground texture created by the helper.
  45316. */
  45317. readonly groundTexture: Nullable<BaseTexture>;
  45318. private _groundMirror;
  45319. /**
  45320. * Gets the ground mirror created by the helper.
  45321. */
  45322. readonly groundMirror: Nullable<MirrorTexture>;
  45323. /**
  45324. * Gets the ground mirror render list to helps pushing the meshes
  45325. * you wish in the ground reflection.
  45326. */
  45327. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45328. private _groundMaterial;
  45329. /**
  45330. * Gets the ground material created by the helper.
  45331. */
  45332. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45333. /**
  45334. * Stores the creation options.
  45335. */
  45336. private readonly _scene;
  45337. private _options;
  45338. /**
  45339. * This observable will be notified with any error during the creation of the environment,
  45340. * mainly texture creation errors.
  45341. */
  45342. onErrorObservable: Observable<{
  45343. message?: string;
  45344. exception?: any;
  45345. }>;
  45346. /**
  45347. * constructor
  45348. * @param options Defines the options we want to customize the helper
  45349. * @param scene The scene to add the material to
  45350. */
  45351. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45352. /**
  45353. * Updates the background according to the new options
  45354. * @param options
  45355. */
  45356. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45357. /**
  45358. * Sets the primary color of all the available elements.
  45359. * @param color the main color to affect to the ground and the background
  45360. */
  45361. setMainColor(color: Color3): void;
  45362. /**
  45363. * Setup the image processing according to the specified options.
  45364. */
  45365. private _setupImageProcessing;
  45366. /**
  45367. * Setup the environment texture according to the specified options.
  45368. */
  45369. private _setupEnvironmentTexture;
  45370. /**
  45371. * Setup the background according to the specified options.
  45372. */
  45373. private _setupBackground;
  45374. /**
  45375. * Get the scene sizes according to the setup.
  45376. */
  45377. private _getSceneSize;
  45378. /**
  45379. * Setup the ground according to the specified options.
  45380. */
  45381. private _setupGround;
  45382. /**
  45383. * Setup the ground material according to the specified options.
  45384. */
  45385. private _setupGroundMaterial;
  45386. /**
  45387. * Setup the ground diffuse texture according to the specified options.
  45388. */
  45389. private _setupGroundDiffuseTexture;
  45390. /**
  45391. * Setup the ground mirror texture according to the specified options.
  45392. */
  45393. private _setupGroundMirrorTexture;
  45394. /**
  45395. * Setup the ground to receive the mirror texture.
  45396. */
  45397. private _setupMirrorInGroundMaterial;
  45398. /**
  45399. * Setup the skybox according to the specified options.
  45400. */
  45401. private _setupSkybox;
  45402. /**
  45403. * Setup the skybox material according to the specified options.
  45404. */
  45405. private _setupSkyboxMaterial;
  45406. /**
  45407. * Setup the skybox reflection texture according to the specified options.
  45408. */
  45409. private _setupSkyboxReflectionTexture;
  45410. private _errorHandler;
  45411. /**
  45412. * Dispose all the elements created by the Helper.
  45413. */
  45414. dispose(): void;
  45415. }
  45416. }
  45417. declare module "babylonjs/Helpers/photoDome" {
  45418. import { Observable } from "babylonjs/Misc/observable";
  45419. import { Nullable } from "babylonjs/types";
  45420. import { Scene } from "babylonjs/scene";
  45421. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45422. import { Mesh } from "babylonjs/Meshes/mesh";
  45423. import { Texture } from "babylonjs/Materials/Textures/texture";
  45424. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45425. import "babylonjs/Meshes/Builders/sphereBuilder";
  45426. /**
  45427. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45428. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45429. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45430. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45431. */
  45432. export class PhotoDome extends TransformNode {
  45433. private _useDirectMapping;
  45434. /**
  45435. * The texture being displayed on the sphere
  45436. */
  45437. protected _photoTexture: Texture;
  45438. /**
  45439. * Gets or sets the texture being displayed on the sphere
  45440. */
  45441. photoTexture: Texture;
  45442. /**
  45443. * Observable raised when an error occured while loading the 360 image
  45444. */
  45445. onLoadErrorObservable: Observable<string>;
  45446. /**
  45447. * The skybox material
  45448. */
  45449. protected _material: BackgroundMaterial;
  45450. /**
  45451. * The surface used for the skybox
  45452. */
  45453. protected _mesh: Mesh;
  45454. /**
  45455. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45456. * Also see the options.resolution property.
  45457. */
  45458. fovMultiplier: number;
  45459. /**
  45460. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45461. * @param name Element's name, child elements will append suffixes for their own names.
  45462. * @param urlsOfPhoto defines the url of the photo to display
  45463. * @param options defines an object containing optional or exposed sub element properties
  45464. * @param onError defines a callback called when an error occured while loading the texture
  45465. */
  45466. constructor(name: string, urlOfPhoto: string, options: {
  45467. resolution?: number;
  45468. size?: number;
  45469. useDirectMapping?: boolean;
  45470. faceForward?: boolean;
  45471. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45472. /**
  45473. * Releases resources associated with this node.
  45474. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45475. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45476. */
  45477. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45478. }
  45479. }
  45480. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45481. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45482. /** @hidden */
  45483. export var rgbdDecodePixelShader: {
  45484. name: string;
  45485. shader: string;
  45486. };
  45487. }
  45488. declare module "babylonjs/Misc/brdfTextureTools" {
  45489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45490. import { Scene } from "babylonjs/scene";
  45491. import "babylonjs/Shaders/rgbdDecode.fragment";
  45492. /**
  45493. * Class used to host texture specific utilities
  45494. */
  45495. export class BRDFTextureTools {
  45496. /**
  45497. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45498. * @param texture the texture to expand.
  45499. */
  45500. private static _ExpandDefaultBRDFTexture;
  45501. /**
  45502. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45503. * @param scene defines the hosting scene
  45504. * @returns the environment BRDF texture
  45505. */
  45506. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45507. private static _environmentBRDFBase64Texture;
  45508. }
  45509. }
  45510. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45511. import { Nullable } from "babylonjs/types";
  45512. import { IAnimatable } from "babylonjs/Misc/tools";
  45513. import { Color3 } from "babylonjs/Maths/math";
  45514. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45515. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45516. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45517. import { Engine } from "babylonjs/Engines/engine";
  45518. import { Scene } from "babylonjs/scene";
  45519. /**
  45520. * @hidden
  45521. */
  45522. export interface IMaterialClearCoatDefines {
  45523. CLEARCOAT: boolean;
  45524. CLEARCOAT_DEFAULTIOR: boolean;
  45525. CLEARCOAT_TEXTURE: boolean;
  45526. CLEARCOAT_TEXTUREDIRECTUV: number;
  45527. CLEARCOAT_BUMP: boolean;
  45528. CLEARCOAT_BUMPDIRECTUV: number;
  45529. CLEARCOAT_TINT: boolean;
  45530. CLEARCOAT_TINT_TEXTURE: boolean;
  45531. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45532. /** @hidden */
  45533. _areTexturesDirty: boolean;
  45534. }
  45535. /**
  45536. * Define the code related to the clear coat parameters of the pbr material.
  45537. */
  45538. export class PBRClearCoatConfiguration {
  45539. /**
  45540. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45541. * The default fits with a polyurethane material.
  45542. */
  45543. private static readonly _DefaultIndiceOfRefraction;
  45544. private _isEnabled;
  45545. /**
  45546. * Defines if the clear coat is enabled in the material.
  45547. */
  45548. isEnabled: boolean;
  45549. /**
  45550. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45551. */
  45552. intensity: number;
  45553. /**
  45554. * Defines the clear coat layer roughness.
  45555. */
  45556. roughness: number;
  45557. private _indiceOfRefraction;
  45558. /**
  45559. * Defines the indice of refraction of the clear coat.
  45560. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45561. * The default fits with a polyurethane material.
  45562. * Changing the default value is more performance intensive.
  45563. */
  45564. indiceOfRefraction: number;
  45565. private _texture;
  45566. /**
  45567. * Stores the clear coat values in a texture.
  45568. */
  45569. texture: Nullable<BaseTexture>;
  45570. private _bumpTexture;
  45571. /**
  45572. * Define the clear coat specific bump texture.
  45573. */
  45574. bumpTexture: Nullable<BaseTexture>;
  45575. private _isTintEnabled;
  45576. /**
  45577. * Defines if the clear coat tint is enabled in the material.
  45578. */
  45579. isTintEnabled: boolean;
  45580. /**
  45581. * Defines the clear coat tint of the material.
  45582. * This is only use if tint is enabled
  45583. */
  45584. tintColor: Color3;
  45585. /**
  45586. * Defines the distance at which the tint color should be found in the
  45587. * clear coat media.
  45588. * This is only use if tint is enabled
  45589. */
  45590. tintColorAtDistance: number;
  45591. /**
  45592. * Defines the clear coat layer thickness.
  45593. * This is only use if tint is enabled
  45594. */
  45595. tintThickness: number;
  45596. private _tintTexture;
  45597. /**
  45598. * Stores the clear tint values in a texture.
  45599. * rgb is tint
  45600. * a is a thickness factor
  45601. */
  45602. tintTexture: Nullable<BaseTexture>;
  45603. /** @hidden */
  45604. private _internalMarkAllSubMeshesAsTexturesDirty;
  45605. /** @hidden */
  45606. _markAllSubMeshesAsTexturesDirty(): void;
  45607. /**
  45608. * Instantiate a new istance of clear coat configuration.
  45609. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45610. */
  45611. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45612. /**
  45613. * Gets wehter the submesh is ready to be used or not.
  45614. * @param defines the list of "defines" to update.
  45615. * @param scene defines the scene the material belongs to.
  45616. * @param engine defines the engine the material belongs to.
  45617. * @param disableBumpMap defines wether the material disables bump or not.
  45618. * @returns - boolean indicating that the submesh is ready or not.
  45619. */
  45620. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45621. /**
  45622. * Checks to see if a texture is used in the material.
  45623. * @param defines the list of "defines" to update.
  45624. * @param scene defines the scene to the material belongs to.
  45625. */
  45626. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45627. /**
  45628. * Binds the material data.
  45629. * @param uniformBuffer defines the Uniform buffer to fill in.
  45630. * @param scene defines the scene the material belongs to.
  45631. * @param engine defines the engine the material belongs to.
  45632. * @param disableBumpMap defines wether the material disables bump or not.
  45633. * @param isFrozen defines wether the material is frozen or not.
  45634. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45635. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45636. */
  45637. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45638. /**
  45639. * Checks to see if a texture is used in the material.
  45640. * @param texture - Base texture to use.
  45641. * @returns - Boolean specifying if a texture is used in the material.
  45642. */
  45643. hasTexture(texture: BaseTexture): boolean;
  45644. /**
  45645. * Returns an array of the actively used textures.
  45646. * @param activeTextures Array of BaseTextures
  45647. */
  45648. getActiveTextures(activeTextures: BaseTexture[]): void;
  45649. /**
  45650. * Returns the animatable textures.
  45651. * @param animatables Array of animatable textures.
  45652. */
  45653. getAnimatables(animatables: IAnimatable[]): void;
  45654. /**
  45655. * Disposes the resources of the material.
  45656. * @param forceDisposeTextures - Forces the disposal of all textures.
  45657. */
  45658. dispose(forceDisposeTextures?: boolean): void;
  45659. /**
  45660. * Get the current class name of the texture useful for serialization or dynamic coding.
  45661. * @returns "PBRClearCoatConfiguration"
  45662. */
  45663. getClassName(): string;
  45664. /**
  45665. * Add fallbacks to the effect fallbacks list.
  45666. * @param defines defines the Base texture to use.
  45667. * @param fallbacks defines the current fallback list.
  45668. * @param currentRank defines the current fallback rank.
  45669. * @returns the new fallback rank.
  45670. */
  45671. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45672. /**
  45673. * Add the required uniforms to the current list.
  45674. * @param uniforms defines the current uniform list.
  45675. */
  45676. static AddUniforms(uniforms: string[]): void;
  45677. /**
  45678. * Add the required samplers to the current list.
  45679. * @param samplers defines the current sampler list.
  45680. */
  45681. static AddSamplers(samplers: string[]): void;
  45682. /**
  45683. * Add the required uniforms to the current buffer.
  45684. * @param uniformBuffer defines the current uniform buffer.
  45685. */
  45686. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45687. /**
  45688. * Makes a duplicate of the current configuration into another one.
  45689. * @param clearCoatConfiguration define the config where to copy the info
  45690. */
  45691. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45692. /**
  45693. * Serializes this clear coat configuration.
  45694. * @returns - An object with the serialized config.
  45695. */
  45696. serialize(): any;
  45697. /**
  45698. * Parses a Clear Coat Configuration from a serialized object.
  45699. * @param source - Serialized object.
  45700. */
  45701. parse(source: any): void;
  45702. }
  45703. }
  45704. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45705. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45706. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45708. import { Vector2 } from "babylonjs/Maths/math";
  45709. import { Scene } from "babylonjs/scene";
  45710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45711. import { IAnimatable } from "babylonjs/Misc/tools";
  45712. import { Nullable } from "babylonjs/types";
  45713. /**
  45714. * @hidden
  45715. */
  45716. export interface IMaterialAnisotropicDefines {
  45717. ANISOTROPIC: boolean;
  45718. ANISOTROPIC_TEXTURE: boolean;
  45719. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45720. MAINUV1: boolean;
  45721. _areTexturesDirty: boolean;
  45722. _needUVs: boolean;
  45723. }
  45724. /**
  45725. * Define the code related to the anisotropic parameters of the pbr material.
  45726. */
  45727. export class PBRAnisotropicConfiguration {
  45728. private _isEnabled;
  45729. /**
  45730. * Defines if the anisotropy is enabled in the material.
  45731. */
  45732. isEnabled: boolean;
  45733. /**
  45734. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45735. */
  45736. intensity: number;
  45737. /**
  45738. * Defines if the effect is along the tangents, bitangents or in between.
  45739. * By default, the effect is "strectching" the highlights along the tangents.
  45740. */
  45741. direction: Vector2;
  45742. private _texture;
  45743. /**
  45744. * Stores the anisotropy values in a texture.
  45745. * rg is direction (like normal from -1 to 1)
  45746. * b is a intensity
  45747. */
  45748. texture: Nullable<BaseTexture>;
  45749. /** @hidden */
  45750. private _internalMarkAllSubMeshesAsTexturesDirty;
  45751. /** @hidden */
  45752. _markAllSubMeshesAsTexturesDirty(): void;
  45753. /**
  45754. * Instantiate a new istance of anisotropy configuration.
  45755. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45756. */
  45757. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45758. /**
  45759. * Specifies that the submesh is ready to be used.
  45760. * @param defines the list of "defines" to update.
  45761. * @param scene defines the scene the material belongs to.
  45762. * @returns - boolean indicating that the submesh is ready or not.
  45763. */
  45764. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45765. /**
  45766. * Checks to see if a texture is used in the material.
  45767. * @param defines the list of "defines" to update.
  45768. * @param mesh the mesh we are preparing the defines for.
  45769. * @param scene defines the scene the material belongs to.
  45770. */
  45771. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45772. /**
  45773. * Binds the material data.
  45774. * @param uniformBuffer defines the Uniform buffer to fill in.
  45775. * @param scene defines the scene the material belongs to.
  45776. * @param isFrozen defines wether the material is frozen or not.
  45777. */
  45778. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45779. /**
  45780. * Checks to see if a texture is used in the material.
  45781. * @param texture - Base texture to use.
  45782. * @returns - Boolean specifying if a texture is used in the material.
  45783. */
  45784. hasTexture(texture: BaseTexture): boolean;
  45785. /**
  45786. * Returns an array of the actively used textures.
  45787. * @param activeTextures Array of BaseTextures
  45788. */
  45789. getActiveTextures(activeTextures: BaseTexture[]): void;
  45790. /**
  45791. * Returns the animatable textures.
  45792. * @param animatables Array of animatable textures.
  45793. */
  45794. getAnimatables(animatables: IAnimatable[]): void;
  45795. /**
  45796. * Disposes the resources of the material.
  45797. * @param forceDisposeTextures - Forces the disposal of all textures.
  45798. */
  45799. dispose(forceDisposeTextures?: boolean): void;
  45800. /**
  45801. * Get the current class name of the texture useful for serialization or dynamic coding.
  45802. * @returns "PBRAnisotropicConfiguration"
  45803. */
  45804. getClassName(): string;
  45805. /**
  45806. * Add fallbacks to the effect fallbacks list.
  45807. * @param defines defines the Base texture to use.
  45808. * @param fallbacks defines the current fallback list.
  45809. * @param currentRank defines the current fallback rank.
  45810. * @returns the new fallback rank.
  45811. */
  45812. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45813. /**
  45814. * Add the required uniforms to the current list.
  45815. * @param uniforms defines the current uniform list.
  45816. */
  45817. static AddUniforms(uniforms: string[]): void;
  45818. /**
  45819. * Add the required uniforms to the current buffer.
  45820. * @param uniformBuffer defines the current uniform buffer.
  45821. */
  45822. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45823. /**
  45824. * Add the required samplers to the current list.
  45825. * @param samplers defines the current sampler list.
  45826. */
  45827. static AddSamplers(samplers: string[]): void;
  45828. /**
  45829. * Makes a duplicate of the current configuration into another one.
  45830. * @param anisotropicConfiguration define the config where to copy the info
  45831. */
  45832. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45833. /**
  45834. * Serializes this anisotropy configuration.
  45835. * @returns - An object with the serialized config.
  45836. */
  45837. serialize(): any;
  45838. /**
  45839. * Parses a anisotropy Configuration from a serialized object.
  45840. * @param source - Serialized object.
  45841. */
  45842. parse(source: any): void;
  45843. }
  45844. }
  45845. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45846. /**
  45847. * @hidden
  45848. */
  45849. export interface IMaterialBRDFDefines {
  45850. BRDF_V_HEIGHT_CORRELATED: boolean;
  45851. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45852. /** @hidden */
  45853. _areMiscDirty: boolean;
  45854. }
  45855. /**
  45856. * Define the code related to the BRDF parameters of the pbr material.
  45857. */
  45858. export class PBRBRDFConfiguration {
  45859. /**
  45860. * Default value used for the energy conservation.
  45861. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45862. */
  45863. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45864. /**
  45865. * Default value used for the Smith Visibility Height Correlated mode.
  45866. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45867. */
  45868. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45869. private _useEnergyConservation;
  45870. /**
  45871. * Defines if the material uses energy conservation.
  45872. */
  45873. useEnergyConservation: boolean;
  45874. private _useSmithVisibilityHeightCorrelated;
  45875. /**
  45876. * LEGACY Mode set to false
  45877. * Defines if the material uses height smith correlated visibility term.
  45878. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45879. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45880. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45881. * Not relying on height correlated will also disable energy conservation.
  45882. */
  45883. useSmithVisibilityHeightCorrelated: boolean;
  45884. /** @hidden */
  45885. private _internalMarkAllSubMeshesAsMiscDirty;
  45886. /** @hidden */
  45887. _markAllSubMeshesAsMiscDirty(): void;
  45888. /**
  45889. * Instantiate a new istance of clear coat configuration.
  45890. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45891. */
  45892. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45893. /**
  45894. * Checks to see if a texture is used in the material.
  45895. * @param defines the list of "defines" to update.
  45896. */
  45897. prepareDefines(defines: IMaterialBRDFDefines): void;
  45898. /**
  45899. * Get the current class name of the texture useful for serialization or dynamic coding.
  45900. * @returns "PBRClearCoatConfiguration"
  45901. */
  45902. getClassName(): string;
  45903. /**
  45904. * Makes a duplicate of the current configuration into another one.
  45905. * @param brdfConfiguration define the config where to copy the info
  45906. */
  45907. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45908. /**
  45909. * Serializes this BRDF configuration.
  45910. * @returns - An object with the serialized config.
  45911. */
  45912. serialize(): any;
  45913. /**
  45914. * Parses a BRDF Configuration from a serialized object.
  45915. * @param source - Serialized object.
  45916. */
  45917. parse(source: any): void;
  45918. }
  45919. }
  45920. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45921. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45922. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45923. import { Color3 } from "babylonjs/Maths/math";
  45924. import { Scene } from "babylonjs/scene";
  45925. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45926. import { IAnimatable } from "babylonjs/Misc/tools";
  45927. import { Nullable } from "babylonjs/types";
  45928. /**
  45929. * @hidden
  45930. */
  45931. export interface IMaterialSheenDefines {
  45932. SHEEN: boolean;
  45933. SHEEN_TEXTURE: boolean;
  45934. SHEEN_TEXTUREDIRECTUV: number;
  45935. SHEEN_LINKWITHALBEDO: boolean;
  45936. /** @hidden */
  45937. _areTexturesDirty: boolean;
  45938. }
  45939. /**
  45940. * Define the code related to the Sheen parameters of the pbr material.
  45941. */
  45942. export class PBRSheenConfiguration {
  45943. private _isEnabled;
  45944. /**
  45945. * Defines if the material uses sheen.
  45946. */
  45947. isEnabled: boolean;
  45948. private _linkSheenWithAlbedo;
  45949. /**
  45950. * Defines if the sheen is linked to the sheen color.
  45951. */
  45952. linkSheenWithAlbedo: boolean;
  45953. /**
  45954. * Defines the sheen intensity.
  45955. */
  45956. intensity: number;
  45957. /**
  45958. * Defines the sheen color.
  45959. */
  45960. color: Color3;
  45961. private _texture;
  45962. /**
  45963. * Stores the sheen tint values in a texture.
  45964. * rgb is tint
  45965. * a is a intensity
  45966. */
  45967. texture: Nullable<BaseTexture>;
  45968. /** @hidden */
  45969. private _internalMarkAllSubMeshesAsTexturesDirty;
  45970. /** @hidden */
  45971. _markAllSubMeshesAsTexturesDirty(): void;
  45972. /**
  45973. * Instantiate a new istance of clear coat configuration.
  45974. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45975. */
  45976. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45977. /**
  45978. * Specifies that the submesh is ready to be used.
  45979. * @param defines the list of "defines" to update.
  45980. * @param scene defines the scene the material belongs to.
  45981. * @returns - boolean indicating that the submesh is ready or not.
  45982. */
  45983. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45984. /**
  45985. * Checks to see if a texture is used in the material.
  45986. * @param defines the list of "defines" to update.
  45987. * @param scene defines the scene the material belongs to.
  45988. */
  45989. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45990. /**
  45991. * Binds the material data.
  45992. * @param uniformBuffer defines the Uniform buffer to fill in.
  45993. * @param scene defines the scene the material belongs to.
  45994. * @param isFrozen defines wether the material is frozen or not.
  45995. */
  45996. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45997. /**
  45998. * Checks to see if a texture is used in the material.
  45999. * @param texture - Base texture to use.
  46000. * @returns - Boolean specifying if a texture is used in the material.
  46001. */
  46002. hasTexture(texture: BaseTexture): boolean;
  46003. /**
  46004. * Returns an array of the actively used textures.
  46005. * @param activeTextures Array of BaseTextures
  46006. */
  46007. getActiveTextures(activeTextures: BaseTexture[]): void;
  46008. /**
  46009. * Returns the animatable textures.
  46010. * @param animatables Array of animatable textures.
  46011. */
  46012. getAnimatables(animatables: IAnimatable[]): void;
  46013. /**
  46014. * Disposes the resources of the material.
  46015. * @param forceDisposeTextures - Forces the disposal of all textures.
  46016. */
  46017. dispose(forceDisposeTextures?: boolean): void;
  46018. /**
  46019. * Get the current class name of the texture useful for serialization or dynamic coding.
  46020. * @returns "PBRSheenConfiguration"
  46021. */
  46022. getClassName(): string;
  46023. /**
  46024. * Add fallbacks to the effect fallbacks list.
  46025. * @param defines defines the Base texture to use.
  46026. * @param fallbacks defines the current fallback list.
  46027. * @param currentRank defines the current fallback rank.
  46028. * @returns the new fallback rank.
  46029. */
  46030. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46031. /**
  46032. * Add the required uniforms to the current list.
  46033. * @param uniforms defines the current uniform list.
  46034. */
  46035. static AddUniforms(uniforms: string[]): void;
  46036. /**
  46037. * Add the required uniforms to the current buffer.
  46038. * @param uniformBuffer defines the current uniform buffer.
  46039. */
  46040. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46041. /**
  46042. * Add the required samplers to the current list.
  46043. * @param samplers defines the current sampler list.
  46044. */
  46045. static AddSamplers(samplers: string[]): void;
  46046. /**
  46047. * Makes a duplicate of the current configuration into another one.
  46048. * @param sheenConfiguration define the config where to copy the info
  46049. */
  46050. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46051. /**
  46052. * Serializes this BRDF configuration.
  46053. * @returns - An object with the serialized config.
  46054. */
  46055. serialize(): any;
  46056. /**
  46057. * Parses a Sheen Configuration from a serialized object.
  46058. * @param source - Serialized object.
  46059. */
  46060. parse(source: any): void;
  46061. }
  46062. }
  46063. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46064. import { Nullable } from "babylonjs/types";
  46065. import { IAnimatable } from "babylonjs/Misc/tools";
  46066. import { Color3 } from "babylonjs/Maths/math";
  46067. import { SmartArray } from "babylonjs/Misc/smartArray";
  46068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46069. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46070. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46071. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46072. import { Engine } from "babylonjs/Engines/engine";
  46073. import { Scene } from "babylonjs/scene";
  46074. /**
  46075. * @hidden
  46076. */
  46077. export interface IMaterialSubSurfaceDefines {
  46078. SUBSURFACE: boolean;
  46079. SS_REFRACTION: boolean;
  46080. SS_TRANSLUCENCY: boolean;
  46081. SS_SCATERRING: boolean;
  46082. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46083. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46084. SS_REFRACTIONMAP_3D: boolean;
  46085. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46086. SS_LODINREFRACTIONALPHA: boolean;
  46087. SS_GAMMAREFRACTION: boolean;
  46088. SS_RGBDREFRACTION: boolean;
  46089. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46090. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46091. /** @hidden */
  46092. _areTexturesDirty: boolean;
  46093. }
  46094. /**
  46095. * Define the code related to the sub surface parameters of the pbr material.
  46096. */
  46097. export class PBRSubSurfaceConfiguration {
  46098. private _isRefractionEnabled;
  46099. /**
  46100. * Defines if the refraction is enabled in the material.
  46101. */
  46102. isRefractionEnabled: boolean;
  46103. private _isTranslucencyEnabled;
  46104. /**
  46105. * Defines if the translucency is enabled in the material.
  46106. */
  46107. isTranslucencyEnabled: boolean;
  46108. private _isScatteringEnabled;
  46109. /**
  46110. * Defines the refraction intensity of the material.
  46111. * The refraction when enabled replaces the Diffuse part of the material.
  46112. * The intensity helps transitionning between diffuse and refraction.
  46113. */
  46114. refractionIntensity: number;
  46115. /**
  46116. * Defines the translucency intensity of the material.
  46117. * When translucency has been enabled, this defines how much of the "translucency"
  46118. * is addded to the diffuse part of the material.
  46119. */
  46120. translucencyIntensity: number;
  46121. /**
  46122. * Defines the scattering intensity of the material.
  46123. * When scattering has been enabled, this defines how much of the "scattered light"
  46124. * is addded to the diffuse part of the material.
  46125. */
  46126. scatteringIntensity: number;
  46127. private _thicknessTexture;
  46128. /**
  46129. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46130. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46131. * 0 would mean minimumThickness
  46132. * 1 would mean maximumThickness
  46133. * The other channels might be use as a mask to vary the different effects intensity.
  46134. */
  46135. thicknessTexture: Nullable<BaseTexture>;
  46136. private _refractionTexture;
  46137. /**
  46138. * Defines the texture to use for refraction.
  46139. */
  46140. refractionTexture: Nullable<BaseTexture>;
  46141. private _indexOfRefraction;
  46142. /**
  46143. * Defines the indice of refraction used in the material.
  46144. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46145. */
  46146. indexOfRefraction: number;
  46147. private _invertRefractionY;
  46148. /**
  46149. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46150. */
  46151. invertRefractionY: boolean;
  46152. private _linkRefractionWithTransparency;
  46153. /**
  46154. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46155. * Materials half opaque for instance using refraction could benefit from this control.
  46156. */
  46157. linkRefractionWithTransparency: boolean;
  46158. /**
  46159. * Defines the minimum thickness stored in the thickness map.
  46160. * If no thickness map is defined, this value will be used to simulate thickness.
  46161. */
  46162. minimumThickness: number;
  46163. /**
  46164. * Defines the maximum thickness stored in the thickness map.
  46165. */
  46166. maximumThickness: number;
  46167. /**
  46168. * Defines the volume tint of the material.
  46169. * This is used for both translucency and scattering.
  46170. */
  46171. tintColor: Color3;
  46172. /**
  46173. * Defines the distance at which the tint color should be found in the media.
  46174. * This is used for refraction only.
  46175. */
  46176. tintColorAtDistance: number;
  46177. /**
  46178. * Defines how far each channel transmit through the media.
  46179. * It is defined as a color to simplify it selection.
  46180. */
  46181. diffusionDistance: Color3;
  46182. private _useMaskFromThicknessTexture;
  46183. /**
  46184. * Stores the intensity of the different subsurface effects in the thickness texture.
  46185. * * the green channel is the translucency intensity.
  46186. * * the blue channel is the scattering intensity.
  46187. * * the alpha channel is the refraction intensity.
  46188. */
  46189. useMaskFromThicknessTexture: boolean;
  46190. /** @hidden */
  46191. private _internalMarkAllSubMeshesAsTexturesDirty;
  46192. /** @hidden */
  46193. _markAllSubMeshesAsTexturesDirty(): void;
  46194. /**
  46195. * Instantiate a new istance of sub surface configuration.
  46196. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46197. */
  46198. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46199. /**
  46200. * Gets wehter the submesh is ready to be used or not.
  46201. * @param defines the list of "defines" to update.
  46202. * @param scene defines the scene the material belongs to.
  46203. * @returns - boolean indicating that the submesh is ready or not.
  46204. */
  46205. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46206. /**
  46207. * Checks to see if a texture is used in the material.
  46208. * @param defines the list of "defines" to update.
  46209. * @param scene defines the scene to the material belongs to.
  46210. */
  46211. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46212. /**
  46213. * Binds the material data.
  46214. * @param uniformBuffer defines the Uniform buffer to fill in.
  46215. * @param scene defines the scene the material belongs to.
  46216. * @param engine defines the engine the material belongs to.
  46217. * @param isFrozen defines wether the material is frozen or not.
  46218. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46219. */
  46220. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46221. /**
  46222. * Unbinds the material from the mesh.
  46223. * @param activeEffect defines the effect that should be unbound from.
  46224. * @returns true if unbound, otherwise false
  46225. */
  46226. unbind(activeEffect: Effect): boolean;
  46227. /**
  46228. * Returns the texture used for refraction or null if none is used.
  46229. * @param scene defines the scene the material belongs to.
  46230. * @returns - Refraction texture if present. If no refraction texture and refraction
  46231. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46232. */
  46233. private _getRefractionTexture;
  46234. /**
  46235. * Returns true if alpha blending should be disabled.
  46236. */
  46237. readonly disableAlphaBlending: boolean;
  46238. /**
  46239. * Fills the list of render target textures.
  46240. * @param renderTargets the list of render targets to update
  46241. */
  46242. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46243. /**
  46244. * Checks to see if a texture is used in the material.
  46245. * @param texture - Base texture to use.
  46246. * @returns - Boolean specifying if a texture is used in the material.
  46247. */
  46248. hasTexture(texture: BaseTexture): boolean;
  46249. /**
  46250. * Gets a boolean indicating that current material needs to register RTT
  46251. * @returns true if this uses a render target otherwise false.
  46252. */
  46253. hasRenderTargetTextures(): boolean;
  46254. /**
  46255. * Returns an array of the actively used textures.
  46256. * @param activeTextures Array of BaseTextures
  46257. */
  46258. getActiveTextures(activeTextures: BaseTexture[]): void;
  46259. /**
  46260. * Returns the animatable textures.
  46261. * @param animatables Array of animatable textures.
  46262. */
  46263. getAnimatables(animatables: IAnimatable[]): void;
  46264. /**
  46265. * Disposes the resources of the material.
  46266. * @param forceDisposeTextures - Forces the disposal of all textures.
  46267. */
  46268. dispose(forceDisposeTextures?: boolean): void;
  46269. /**
  46270. * Get the current class name of the texture useful for serialization or dynamic coding.
  46271. * @returns "PBRSubSurfaceConfiguration"
  46272. */
  46273. getClassName(): string;
  46274. /**
  46275. * Add fallbacks to the effect fallbacks list.
  46276. * @param defines defines the Base texture to use.
  46277. * @param fallbacks defines the current fallback list.
  46278. * @param currentRank defines the current fallback rank.
  46279. * @returns the new fallback rank.
  46280. */
  46281. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46282. /**
  46283. * Add the required uniforms to the current list.
  46284. * @param uniforms defines the current uniform list.
  46285. */
  46286. static AddUniforms(uniforms: string[]): void;
  46287. /**
  46288. * Add the required samplers to the current list.
  46289. * @param samplers defines the current sampler list.
  46290. */
  46291. static AddSamplers(samplers: string[]): void;
  46292. /**
  46293. * Add the required uniforms to the current buffer.
  46294. * @param uniformBuffer defines the current uniform buffer.
  46295. */
  46296. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46297. /**
  46298. * Makes a duplicate of the current configuration into another one.
  46299. * @param configuration define the config where to copy the info
  46300. */
  46301. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46302. /**
  46303. * Serializes this Sub Surface configuration.
  46304. * @returns - An object with the serialized config.
  46305. */
  46306. serialize(): any;
  46307. /**
  46308. * Parses a Sub Surface Configuration from a serialized object.
  46309. * @param source - Serialized object.
  46310. */
  46311. parse(source: any): void;
  46312. }
  46313. }
  46314. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46315. /** @hidden */
  46316. export var pbrFragmentDeclaration: {
  46317. name: string;
  46318. shader: string;
  46319. };
  46320. }
  46321. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46322. /** @hidden */
  46323. export var pbrUboDeclaration: {
  46324. name: string;
  46325. shader: string;
  46326. };
  46327. }
  46328. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46329. /** @hidden */
  46330. export var pbrFragmentExtraDeclaration: {
  46331. name: string;
  46332. shader: string;
  46333. };
  46334. }
  46335. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46336. /** @hidden */
  46337. export var pbrFragmentSamplersDeclaration: {
  46338. name: string;
  46339. shader: string;
  46340. };
  46341. }
  46342. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46343. /** @hidden */
  46344. export var pbrHelperFunctions: {
  46345. name: string;
  46346. shader: string;
  46347. };
  46348. }
  46349. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46350. /** @hidden */
  46351. export var harmonicsFunctions: {
  46352. name: string;
  46353. shader: string;
  46354. };
  46355. }
  46356. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46357. /** @hidden */
  46358. export var pbrDirectLightingSetupFunctions: {
  46359. name: string;
  46360. shader: string;
  46361. };
  46362. }
  46363. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46364. /** @hidden */
  46365. export var pbrDirectLightingFalloffFunctions: {
  46366. name: string;
  46367. shader: string;
  46368. };
  46369. }
  46370. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46371. /** @hidden */
  46372. export var pbrBRDFFunctions: {
  46373. name: string;
  46374. shader: string;
  46375. };
  46376. }
  46377. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46378. /** @hidden */
  46379. export var pbrDirectLightingFunctions: {
  46380. name: string;
  46381. shader: string;
  46382. };
  46383. }
  46384. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46385. /** @hidden */
  46386. export var pbrIBLFunctions: {
  46387. name: string;
  46388. shader: string;
  46389. };
  46390. }
  46391. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46392. /** @hidden */
  46393. export var pbrDebug: {
  46394. name: string;
  46395. shader: string;
  46396. };
  46397. }
  46398. declare module "babylonjs/Shaders/pbr.fragment" {
  46399. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46400. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46401. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46402. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46403. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46404. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46405. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46406. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46407. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46408. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46409. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46410. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46411. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46412. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46413. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46414. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46415. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46416. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46417. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46418. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46419. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46420. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46421. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46422. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46423. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46424. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46425. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46426. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46427. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46428. /** @hidden */
  46429. export var pbrPixelShader: {
  46430. name: string;
  46431. shader: string;
  46432. };
  46433. }
  46434. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46435. /** @hidden */
  46436. export var pbrVertexDeclaration: {
  46437. name: string;
  46438. shader: string;
  46439. };
  46440. }
  46441. declare module "babylonjs/Shaders/pbr.vertex" {
  46442. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46443. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46444. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46445. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46446. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46447. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46448. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46449. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46450. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46451. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46452. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46453. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46454. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46455. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46456. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46457. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46458. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46459. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46460. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46461. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46462. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46463. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46464. /** @hidden */
  46465. export var pbrVertexShader: {
  46466. name: string;
  46467. shader: string;
  46468. };
  46469. }
  46470. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46471. import { IAnimatable } from "babylonjs/Misc/tools";
  46472. import { Nullable } from "babylonjs/types";
  46473. import { Scene } from "babylonjs/scene";
  46474. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46475. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46477. import { Mesh } from "babylonjs/Meshes/mesh";
  46478. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46479. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46480. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46481. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46482. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46483. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46484. import { Material } from "babylonjs/Materials/material";
  46485. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46486. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46487. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46488. import "babylonjs/Shaders/pbr.fragment";
  46489. import "babylonjs/Shaders/pbr.vertex";
  46490. /**
  46491. * Manages the defines for the PBR Material.
  46492. * @hidden
  46493. */
  46494. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46495. PBR: boolean;
  46496. MAINUV1: boolean;
  46497. MAINUV2: boolean;
  46498. UV1: boolean;
  46499. UV2: boolean;
  46500. ALBEDO: boolean;
  46501. ALBEDODIRECTUV: number;
  46502. VERTEXCOLOR: boolean;
  46503. AMBIENT: boolean;
  46504. AMBIENTDIRECTUV: number;
  46505. AMBIENTINGRAYSCALE: boolean;
  46506. OPACITY: boolean;
  46507. VERTEXALPHA: boolean;
  46508. OPACITYDIRECTUV: number;
  46509. OPACITYRGB: boolean;
  46510. ALPHATEST: boolean;
  46511. DEPTHPREPASS: boolean;
  46512. ALPHABLEND: boolean;
  46513. ALPHAFROMALBEDO: boolean;
  46514. ALPHATESTVALUE: string;
  46515. SPECULAROVERALPHA: boolean;
  46516. RADIANCEOVERALPHA: boolean;
  46517. ALPHAFRESNEL: boolean;
  46518. LINEARALPHAFRESNEL: boolean;
  46519. PREMULTIPLYALPHA: boolean;
  46520. EMISSIVE: boolean;
  46521. EMISSIVEDIRECTUV: number;
  46522. REFLECTIVITY: boolean;
  46523. REFLECTIVITYDIRECTUV: number;
  46524. SPECULARTERM: boolean;
  46525. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46526. MICROSURFACEAUTOMATIC: boolean;
  46527. LODBASEDMICROSFURACE: boolean;
  46528. MICROSURFACEMAP: boolean;
  46529. MICROSURFACEMAPDIRECTUV: number;
  46530. METALLICWORKFLOW: boolean;
  46531. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46532. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46533. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46534. AOSTOREINMETALMAPRED: boolean;
  46535. ENVIRONMENTBRDF: boolean;
  46536. ENVIRONMENTBRDF_RGBD: boolean;
  46537. NORMAL: boolean;
  46538. TANGENT: boolean;
  46539. BUMP: boolean;
  46540. BUMPDIRECTUV: number;
  46541. OBJECTSPACE_NORMALMAP: boolean;
  46542. PARALLAX: boolean;
  46543. PARALLAXOCCLUSION: boolean;
  46544. NORMALXYSCALE: boolean;
  46545. LIGHTMAP: boolean;
  46546. LIGHTMAPDIRECTUV: number;
  46547. USELIGHTMAPASSHADOWMAP: boolean;
  46548. GAMMALIGHTMAP: boolean;
  46549. REFLECTION: boolean;
  46550. REFLECTIONMAP_3D: boolean;
  46551. REFLECTIONMAP_SPHERICAL: boolean;
  46552. REFLECTIONMAP_PLANAR: boolean;
  46553. REFLECTIONMAP_CUBIC: boolean;
  46554. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46555. REFLECTIONMAP_PROJECTION: boolean;
  46556. REFLECTIONMAP_SKYBOX: boolean;
  46557. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46558. REFLECTIONMAP_EXPLICIT: boolean;
  46559. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46560. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46561. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46562. INVERTCUBICMAP: boolean;
  46563. USESPHERICALFROMREFLECTIONMAP: boolean;
  46564. USESPHERICALINVERTEX: boolean;
  46565. REFLECTIONMAP_OPPOSITEZ: boolean;
  46566. LODINREFLECTIONALPHA: boolean;
  46567. GAMMAREFLECTION: boolean;
  46568. RGBDREFLECTION: boolean;
  46569. RADIANCEOCCLUSION: boolean;
  46570. HORIZONOCCLUSION: boolean;
  46571. INSTANCES: boolean;
  46572. NUM_BONE_INFLUENCERS: number;
  46573. BonesPerMesh: number;
  46574. BONETEXTURE: boolean;
  46575. NONUNIFORMSCALING: boolean;
  46576. MORPHTARGETS: boolean;
  46577. MORPHTARGETS_NORMAL: boolean;
  46578. MORPHTARGETS_TANGENT: boolean;
  46579. NUM_MORPH_INFLUENCERS: number;
  46580. IMAGEPROCESSING: boolean;
  46581. VIGNETTE: boolean;
  46582. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46583. VIGNETTEBLENDMODEOPAQUE: boolean;
  46584. TONEMAPPING: boolean;
  46585. TONEMAPPING_ACES: boolean;
  46586. CONTRAST: boolean;
  46587. COLORCURVES: boolean;
  46588. COLORGRADING: boolean;
  46589. COLORGRADING3D: boolean;
  46590. SAMPLER3DGREENDEPTH: boolean;
  46591. SAMPLER3DBGRMAP: boolean;
  46592. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46593. EXPOSURE: boolean;
  46594. MULTIVIEW: boolean;
  46595. USEPHYSICALLIGHTFALLOFF: boolean;
  46596. USEGLTFLIGHTFALLOFF: boolean;
  46597. TWOSIDEDLIGHTING: boolean;
  46598. SHADOWFLOAT: boolean;
  46599. CLIPPLANE: boolean;
  46600. CLIPPLANE2: boolean;
  46601. CLIPPLANE3: boolean;
  46602. CLIPPLANE4: boolean;
  46603. POINTSIZE: boolean;
  46604. FOG: boolean;
  46605. LOGARITHMICDEPTH: boolean;
  46606. FORCENORMALFORWARD: boolean;
  46607. SPECULARAA: boolean;
  46608. CLEARCOAT: boolean;
  46609. CLEARCOAT_DEFAULTIOR: boolean;
  46610. CLEARCOAT_TEXTURE: boolean;
  46611. CLEARCOAT_TEXTUREDIRECTUV: number;
  46612. CLEARCOAT_BUMP: boolean;
  46613. CLEARCOAT_BUMPDIRECTUV: number;
  46614. CLEARCOAT_TINT: boolean;
  46615. CLEARCOAT_TINT_TEXTURE: boolean;
  46616. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46617. ANISOTROPIC: boolean;
  46618. ANISOTROPIC_TEXTURE: boolean;
  46619. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46620. BRDF_V_HEIGHT_CORRELATED: boolean;
  46621. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46622. SHEEN: boolean;
  46623. SHEEN_TEXTURE: boolean;
  46624. SHEEN_TEXTUREDIRECTUV: number;
  46625. SHEEN_LINKWITHALBEDO: boolean;
  46626. SUBSURFACE: boolean;
  46627. SS_REFRACTION: boolean;
  46628. SS_TRANSLUCENCY: boolean;
  46629. SS_SCATERRING: boolean;
  46630. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46631. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46632. SS_REFRACTIONMAP_3D: boolean;
  46633. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46634. SS_LODINREFRACTIONALPHA: boolean;
  46635. SS_GAMMAREFRACTION: boolean;
  46636. SS_RGBDREFRACTION: boolean;
  46637. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46638. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46639. UNLIT: boolean;
  46640. DEBUGMODE: number;
  46641. /**
  46642. * Initializes the PBR Material defines.
  46643. */
  46644. constructor();
  46645. /**
  46646. * Resets the PBR Material defines.
  46647. */
  46648. reset(): void;
  46649. }
  46650. /**
  46651. * The Physically based material base class of BJS.
  46652. *
  46653. * This offers the main features of a standard PBR material.
  46654. * For more information, please refer to the documentation :
  46655. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46656. */
  46657. export abstract class PBRBaseMaterial extends PushMaterial {
  46658. /**
  46659. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46660. */
  46661. static readonly PBRMATERIAL_OPAQUE: number;
  46662. /**
  46663. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46664. */
  46665. static readonly PBRMATERIAL_ALPHATEST: number;
  46666. /**
  46667. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46668. */
  46669. static readonly PBRMATERIAL_ALPHABLEND: number;
  46670. /**
  46671. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46672. * They are also discarded below the alpha cutoff threshold to improve performances.
  46673. */
  46674. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46675. /**
  46676. * Defines the default value of how much AO map is occluding the analytical lights
  46677. * (point spot...).
  46678. */
  46679. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46680. /**
  46681. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46682. */
  46683. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46684. /**
  46685. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46686. * to enhance interoperability with other engines.
  46687. */
  46688. static readonly LIGHTFALLOFF_GLTF: number;
  46689. /**
  46690. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46691. * to enhance interoperability with other materials.
  46692. */
  46693. static readonly LIGHTFALLOFF_STANDARD: number;
  46694. /**
  46695. * Intensity of the direct lights e.g. the four lights available in your scene.
  46696. * This impacts both the direct diffuse and specular highlights.
  46697. */
  46698. protected _directIntensity: number;
  46699. /**
  46700. * Intensity of the emissive part of the material.
  46701. * This helps controlling the emissive effect without modifying the emissive color.
  46702. */
  46703. protected _emissiveIntensity: number;
  46704. /**
  46705. * Intensity of the environment e.g. how much the environment will light the object
  46706. * either through harmonics for rough material or through the refelction for shiny ones.
  46707. */
  46708. protected _environmentIntensity: number;
  46709. /**
  46710. * This is a special control allowing the reduction of the specular highlights coming from the
  46711. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46712. */
  46713. protected _specularIntensity: number;
  46714. /**
  46715. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46716. */
  46717. private _lightingInfos;
  46718. /**
  46719. * Debug Control allowing disabling the bump map on this material.
  46720. */
  46721. protected _disableBumpMap: boolean;
  46722. /**
  46723. * AKA Diffuse Texture in standard nomenclature.
  46724. */
  46725. protected _albedoTexture: Nullable<BaseTexture>;
  46726. /**
  46727. * AKA Occlusion Texture in other nomenclature.
  46728. */
  46729. protected _ambientTexture: Nullable<BaseTexture>;
  46730. /**
  46731. * AKA Occlusion Texture Intensity in other nomenclature.
  46732. */
  46733. protected _ambientTextureStrength: number;
  46734. /**
  46735. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46736. * 1 means it completely occludes it
  46737. * 0 mean it has no impact
  46738. */
  46739. protected _ambientTextureImpactOnAnalyticalLights: number;
  46740. /**
  46741. * Stores the alpha values in a texture.
  46742. */
  46743. protected _opacityTexture: Nullable<BaseTexture>;
  46744. /**
  46745. * Stores the reflection values in a texture.
  46746. */
  46747. protected _reflectionTexture: Nullable<BaseTexture>;
  46748. /**
  46749. * Stores the emissive values in a texture.
  46750. */
  46751. protected _emissiveTexture: Nullable<BaseTexture>;
  46752. /**
  46753. * AKA Specular texture in other nomenclature.
  46754. */
  46755. protected _reflectivityTexture: Nullable<BaseTexture>;
  46756. /**
  46757. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46758. */
  46759. protected _metallicTexture: Nullable<BaseTexture>;
  46760. /**
  46761. * Specifies the metallic scalar of the metallic/roughness workflow.
  46762. * Can also be used to scale the metalness values of the metallic texture.
  46763. */
  46764. protected _metallic: Nullable<number>;
  46765. /**
  46766. * Specifies the roughness scalar of the metallic/roughness workflow.
  46767. * Can also be used to scale the roughness values of the metallic texture.
  46768. */
  46769. protected _roughness: Nullable<number>;
  46770. /**
  46771. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46772. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46773. */
  46774. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46775. /**
  46776. * Stores surface normal data used to displace a mesh in a texture.
  46777. */
  46778. protected _bumpTexture: Nullable<BaseTexture>;
  46779. /**
  46780. * Stores the pre-calculated light information of a mesh in a texture.
  46781. */
  46782. protected _lightmapTexture: Nullable<BaseTexture>;
  46783. /**
  46784. * The color of a material in ambient lighting.
  46785. */
  46786. protected _ambientColor: Color3;
  46787. /**
  46788. * AKA Diffuse Color in other nomenclature.
  46789. */
  46790. protected _albedoColor: Color3;
  46791. /**
  46792. * AKA Specular Color in other nomenclature.
  46793. */
  46794. protected _reflectivityColor: Color3;
  46795. /**
  46796. * The color applied when light is reflected from a material.
  46797. */
  46798. protected _reflectionColor: Color3;
  46799. /**
  46800. * The color applied when light is emitted from a material.
  46801. */
  46802. protected _emissiveColor: Color3;
  46803. /**
  46804. * AKA Glossiness in other nomenclature.
  46805. */
  46806. protected _microSurface: number;
  46807. /**
  46808. * Specifies that the material will use the light map as a show map.
  46809. */
  46810. protected _useLightmapAsShadowmap: boolean;
  46811. /**
  46812. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46813. * makes the reflect vector face the model (under horizon).
  46814. */
  46815. protected _useHorizonOcclusion: boolean;
  46816. /**
  46817. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46818. * too much the area relying on ambient texture to define their ambient occlusion.
  46819. */
  46820. protected _useRadianceOcclusion: boolean;
  46821. /**
  46822. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46823. */
  46824. protected _useAlphaFromAlbedoTexture: boolean;
  46825. /**
  46826. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46827. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46828. */
  46829. protected _useSpecularOverAlpha: boolean;
  46830. /**
  46831. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46832. */
  46833. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46834. /**
  46835. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46836. */
  46837. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46838. /**
  46839. * Specifies if the metallic texture contains the roughness information in its green channel.
  46840. */
  46841. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46842. /**
  46843. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46844. */
  46845. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46846. /**
  46847. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46848. */
  46849. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46850. /**
  46851. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46852. */
  46853. protected _useAmbientInGrayScale: boolean;
  46854. /**
  46855. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46856. * The material will try to infer what glossiness each pixel should be.
  46857. */
  46858. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46859. /**
  46860. * Defines the falloff type used in this material.
  46861. * It by default is Physical.
  46862. */
  46863. protected _lightFalloff: number;
  46864. /**
  46865. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46866. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46867. */
  46868. protected _useRadianceOverAlpha: boolean;
  46869. /**
  46870. * Allows using an object space normal map (instead of tangent space).
  46871. */
  46872. protected _useObjectSpaceNormalMap: boolean;
  46873. /**
  46874. * Allows using the bump map in parallax mode.
  46875. */
  46876. protected _useParallax: boolean;
  46877. /**
  46878. * Allows using the bump map in parallax occlusion mode.
  46879. */
  46880. protected _useParallaxOcclusion: boolean;
  46881. /**
  46882. * Controls the scale bias of the parallax mode.
  46883. */
  46884. protected _parallaxScaleBias: number;
  46885. /**
  46886. * If sets to true, disables all the lights affecting the material.
  46887. */
  46888. protected _disableLighting: boolean;
  46889. /**
  46890. * Number of Simultaneous lights allowed on the material.
  46891. */
  46892. protected _maxSimultaneousLights: number;
  46893. /**
  46894. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46895. */
  46896. protected _invertNormalMapX: boolean;
  46897. /**
  46898. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46899. */
  46900. protected _invertNormalMapY: boolean;
  46901. /**
  46902. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46903. */
  46904. protected _twoSidedLighting: boolean;
  46905. /**
  46906. * Defines the alpha limits in alpha test mode.
  46907. */
  46908. protected _alphaCutOff: number;
  46909. /**
  46910. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46911. */
  46912. protected _forceAlphaTest: boolean;
  46913. /**
  46914. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46915. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46916. */
  46917. protected _useAlphaFresnel: boolean;
  46918. /**
  46919. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46920. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46921. */
  46922. protected _useLinearAlphaFresnel: boolean;
  46923. /**
  46924. * The transparency mode of the material.
  46925. */
  46926. protected _transparencyMode: Nullable<number>;
  46927. /**
  46928. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46929. * from cos thetav and roughness:
  46930. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46931. */
  46932. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46933. /**
  46934. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46935. */
  46936. protected _forceIrradianceInFragment: boolean;
  46937. /**
  46938. * Force normal to face away from face.
  46939. */
  46940. protected _forceNormalForward: boolean;
  46941. /**
  46942. * Enables specular anti aliasing in the PBR shader.
  46943. * It will both interacts on the Geometry for analytical and IBL lighting.
  46944. * It also prefilter the roughness map based on the bump values.
  46945. */
  46946. protected _enableSpecularAntiAliasing: boolean;
  46947. /**
  46948. * Default configuration related to image processing available in the PBR Material.
  46949. */
  46950. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46951. /**
  46952. * Keep track of the image processing observer to allow dispose and replace.
  46953. */
  46954. private _imageProcessingObserver;
  46955. /**
  46956. * Attaches a new image processing configuration to the PBR Material.
  46957. * @param configuration
  46958. */
  46959. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46960. /**
  46961. * Stores the available render targets.
  46962. */
  46963. private _renderTargets;
  46964. /**
  46965. * Sets the global ambient color for the material used in lighting calculations.
  46966. */
  46967. private _globalAmbientColor;
  46968. /**
  46969. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46970. */
  46971. private _useLogarithmicDepth;
  46972. /**
  46973. * If set to true, no lighting calculations will be applied.
  46974. */
  46975. private _unlit;
  46976. private _debugMode;
  46977. /**
  46978. * @hidden
  46979. * This is reserved for the inspector.
  46980. * Defines the material debug mode.
  46981. * It helps seeing only some components of the material while troubleshooting.
  46982. */
  46983. debugMode: number;
  46984. /**
  46985. * @hidden
  46986. * This is reserved for the inspector.
  46987. * Specify from where on screen the debug mode should start.
  46988. * The value goes from -1 (full screen) to 1 (not visible)
  46989. * It helps with side by side comparison against the final render
  46990. * This defaults to -1
  46991. */
  46992. private debugLimit;
  46993. /**
  46994. * @hidden
  46995. * This is reserved for the inspector.
  46996. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46997. * You can use the factor to better multiply the final value.
  46998. */
  46999. private debugFactor;
  47000. /**
  47001. * Defines the clear coat layer parameters for the material.
  47002. */
  47003. readonly clearCoat: PBRClearCoatConfiguration;
  47004. /**
  47005. * Defines the anisotropic parameters for the material.
  47006. */
  47007. readonly anisotropy: PBRAnisotropicConfiguration;
  47008. /**
  47009. * Defines the BRDF parameters for the material.
  47010. */
  47011. readonly brdf: PBRBRDFConfiguration;
  47012. /**
  47013. * Defines the Sheen parameters for the material.
  47014. */
  47015. readonly sheen: PBRSheenConfiguration;
  47016. /**
  47017. * Defines the SubSurface parameters for the material.
  47018. */
  47019. readonly subSurface: PBRSubSurfaceConfiguration;
  47020. /**
  47021. * Custom callback helping to override the default shader used in the material.
  47022. */
  47023. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47024. /**
  47025. * Instantiates a new PBRMaterial instance.
  47026. *
  47027. * @param name The material name
  47028. * @param scene The scene the material will be use in.
  47029. */
  47030. constructor(name: string, scene: Scene);
  47031. /**
  47032. * Gets a boolean indicating that current material needs to register RTT
  47033. */
  47034. readonly hasRenderTargetTextures: boolean;
  47035. /**
  47036. * Gets the name of the material class.
  47037. */
  47038. getClassName(): string;
  47039. /**
  47040. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47041. */
  47042. /**
  47043. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47044. */
  47045. useLogarithmicDepth: boolean;
  47046. /**
  47047. * Gets the current transparency mode.
  47048. */
  47049. /**
  47050. * Sets the transparency mode of the material.
  47051. *
  47052. * | Value | Type | Description |
  47053. * | ----- | ----------------------------------- | ----------- |
  47054. * | 0 | OPAQUE | |
  47055. * | 1 | ALPHATEST | |
  47056. * | 2 | ALPHABLEND | |
  47057. * | 3 | ALPHATESTANDBLEND | |
  47058. *
  47059. */
  47060. transparencyMode: Nullable<number>;
  47061. /**
  47062. * Returns true if alpha blending should be disabled.
  47063. */
  47064. private readonly _disableAlphaBlending;
  47065. /**
  47066. * Specifies whether or not this material should be rendered in alpha blend mode.
  47067. */
  47068. needAlphaBlending(): boolean;
  47069. /**
  47070. * Specifies if the mesh will require alpha blending.
  47071. * @param mesh - BJS mesh.
  47072. */
  47073. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47074. /**
  47075. * Specifies whether or not this material should be rendered in alpha test mode.
  47076. */
  47077. needAlphaTesting(): boolean;
  47078. /**
  47079. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47080. */
  47081. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47082. /**
  47083. * Gets the texture used for the alpha test.
  47084. */
  47085. getAlphaTestTexture(): Nullable<BaseTexture>;
  47086. /**
  47087. * Specifies that the submesh is ready to be used.
  47088. * @param mesh - BJS mesh.
  47089. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47090. * @param useInstances - Specifies that instances should be used.
  47091. * @returns - boolean indicating that the submesh is ready or not.
  47092. */
  47093. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47094. /**
  47095. * Specifies if the material uses metallic roughness workflow.
  47096. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47097. */
  47098. isMetallicWorkflow(): boolean;
  47099. private _prepareEffect;
  47100. private _prepareDefines;
  47101. /**
  47102. * Force shader compilation
  47103. */
  47104. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47105. clipPlane: boolean;
  47106. }>): void;
  47107. /**
  47108. * Initializes the uniform buffer layout for the shader.
  47109. */
  47110. buildUniformLayout(): void;
  47111. /**
  47112. * Unbinds the material from the mesh
  47113. */
  47114. unbind(): void;
  47115. /**
  47116. * Binds the submesh data.
  47117. * @param world - The world matrix.
  47118. * @param mesh - The BJS mesh.
  47119. * @param subMesh - A submesh of the BJS mesh.
  47120. */
  47121. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47122. /**
  47123. * Returns the animatable textures.
  47124. * @returns - Array of animatable textures.
  47125. */
  47126. getAnimatables(): IAnimatable[];
  47127. /**
  47128. * Returns the texture used for reflections.
  47129. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47130. */
  47131. private _getReflectionTexture;
  47132. /**
  47133. * Returns an array of the actively used textures.
  47134. * @returns - Array of BaseTextures
  47135. */
  47136. getActiveTextures(): BaseTexture[];
  47137. /**
  47138. * Checks to see if a texture is used in the material.
  47139. * @param texture - Base texture to use.
  47140. * @returns - Boolean specifying if a texture is used in the material.
  47141. */
  47142. hasTexture(texture: BaseTexture): boolean;
  47143. /**
  47144. * Disposes the resources of the material.
  47145. * @param forceDisposeEffect - Forces the disposal of effects.
  47146. * @param forceDisposeTextures - Forces the disposal of all textures.
  47147. */
  47148. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47149. }
  47150. }
  47151. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47152. import { Nullable } from "babylonjs/types";
  47153. import { Scene } from "babylonjs/scene";
  47154. import { Color3 } from "babylonjs/Maths/math";
  47155. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47156. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47157. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47158. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47159. /**
  47160. * The Physically based material of BJS.
  47161. *
  47162. * This offers the main features of a standard PBR material.
  47163. * For more information, please refer to the documentation :
  47164. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47165. */
  47166. export class PBRMaterial extends PBRBaseMaterial {
  47167. /**
  47168. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47169. */
  47170. static readonly PBRMATERIAL_OPAQUE: number;
  47171. /**
  47172. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47173. */
  47174. static readonly PBRMATERIAL_ALPHATEST: number;
  47175. /**
  47176. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47177. */
  47178. static readonly PBRMATERIAL_ALPHABLEND: number;
  47179. /**
  47180. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47181. * They are also discarded below the alpha cutoff threshold to improve performances.
  47182. */
  47183. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47184. /**
  47185. * Defines the default value of how much AO map is occluding the analytical lights
  47186. * (point spot...).
  47187. */
  47188. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47189. /**
  47190. * Intensity of the direct lights e.g. the four lights available in your scene.
  47191. * This impacts both the direct diffuse and specular highlights.
  47192. */
  47193. directIntensity: number;
  47194. /**
  47195. * Intensity of the emissive part of the material.
  47196. * This helps controlling the emissive effect without modifying the emissive color.
  47197. */
  47198. emissiveIntensity: number;
  47199. /**
  47200. * Intensity of the environment e.g. how much the environment will light the object
  47201. * either through harmonics for rough material or through the refelction for shiny ones.
  47202. */
  47203. environmentIntensity: number;
  47204. /**
  47205. * This is a special control allowing the reduction of the specular highlights coming from the
  47206. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47207. */
  47208. specularIntensity: number;
  47209. /**
  47210. * Debug Control allowing disabling the bump map on this material.
  47211. */
  47212. disableBumpMap: boolean;
  47213. /**
  47214. * AKA Diffuse Texture in standard nomenclature.
  47215. */
  47216. albedoTexture: BaseTexture;
  47217. /**
  47218. * AKA Occlusion Texture in other nomenclature.
  47219. */
  47220. ambientTexture: BaseTexture;
  47221. /**
  47222. * AKA Occlusion Texture Intensity in other nomenclature.
  47223. */
  47224. ambientTextureStrength: number;
  47225. /**
  47226. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47227. * 1 means it completely occludes it
  47228. * 0 mean it has no impact
  47229. */
  47230. ambientTextureImpactOnAnalyticalLights: number;
  47231. /**
  47232. * Stores the alpha values in a texture.
  47233. */
  47234. opacityTexture: BaseTexture;
  47235. /**
  47236. * Stores the reflection values in a texture.
  47237. */
  47238. reflectionTexture: Nullable<BaseTexture>;
  47239. /**
  47240. * Stores the emissive values in a texture.
  47241. */
  47242. emissiveTexture: BaseTexture;
  47243. /**
  47244. * AKA Specular texture in other nomenclature.
  47245. */
  47246. reflectivityTexture: BaseTexture;
  47247. /**
  47248. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47249. */
  47250. metallicTexture: BaseTexture;
  47251. /**
  47252. * Specifies the metallic scalar of the metallic/roughness workflow.
  47253. * Can also be used to scale the metalness values of the metallic texture.
  47254. */
  47255. metallic: Nullable<number>;
  47256. /**
  47257. * Specifies the roughness scalar of the metallic/roughness workflow.
  47258. * Can also be used to scale the roughness values of the metallic texture.
  47259. */
  47260. roughness: Nullable<number>;
  47261. /**
  47262. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47263. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47264. */
  47265. microSurfaceTexture: BaseTexture;
  47266. /**
  47267. * Stores surface normal data used to displace a mesh in a texture.
  47268. */
  47269. bumpTexture: BaseTexture;
  47270. /**
  47271. * Stores the pre-calculated light information of a mesh in a texture.
  47272. */
  47273. lightmapTexture: BaseTexture;
  47274. /**
  47275. * Stores the refracted light information in a texture.
  47276. */
  47277. refractionTexture: Nullable<BaseTexture>;
  47278. /**
  47279. * The color of a material in ambient lighting.
  47280. */
  47281. ambientColor: Color3;
  47282. /**
  47283. * AKA Diffuse Color in other nomenclature.
  47284. */
  47285. albedoColor: Color3;
  47286. /**
  47287. * AKA Specular Color in other nomenclature.
  47288. */
  47289. reflectivityColor: Color3;
  47290. /**
  47291. * The color reflected from the material.
  47292. */
  47293. reflectionColor: Color3;
  47294. /**
  47295. * The color emitted from the material.
  47296. */
  47297. emissiveColor: Color3;
  47298. /**
  47299. * AKA Glossiness in other nomenclature.
  47300. */
  47301. microSurface: number;
  47302. /**
  47303. * source material index of refraction (IOR)' / 'destination material IOR.
  47304. */
  47305. indexOfRefraction: number;
  47306. /**
  47307. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47308. */
  47309. invertRefractionY: boolean;
  47310. /**
  47311. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47312. * Materials half opaque for instance using refraction could benefit from this control.
  47313. */
  47314. linkRefractionWithTransparency: boolean;
  47315. /**
  47316. * If true, the light map contains occlusion information instead of lighting info.
  47317. */
  47318. useLightmapAsShadowmap: boolean;
  47319. /**
  47320. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47321. */
  47322. useAlphaFromAlbedoTexture: boolean;
  47323. /**
  47324. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47325. */
  47326. forceAlphaTest: boolean;
  47327. /**
  47328. * Defines the alpha limits in alpha test mode.
  47329. */
  47330. alphaCutOff: number;
  47331. /**
  47332. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47333. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47334. */
  47335. useSpecularOverAlpha: boolean;
  47336. /**
  47337. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47338. */
  47339. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47340. /**
  47341. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47342. */
  47343. useRoughnessFromMetallicTextureAlpha: boolean;
  47344. /**
  47345. * Specifies if the metallic texture contains the roughness information in its green channel.
  47346. */
  47347. useRoughnessFromMetallicTextureGreen: boolean;
  47348. /**
  47349. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47350. */
  47351. useMetallnessFromMetallicTextureBlue: boolean;
  47352. /**
  47353. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47354. */
  47355. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47356. /**
  47357. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47358. */
  47359. useAmbientInGrayScale: boolean;
  47360. /**
  47361. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47362. * The material will try to infer what glossiness each pixel should be.
  47363. */
  47364. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47365. /**
  47366. * BJS is using an harcoded light falloff based on a manually sets up range.
  47367. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47368. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47369. */
  47370. /**
  47371. * BJS is using an harcoded light falloff based on a manually sets up range.
  47372. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47373. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47374. */
  47375. usePhysicalLightFalloff: boolean;
  47376. /**
  47377. * In order to support the falloff compatibility with gltf, a special mode has been added
  47378. * to reproduce the gltf light falloff.
  47379. */
  47380. /**
  47381. * In order to support the falloff compatibility with gltf, a special mode has been added
  47382. * to reproduce the gltf light falloff.
  47383. */
  47384. useGLTFLightFalloff: boolean;
  47385. /**
  47386. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47387. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47388. */
  47389. useRadianceOverAlpha: boolean;
  47390. /**
  47391. * Allows using an object space normal map (instead of tangent space).
  47392. */
  47393. useObjectSpaceNormalMap: boolean;
  47394. /**
  47395. * Allows using the bump map in parallax mode.
  47396. */
  47397. useParallax: boolean;
  47398. /**
  47399. * Allows using the bump map in parallax occlusion mode.
  47400. */
  47401. useParallaxOcclusion: boolean;
  47402. /**
  47403. * Controls the scale bias of the parallax mode.
  47404. */
  47405. parallaxScaleBias: number;
  47406. /**
  47407. * If sets to true, disables all the lights affecting the material.
  47408. */
  47409. disableLighting: boolean;
  47410. /**
  47411. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47412. */
  47413. forceIrradianceInFragment: boolean;
  47414. /**
  47415. * Number of Simultaneous lights allowed on the material.
  47416. */
  47417. maxSimultaneousLights: number;
  47418. /**
  47419. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47420. */
  47421. invertNormalMapX: boolean;
  47422. /**
  47423. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47424. */
  47425. invertNormalMapY: boolean;
  47426. /**
  47427. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47428. */
  47429. twoSidedLighting: boolean;
  47430. /**
  47431. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47432. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47433. */
  47434. useAlphaFresnel: boolean;
  47435. /**
  47436. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47437. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47438. */
  47439. useLinearAlphaFresnel: boolean;
  47440. /**
  47441. * Let user defines the brdf lookup texture used for IBL.
  47442. * A default 8bit version is embedded but you could point at :
  47443. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47444. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47445. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47446. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47447. */
  47448. environmentBRDFTexture: Nullable<BaseTexture>;
  47449. /**
  47450. * Force normal to face away from face.
  47451. */
  47452. forceNormalForward: boolean;
  47453. /**
  47454. * Enables specular anti aliasing in the PBR shader.
  47455. * It will both interacts on the Geometry for analytical and IBL lighting.
  47456. * It also prefilter the roughness map based on the bump values.
  47457. */
  47458. enableSpecularAntiAliasing: boolean;
  47459. /**
  47460. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47461. * makes the reflect vector face the model (under horizon).
  47462. */
  47463. useHorizonOcclusion: boolean;
  47464. /**
  47465. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47466. * too much the area relying on ambient texture to define their ambient occlusion.
  47467. */
  47468. useRadianceOcclusion: boolean;
  47469. /**
  47470. * If set to true, no lighting calculations will be applied.
  47471. */
  47472. unlit: boolean;
  47473. /**
  47474. * Gets the image processing configuration used either in this material.
  47475. */
  47476. /**
  47477. * Sets the Default image processing configuration used either in the this material.
  47478. *
  47479. * If sets to null, the scene one is in use.
  47480. */
  47481. imageProcessingConfiguration: ImageProcessingConfiguration;
  47482. /**
  47483. * Gets wether the color curves effect is enabled.
  47484. */
  47485. /**
  47486. * Sets wether the color curves effect is enabled.
  47487. */
  47488. cameraColorCurvesEnabled: boolean;
  47489. /**
  47490. * Gets wether the color grading effect is enabled.
  47491. */
  47492. /**
  47493. * Gets wether the color grading effect is enabled.
  47494. */
  47495. cameraColorGradingEnabled: boolean;
  47496. /**
  47497. * Gets wether tonemapping is enabled or not.
  47498. */
  47499. /**
  47500. * Sets wether tonemapping is enabled or not
  47501. */
  47502. cameraToneMappingEnabled: boolean;
  47503. /**
  47504. * The camera exposure used on this material.
  47505. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47506. * This corresponds to a photographic exposure.
  47507. */
  47508. /**
  47509. * The camera exposure used on this material.
  47510. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47511. * This corresponds to a photographic exposure.
  47512. */
  47513. cameraExposure: number;
  47514. /**
  47515. * Gets The camera contrast used on this material.
  47516. */
  47517. /**
  47518. * Sets The camera contrast used on this material.
  47519. */
  47520. cameraContrast: number;
  47521. /**
  47522. * Gets the Color Grading 2D Lookup Texture.
  47523. */
  47524. /**
  47525. * Sets the Color Grading 2D Lookup Texture.
  47526. */
  47527. cameraColorGradingTexture: Nullable<BaseTexture>;
  47528. /**
  47529. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47530. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47531. * 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;
  47532. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47533. */
  47534. /**
  47535. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47536. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47537. * 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;
  47538. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47539. */
  47540. cameraColorCurves: Nullable<ColorCurves>;
  47541. /**
  47542. * Instantiates a new PBRMaterial instance.
  47543. *
  47544. * @param name The material name
  47545. * @param scene The scene the material will be use in.
  47546. */
  47547. constructor(name: string, scene: Scene);
  47548. /**
  47549. * Returns the name of this material class.
  47550. */
  47551. getClassName(): string;
  47552. /**
  47553. * Makes a duplicate of the current material.
  47554. * @param name - name to use for the new material.
  47555. */
  47556. clone(name: string): PBRMaterial;
  47557. /**
  47558. * Serializes this PBR Material.
  47559. * @returns - An object with the serialized material.
  47560. */
  47561. serialize(): any;
  47562. /**
  47563. * Parses a PBR Material from a serialized object.
  47564. * @param source - Serialized object.
  47565. * @param scene - BJS scene instance.
  47566. * @param rootUrl - url for the scene object
  47567. * @returns - PBRMaterial
  47568. */
  47569. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47570. }
  47571. }
  47572. declare module "babylonjs/Misc/dds" {
  47573. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47574. import { Engine } from "babylonjs/Engines/engine";
  47575. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47576. import { Nullable } from "babylonjs/types";
  47577. import { Scene } from "babylonjs/scene";
  47578. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47579. /**
  47580. * Direct draw surface info
  47581. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47582. */
  47583. export interface DDSInfo {
  47584. /**
  47585. * Width of the texture
  47586. */
  47587. width: number;
  47588. /**
  47589. * Width of the texture
  47590. */
  47591. height: number;
  47592. /**
  47593. * Number of Mipmaps for the texture
  47594. * @see https://en.wikipedia.org/wiki/Mipmap
  47595. */
  47596. mipmapCount: number;
  47597. /**
  47598. * If the textures format is a known fourCC format
  47599. * @see https://www.fourcc.org/
  47600. */
  47601. isFourCC: boolean;
  47602. /**
  47603. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47604. */
  47605. isRGB: boolean;
  47606. /**
  47607. * If the texture is a lumincance format
  47608. */
  47609. isLuminance: boolean;
  47610. /**
  47611. * If this is a cube texture
  47612. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47613. */
  47614. isCube: boolean;
  47615. /**
  47616. * If the texture is a compressed format eg. FOURCC_DXT1
  47617. */
  47618. isCompressed: boolean;
  47619. /**
  47620. * The dxgiFormat of the texture
  47621. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47622. */
  47623. dxgiFormat: number;
  47624. /**
  47625. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47626. */
  47627. textureType: number;
  47628. /**
  47629. * Sphericle polynomial created for the dds texture
  47630. */
  47631. sphericalPolynomial?: SphericalPolynomial;
  47632. }
  47633. /**
  47634. * Class used to provide DDS decompression tools
  47635. */
  47636. export class DDSTools {
  47637. /**
  47638. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47639. */
  47640. static StoreLODInAlphaChannel: boolean;
  47641. /**
  47642. * Gets DDS information from an array buffer
  47643. * @param arrayBuffer defines the array buffer to read data from
  47644. * @returns the DDS information
  47645. */
  47646. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47647. private static _FloatView;
  47648. private static _Int32View;
  47649. private static _ToHalfFloat;
  47650. private static _FromHalfFloat;
  47651. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47652. private static _GetHalfFloatRGBAArrayBuffer;
  47653. private static _GetFloatRGBAArrayBuffer;
  47654. private static _GetFloatAsUIntRGBAArrayBuffer;
  47655. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47656. private static _GetRGBAArrayBuffer;
  47657. private static _ExtractLongWordOrder;
  47658. private static _GetRGBArrayBuffer;
  47659. private static _GetLuminanceArrayBuffer;
  47660. /**
  47661. * Uploads DDS Levels to a Babylon Texture
  47662. * @hidden
  47663. */
  47664. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47665. }
  47666. module "babylonjs/Engines/engine" {
  47667. interface Engine {
  47668. /**
  47669. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47670. * @param rootUrl defines the url where the file to load is located
  47671. * @param scene defines the current scene
  47672. * @param lodScale defines scale to apply to the mip map selection
  47673. * @param lodOffset defines offset to apply to the mip map selection
  47674. * @param onLoad defines an optional callback raised when the texture is loaded
  47675. * @param onError defines an optional callback raised if there is an issue to load the texture
  47676. * @param format defines the format of the data
  47677. * @param forcedExtension defines the extension to use to pick the right loader
  47678. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47679. * @returns the cube texture as an InternalTexture
  47680. */
  47681. 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;
  47682. }
  47683. }
  47684. }
  47685. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47686. import { Nullable } from "babylonjs/types";
  47687. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47688. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47689. /**
  47690. * Implementation of the DDS Texture Loader.
  47691. * @hidden
  47692. */
  47693. export class _DDSTextureLoader implements IInternalTextureLoader {
  47694. /**
  47695. * Defines wether the loader supports cascade loading the different faces.
  47696. */
  47697. readonly supportCascades: boolean;
  47698. /**
  47699. * This returns if the loader support the current file information.
  47700. * @param extension defines the file extension of the file being loaded
  47701. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47702. * @param fallback defines the fallback internal texture if any
  47703. * @param isBase64 defines whether the texture is encoded as a base64
  47704. * @param isBuffer defines whether the texture data are stored as a buffer
  47705. * @returns true if the loader can load the specified file
  47706. */
  47707. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47708. /**
  47709. * Transform the url before loading if required.
  47710. * @param rootUrl the url of the texture
  47711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47712. * @returns the transformed texture
  47713. */
  47714. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47715. /**
  47716. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47717. * @param rootUrl the url of the texture
  47718. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47719. * @returns the fallback texture
  47720. */
  47721. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47722. /**
  47723. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47724. * @param data contains the texture data
  47725. * @param texture defines the BabylonJS internal texture
  47726. * @param createPolynomials will be true if polynomials have been requested
  47727. * @param onLoad defines the callback to trigger once the texture is ready
  47728. * @param onError defines the callback to trigger in case of error
  47729. */
  47730. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47731. /**
  47732. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47733. * @param data contains the texture data
  47734. * @param texture defines the BabylonJS internal texture
  47735. * @param callback defines the method to call once ready to upload
  47736. */
  47737. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47738. }
  47739. }
  47740. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47741. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47742. /** @hidden */
  47743. export var rgbdEncodePixelShader: {
  47744. name: string;
  47745. shader: string;
  47746. };
  47747. }
  47748. declare module "babylonjs/Misc/environmentTextureTools" {
  47749. import { Nullable } from "babylonjs/types";
  47750. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47751. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47752. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47753. import "babylonjs/Engines/Extensions/engine.renderTarget";
  47754. import "babylonjs/Shaders/rgbdEncode.fragment";
  47755. import "babylonjs/Shaders/rgbdDecode.fragment";
  47756. /**
  47757. * Raw texture data and descriptor sufficient for WebGL texture upload
  47758. */
  47759. export interface EnvironmentTextureInfo {
  47760. /**
  47761. * Version of the environment map
  47762. */
  47763. version: number;
  47764. /**
  47765. * Width of image
  47766. */
  47767. width: number;
  47768. /**
  47769. * Irradiance information stored in the file.
  47770. */
  47771. irradiance: any;
  47772. /**
  47773. * Specular information stored in the file.
  47774. */
  47775. specular: any;
  47776. }
  47777. /**
  47778. * Sets of helpers addressing the serialization and deserialization of environment texture
  47779. * stored in a BabylonJS env file.
  47780. * Those files are usually stored as .env files.
  47781. */
  47782. export class EnvironmentTextureTools {
  47783. /**
  47784. * Magic number identifying the env file.
  47785. */
  47786. private static _MagicBytes;
  47787. /**
  47788. * Gets the environment info from an env file.
  47789. * @param data The array buffer containing the .env bytes.
  47790. * @returns the environment file info (the json header) if successfully parsed.
  47791. */
  47792. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47793. /**
  47794. * Creates an environment texture from a loaded cube texture.
  47795. * @param texture defines the cube texture to convert in env file
  47796. * @return a promise containing the environment data if succesfull.
  47797. */
  47798. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47799. /**
  47800. * Creates a JSON representation of the spherical data.
  47801. * @param texture defines the texture containing the polynomials
  47802. * @return the JSON representation of the spherical info
  47803. */
  47804. private static _CreateEnvTextureIrradiance;
  47805. /**
  47806. * Uploads the texture info contained in the env file to the GPU.
  47807. * @param texture defines the internal texture to upload to
  47808. * @param arrayBuffer defines the buffer cotaining the data to load
  47809. * @param info defines the texture info retrieved through the GetEnvInfo method
  47810. * @returns a promise
  47811. */
  47812. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47813. /**
  47814. * Uploads the levels of image data to the GPU.
  47815. * @param texture defines the internal texture to upload to
  47816. * @param imageData defines the array buffer views of image data [mipmap][face]
  47817. * @returns a promise
  47818. */
  47819. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47820. /**
  47821. * Uploads spherical polynomials information to the texture.
  47822. * @param texture defines the texture we are trying to upload the information to
  47823. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47824. */
  47825. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47826. /** @hidden */
  47827. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47828. }
  47829. }
  47830. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47831. import { Nullable } from "babylonjs/types";
  47832. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47833. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47834. /**
  47835. * Implementation of the ENV Texture Loader.
  47836. * @hidden
  47837. */
  47838. export class _ENVTextureLoader implements IInternalTextureLoader {
  47839. /**
  47840. * Defines wether the loader supports cascade loading the different faces.
  47841. */
  47842. readonly supportCascades: boolean;
  47843. /**
  47844. * This returns if the loader support the current file information.
  47845. * @param extension defines the file extension of the file being loaded
  47846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47847. * @param fallback defines the fallback internal texture if any
  47848. * @param isBase64 defines whether the texture is encoded as a base64
  47849. * @param isBuffer defines whether the texture data are stored as a buffer
  47850. * @returns true if the loader can load the specified file
  47851. */
  47852. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47853. /**
  47854. * Transform the url before loading if required.
  47855. * @param rootUrl the url of the texture
  47856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47857. * @returns the transformed texture
  47858. */
  47859. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47860. /**
  47861. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47862. * @param rootUrl the url of the texture
  47863. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47864. * @returns the fallback texture
  47865. */
  47866. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47867. /**
  47868. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47869. * @param data contains the texture data
  47870. * @param texture defines the BabylonJS internal texture
  47871. * @param createPolynomials will be true if polynomials have been requested
  47872. * @param onLoad defines the callback to trigger once the texture is ready
  47873. * @param onError defines the callback to trigger in case of error
  47874. */
  47875. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47876. /**
  47877. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47878. * @param data contains the texture data
  47879. * @param texture defines the BabylonJS internal texture
  47880. * @param callback defines the method to call once ready to upload
  47881. */
  47882. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47883. }
  47884. }
  47885. declare module "babylonjs/Misc/khronosTextureContainer" {
  47886. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47887. /**
  47888. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47889. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47890. */
  47891. export class KhronosTextureContainer {
  47892. /** contents of the KTX container file */
  47893. arrayBuffer: any;
  47894. private static HEADER_LEN;
  47895. private static COMPRESSED_2D;
  47896. private static COMPRESSED_3D;
  47897. private static TEX_2D;
  47898. private static TEX_3D;
  47899. /**
  47900. * Gets the openGL type
  47901. */
  47902. glType: number;
  47903. /**
  47904. * Gets the openGL type size
  47905. */
  47906. glTypeSize: number;
  47907. /**
  47908. * Gets the openGL format
  47909. */
  47910. glFormat: number;
  47911. /**
  47912. * Gets the openGL internal format
  47913. */
  47914. glInternalFormat: number;
  47915. /**
  47916. * Gets the base internal format
  47917. */
  47918. glBaseInternalFormat: number;
  47919. /**
  47920. * Gets image width in pixel
  47921. */
  47922. pixelWidth: number;
  47923. /**
  47924. * Gets image height in pixel
  47925. */
  47926. pixelHeight: number;
  47927. /**
  47928. * Gets image depth in pixels
  47929. */
  47930. pixelDepth: number;
  47931. /**
  47932. * Gets the number of array elements
  47933. */
  47934. numberOfArrayElements: number;
  47935. /**
  47936. * Gets the number of faces
  47937. */
  47938. numberOfFaces: number;
  47939. /**
  47940. * Gets the number of mipmap levels
  47941. */
  47942. numberOfMipmapLevels: number;
  47943. /**
  47944. * Gets the bytes of key value data
  47945. */
  47946. bytesOfKeyValueData: number;
  47947. /**
  47948. * Gets the load type
  47949. */
  47950. loadType: number;
  47951. /**
  47952. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47953. */
  47954. isInvalid: boolean;
  47955. /**
  47956. * Creates a new KhronosTextureContainer
  47957. * @param arrayBuffer contents of the KTX container file
  47958. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47959. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47960. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47961. */
  47962. constructor(
  47963. /** contents of the KTX container file */
  47964. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47965. /**
  47966. * Uploads KTX content to a Babylon Texture.
  47967. * It is assumed that the texture has already been created & is currently bound
  47968. * @hidden
  47969. */
  47970. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47971. private _upload2DCompressedLevels;
  47972. }
  47973. }
  47974. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47975. import { Nullable } from "babylonjs/types";
  47976. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47977. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47978. /**
  47979. * Implementation of the KTX Texture Loader.
  47980. * @hidden
  47981. */
  47982. export class _KTXTextureLoader implements IInternalTextureLoader {
  47983. /**
  47984. * Defines wether the loader supports cascade loading the different faces.
  47985. */
  47986. readonly supportCascades: boolean;
  47987. /**
  47988. * This returns if the loader support the current file information.
  47989. * @param extension defines the file extension of the file being loaded
  47990. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47991. * @param fallback defines the fallback internal texture if any
  47992. * @param isBase64 defines whether the texture is encoded as a base64
  47993. * @param isBuffer defines whether the texture data are stored as a buffer
  47994. * @returns true if the loader can load the specified file
  47995. */
  47996. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47997. /**
  47998. * Transform the url before loading if required.
  47999. * @param rootUrl the url of the texture
  48000. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48001. * @returns the transformed texture
  48002. */
  48003. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48004. /**
  48005. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48006. * @param rootUrl the url of the texture
  48007. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48008. * @returns the fallback texture
  48009. */
  48010. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48011. /**
  48012. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48013. * @param data contains the texture data
  48014. * @param texture defines the BabylonJS internal texture
  48015. * @param createPolynomials will be true if polynomials have been requested
  48016. * @param onLoad defines the callback to trigger once the texture is ready
  48017. * @param onError defines the callback to trigger in case of error
  48018. */
  48019. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48020. /**
  48021. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48022. * @param data contains the texture data
  48023. * @param texture defines the BabylonJS internal texture
  48024. * @param callback defines the method to call once ready to upload
  48025. */
  48026. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48027. }
  48028. }
  48029. declare module "babylonjs/Helpers/sceneHelpers" {
  48030. import { Nullable } from "babylonjs/types";
  48031. import { Mesh } from "babylonjs/Meshes/mesh";
  48032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48033. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48034. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48035. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48036. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48037. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48038. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48039. import "babylonjs/Meshes/Builders/boxBuilder";
  48040. /** @hidden */
  48041. export var _forceSceneHelpersToBundle: boolean;
  48042. module "babylonjs/scene" {
  48043. interface Scene {
  48044. /**
  48045. * Creates a default light for the scene.
  48046. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48047. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48048. */
  48049. createDefaultLight(replace?: boolean): void;
  48050. /**
  48051. * Creates a default camera for the scene.
  48052. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48053. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48054. * @param replace has default false, when true replaces the active camera in the scene
  48055. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48056. */
  48057. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48058. /**
  48059. * Creates a default camera and a default light.
  48060. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48061. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48062. * @param replace has the default false, when true replaces the active camera/light in the scene
  48063. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48064. */
  48065. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48066. /**
  48067. * Creates a new sky box
  48068. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48069. * @param environmentTexture defines the texture to use as environment texture
  48070. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48071. * @param scale defines the overall scale of the skybox
  48072. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48073. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48074. * @returns a new mesh holding the sky box
  48075. */
  48076. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48077. /**
  48078. * Creates a new environment
  48079. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48080. * @param options defines the options you can use to configure the environment
  48081. * @returns the new EnvironmentHelper
  48082. */
  48083. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48084. /**
  48085. * Creates a new VREXperienceHelper
  48086. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48087. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48088. * @returns a new VREXperienceHelper
  48089. */
  48090. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48091. /**
  48092. * Creates a new XREXperienceHelper
  48093. * @see http://doc.babylonjs.com/how_to/webxr
  48094. * @returns a promise for a new XREXperienceHelper
  48095. */
  48096. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48097. }
  48098. }
  48099. }
  48100. declare module "babylonjs/Helpers/videoDome" {
  48101. import { Scene } from "babylonjs/scene";
  48102. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48103. import { Mesh } from "babylonjs/Meshes/mesh";
  48104. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48105. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48106. import "babylonjs/Meshes/Builders/sphereBuilder";
  48107. /**
  48108. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48109. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48110. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48111. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48112. */
  48113. export class VideoDome extends TransformNode {
  48114. /**
  48115. * Define the video source as a Monoscopic panoramic 360 video.
  48116. */
  48117. static readonly MODE_MONOSCOPIC: number;
  48118. /**
  48119. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48120. */
  48121. static readonly MODE_TOPBOTTOM: number;
  48122. /**
  48123. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48124. */
  48125. static readonly MODE_SIDEBYSIDE: number;
  48126. private _useDirectMapping;
  48127. /**
  48128. * The video texture being displayed on the sphere
  48129. */
  48130. protected _videoTexture: VideoTexture;
  48131. /**
  48132. * Gets the video texture being displayed on the sphere
  48133. */
  48134. readonly videoTexture: VideoTexture;
  48135. /**
  48136. * The skybox material
  48137. */
  48138. protected _material: BackgroundMaterial;
  48139. /**
  48140. * The surface used for the skybox
  48141. */
  48142. protected _mesh: Mesh;
  48143. /**
  48144. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48145. * Also see the options.resolution property.
  48146. */
  48147. fovMultiplier: number;
  48148. private _videoMode;
  48149. /**
  48150. * Gets or set the current video mode for the video. It can be:
  48151. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48152. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48153. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48154. */
  48155. videoMode: number;
  48156. /**
  48157. * Oberserver used in Stereoscopic VR Mode.
  48158. */
  48159. private _onBeforeCameraRenderObserver;
  48160. /**
  48161. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48162. * @param name Element's name, child elements will append suffixes for their own names.
  48163. * @param urlsOrVideo defines the url(s) or the video element to use
  48164. * @param options An object containing optional or exposed sub element properties
  48165. */
  48166. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48167. resolution?: number;
  48168. clickToPlay?: boolean;
  48169. autoPlay?: boolean;
  48170. loop?: boolean;
  48171. size?: number;
  48172. poster?: string;
  48173. faceForward?: boolean;
  48174. useDirectMapping?: boolean;
  48175. }, scene: Scene);
  48176. private _changeVideoMode;
  48177. /**
  48178. * Releases resources associated with this node.
  48179. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48180. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48181. */
  48182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48183. }
  48184. }
  48185. declare module "babylonjs/Helpers/index" {
  48186. export * from "babylonjs/Helpers/environmentHelper";
  48187. export * from "babylonjs/Helpers/photoDome";
  48188. export * from "babylonjs/Helpers/sceneHelpers";
  48189. export * from "babylonjs/Helpers/videoDome";
  48190. }
  48191. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48192. import { PerfCounter } from "babylonjs/Misc/tools";
  48193. import { IDisposable } from "babylonjs/scene";
  48194. import { Engine } from "babylonjs/Engines/engine";
  48195. /**
  48196. * This class can be used to get instrumentation data from a Babylon engine
  48197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48198. */
  48199. export class EngineInstrumentation implements IDisposable {
  48200. /**
  48201. * Define the instrumented engine.
  48202. */
  48203. engine: Engine;
  48204. private _captureGPUFrameTime;
  48205. private _gpuFrameTimeToken;
  48206. private _gpuFrameTime;
  48207. private _captureShaderCompilationTime;
  48208. private _shaderCompilationTime;
  48209. private _onBeginFrameObserver;
  48210. private _onEndFrameObserver;
  48211. private _onBeforeShaderCompilationObserver;
  48212. private _onAfterShaderCompilationObserver;
  48213. /**
  48214. * Gets the perf counter used for GPU frame time
  48215. */
  48216. readonly gpuFrameTimeCounter: PerfCounter;
  48217. /**
  48218. * Gets the GPU frame time capture status
  48219. */
  48220. /**
  48221. * Enable or disable the GPU frame time capture
  48222. */
  48223. captureGPUFrameTime: boolean;
  48224. /**
  48225. * Gets the perf counter used for shader compilation time
  48226. */
  48227. readonly shaderCompilationTimeCounter: PerfCounter;
  48228. /**
  48229. * Gets the shader compilation time capture status
  48230. */
  48231. /**
  48232. * Enable or disable the shader compilation time capture
  48233. */
  48234. captureShaderCompilationTime: boolean;
  48235. /**
  48236. * Instantiates a new engine instrumentation.
  48237. * This class can be used to get instrumentation data from a Babylon engine
  48238. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48239. * @param engine Defines the engine to instrument
  48240. */
  48241. constructor(
  48242. /**
  48243. * Define the instrumented engine.
  48244. */
  48245. engine: Engine);
  48246. /**
  48247. * Dispose and release associated resources.
  48248. */
  48249. dispose(): void;
  48250. }
  48251. }
  48252. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48253. import { PerfCounter } from "babylonjs/Misc/tools";
  48254. import { Scene, IDisposable } from "babylonjs/scene";
  48255. /**
  48256. * This class can be used to get instrumentation data from a Babylon engine
  48257. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48258. */
  48259. export class SceneInstrumentation implements IDisposable {
  48260. /**
  48261. * Defines the scene to instrument
  48262. */
  48263. scene: Scene;
  48264. private _captureActiveMeshesEvaluationTime;
  48265. private _activeMeshesEvaluationTime;
  48266. private _captureRenderTargetsRenderTime;
  48267. private _renderTargetsRenderTime;
  48268. private _captureFrameTime;
  48269. private _frameTime;
  48270. private _captureRenderTime;
  48271. private _renderTime;
  48272. private _captureInterFrameTime;
  48273. private _interFrameTime;
  48274. private _captureParticlesRenderTime;
  48275. private _particlesRenderTime;
  48276. private _captureSpritesRenderTime;
  48277. private _spritesRenderTime;
  48278. private _capturePhysicsTime;
  48279. private _physicsTime;
  48280. private _captureAnimationsTime;
  48281. private _animationsTime;
  48282. private _captureCameraRenderTime;
  48283. private _cameraRenderTime;
  48284. private _onBeforeActiveMeshesEvaluationObserver;
  48285. private _onAfterActiveMeshesEvaluationObserver;
  48286. private _onBeforeRenderTargetsRenderObserver;
  48287. private _onAfterRenderTargetsRenderObserver;
  48288. private _onAfterRenderObserver;
  48289. private _onBeforeDrawPhaseObserver;
  48290. private _onAfterDrawPhaseObserver;
  48291. private _onBeforeAnimationsObserver;
  48292. private _onBeforeParticlesRenderingObserver;
  48293. private _onAfterParticlesRenderingObserver;
  48294. private _onBeforeSpritesRenderingObserver;
  48295. private _onAfterSpritesRenderingObserver;
  48296. private _onBeforePhysicsObserver;
  48297. private _onAfterPhysicsObserver;
  48298. private _onAfterAnimationsObserver;
  48299. private _onBeforeCameraRenderObserver;
  48300. private _onAfterCameraRenderObserver;
  48301. /**
  48302. * Gets the perf counter used for active meshes evaluation time
  48303. */
  48304. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48305. /**
  48306. * Gets the active meshes evaluation time capture status
  48307. */
  48308. /**
  48309. * Enable or disable the active meshes evaluation time capture
  48310. */
  48311. captureActiveMeshesEvaluationTime: boolean;
  48312. /**
  48313. * Gets the perf counter used for render targets render time
  48314. */
  48315. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48316. /**
  48317. * Gets the render targets render time capture status
  48318. */
  48319. /**
  48320. * Enable or disable the render targets render time capture
  48321. */
  48322. captureRenderTargetsRenderTime: boolean;
  48323. /**
  48324. * Gets the perf counter used for particles render time
  48325. */
  48326. readonly particlesRenderTimeCounter: PerfCounter;
  48327. /**
  48328. * Gets the particles render time capture status
  48329. */
  48330. /**
  48331. * Enable or disable the particles render time capture
  48332. */
  48333. captureParticlesRenderTime: boolean;
  48334. /**
  48335. * Gets the perf counter used for sprites render time
  48336. */
  48337. readonly spritesRenderTimeCounter: PerfCounter;
  48338. /**
  48339. * Gets the sprites render time capture status
  48340. */
  48341. /**
  48342. * Enable or disable the sprites render time capture
  48343. */
  48344. captureSpritesRenderTime: boolean;
  48345. /**
  48346. * Gets the perf counter used for physics time
  48347. */
  48348. readonly physicsTimeCounter: PerfCounter;
  48349. /**
  48350. * Gets the physics time capture status
  48351. */
  48352. /**
  48353. * Enable or disable the physics time capture
  48354. */
  48355. capturePhysicsTime: boolean;
  48356. /**
  48357. * Gets the perf counter used for animations time
  48358. */
  48359. readonly animationsTimeCounter: PerfCounter;
  48360. /**
  48361. * Gets the animations time capture status
  48362. */
  48363. /**
  48364. * Enable or disable the animations time capture
  48365. */
  48366. captureAnimationsTime: boolean;
  48367. /**
  48368. * Gets the perf counter used for frame time capture
  48369. */
  48370. readonly frameTimeCounter: PerfCounter;
  48371. /**
  48372. * Gets the frame time capture status
  48373. */
  48374. /**
  48375. * Enable or disable the frame time capture
  48376. */
  48377. captureFrameTime: boolean;
  48378. /**
  48379. * Gets the perf counter used for inter-frames time capture
  48380. */
  48381. readonly interFrameTimeCounter: PerfCounter;
  48382. /**
  48383. * Gets the inter-frames time capture status
  48384. */
  48385. /**
  48386. * Enable or disable the inter-frames time capture
  48387. */
  48388. captureInterFrameTime: boolean;
  48389. /**
  48390. * Gets the perf counter used for render time capture
  48391. */
  48392. readonly renderTimeCounter: PerfCounter;
  48393. /**
  48394. * Gets the render time capture status
  48395. */
  48396. /**
  48397. * Enable or disable the render time capture
  48398. */
  48399. captureRenderTime: boolean;
  48400. /**
  48401. * Gets the perf counter used for camera render time capture
  48402. */
  48403. readonly cameraRenderTimeCounter: PerfCounter;
  48404. /**
  48405. * Gets the camera render time capture status
  48406. */
  48407. /**
  48408. * Enable or disable the camera render time capture
  48409. */
  48410. captureCameraRenderTime: boolean;
  48411. /**
  48412. * Gets the perf counter used for draw calls
  48413. */
  48414. readonly drawCallsCounter: PerfCounter;
  48415. /**
  48416. * Instantiates a new scene instrumentation.
  48417. * This class can be used to get instrumentation data from a Babylon engine
  48418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48419. * @param scene Defines the scene to instrument
  48420. */
  48421. constructor(
  48422. /**
  48423. * Defines the scene to instrument
  48424. */
  48425. scene: Scene);
  48426. /**
  48427. * Dispose and release associated resources.
  48428. */
  48429. dispose(): void;
  48430. }
  48431. }
  48432. declare module "babylonjs/Instrumentation/index" {
  48433. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48434. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48435. export * from "babylonjs/Instrumentation/timeToken";
  48436. }
  48437. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48438. /** @hidden */
  48439. export var glowMapGenerationPixelShader: {
  48440. name: string;
  48441. shader: string;
  48442. };
  48443. }
  48444. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48445. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48446. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48447. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48448. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48449. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48450. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48451. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48452. /** @hidden */
  48453. export var glowMapGenerationVertexShader: {
  48454. name: string;
  48455. shader: string;
  48456. };
  48457. }
  48458. declare module "babylonjs/Layers/effectLayer" {
  48459. import { Observable } from "babylonjs/Misc/observable";
  48460. import { Nullable } from "babylonjs/types";
  48461. import { Camera } from "babylonjs/Cameras/camera";
  48462. import { Scene } from "babylonjs/scene";
  48463. import { Color4, ISize } from "babylonjs/Maths/math";
  48464. import { Engine } from "babylonjs/Engines/engine";
  48465. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48467. import { Mesh } from "babylonjs/Meshes/mesh";
  48468. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48470. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48471. import { Effect } from "babylonjs/Materials/effect";
  48472. import { Material } from "babylonjs/Materials/material";
  48473. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48474. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48475. /**
  48476. * Effect layer options. This helps customizing the behaviour
  48477. * of the effect layer.
  48478. */
  48479. export interface IEffectLayerOptions {
  48480. /**
  48481. * Multiplication factor apply to the canvas size to compute the render target size
  48482. * used to generated the objects (the smaller the faster).
  48483. */
  48484. mainTextureRatio: number;
  48485. /**
  48486. * Enforces a fixed size texture to ensure effect stability across devices.
  48487. */
  48488. mainTextureFixedSize?: number;
  48489. /**
  48490. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48491. */
  48492. alphaBlendingMode: number;
  48493. /**
  48494. * The camera attached to the layer.
  48495. */
  48496. camera: Nullable<Camera>;
  48497. /**
  48498. * The rendering group to draw the layer in.
  48499. */
  48500. renderingGroupId: number;
  48501. }
  48502. /**
  48503. * The effect layer Helps adding post process effect blended with the main pass.
  48504. *
  48505. * This can be for instance use to generate glow or higlight effects on the scene.
  48506. *
  48507. * The effect layer class can not be used directly and is intented to inherited from to be
  48508. * customized per effects.
  48509. */
  48510. export abstract class EffectLayer {
  48511. private _vertexBuffers;
  48512. private _indexBuffer;
  48513. private _cachedDefines;
  48514. private _effectLayerMapGenerationEffect;
  48515. private _effectLayerOptions;
  48516. private _mergeEffect;
  48517. protected _scene: Scene;
  48518. protected _engine: Engine;
  48519. protected _maxSize: number;
  48520. protected _mainTextureDesiredSize: ISize;
  48521. protected _mainTexture: RenderTargetTexture;
  48522. protected _shouldRender: boolean;
  48523. protected _postProcesses: PostProcess[];
  48524. protected _textures: BaseTexture[];
  48525. protected _emissiveTextureAndColor: {
  48526. texture: Nullable<BaseTexture>;
  48527. color: Color4;
  48528. };
  48529. /**
  48530. * The name of the layer
  48531. */
  48532. name: string;
  48533. /**
  48534. * The clear color of the texture used to generate the glow map.
  48535. */
  48536. neutralColor: Color4;
  48537. /**
  48538. * Specifies wether the highlight layer is enabled or not.
  48539. */
  48540. isEnabled: boolean;
  48541. /**
  48542. * Gets the camera attached to the layer.
  48543. */
  48544. readonly camera: Nullable<Camera>;
  48545. /**
  48546. * Gets the rendering group id the layer should render in.
  48547. */
  48548. readonly renderingGroupId: number;
  48549. /**
  48550. * An event triggered when the effect layer has been disposed.
  48551. */
  48552. onDisposeObservable: Observable<EffectLayer>;
  48553. /**
  48554. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48555. */
  48556. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48557. /**
  48558. * An event triggered when the generated texture is being merged in the scene.
  48559. */
  48560. onBeforeComposeObservable: Observable<EffectLayer>;
  48561. /**
  48562. * An event triggered when the generated texture has been merged in the scene.
  48563. */
  48564. onAfterComposeObservable: Observable<EffectLayer>;
  48565. /**
  48566. * An event triggered when the efffect layer changes its size.
  48567. */
  48568. onSizeChangedObservable: Observable<EffectLayer>;
  48569. /** @hidden */
  48570. static _SceneComponentInitialization: (scene: Scene) => void;
  48571. /**
  48572. * Instantiates a new effect Layer and references it in the scene.
  48573. * @param name The name of the layer
  48574. * @param scene The scene to use the layer in
  48575. */
  48576. constructor(
  48577. /** The Friendly of the effect in the scene */
  48578. name: string, scene: Scene);
  48579. /**
  48580. * Get the effect name of the layer.
  48581. * @return The effect name
  48582. */
  48583. abstract getEffectName(): string;
  48584. /**
  48585. * Checks for the readiness of the element composing the layer.
  48586. * @param subMesh the mesh to check for
  48587. * @param useInstances specify wether or not to use instances to render the mesh
  48588. * @return true if ready otherwise, false
  48589. */
  48590. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48591. /**
  48592. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48593. * @returns true if the effect requires stencil during the main canvas render pass.
  48594. */
  48595. abstract needStencil(): boolean;
  48596. /**
  48597. * Create the merge effect. This is the shader use to blit the information back
  48598. * to the main canvas at the end of the scene rendering.
  48599. * @returns The effect containing the shader used to merge the effect on the main canvas
  48600. */
  48601. protected abstract _createMergeEffect(): Effect;
  48602. /**
  48603. * Creates the render target textures and post processes used in the effect layer.
  48604. */
  48605. protected abstract _createTextureAndPostProcesses(): void;
  48606. /**
  48607. * Implementation specific of rendering the generating effect on the main canvas.
  48608. * @param effect The effect used to render through
  48609. */
  48610. protected abstract _internalRender(effect: Effect): void;
  48611. /**
  48612. * Sets the required values for both the emissive texture and and the main color.
  48613. */
  48614. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48615. /**
  48616. * Free any resources and references associated to a mesh.
  48617. * Internal use
  48618. * @param mesh The mesh to free.
  48619. */
  48620. abstract _disposeMesh(mesh: Mesh): void;
  48621. /**
  48622. * Serializes this layer (Glow or Highlight for example)
  48623. * @returns a serialized layer object
  48624. */
  48625. abstract serialize?(): any;
  48626. /**
  48627. * Initializes the effect layer with the required options.
  48628. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48629. */
  48630. protected _init(options: Partial<IEffectLayerOptions>): void;
  48631. /**
  48632. * Generates the index buffer of the full screen quad blending to the main canvas.
  48633. */
  48634. private _generateIndexBuffer;
  48635. /**
  48636. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48637. */
  48638. private _genrateVertexBuffer;
  48639. /**
  48640. * Sets the main texture desired size which is the closest power of two
  48641. * of the engine canvas size.
  48642. */
  48643. private _setMainTextureSize;
  48644. /**
  48645. * Creates the main texture for the effect layer.
  48646. */
  48647. protected _createMainTexture(): void;
  48648. /**
  48649. * Adds specific effects defines.
  48650. * @param defines The defines to add specifics to.
  48651. */
  48652. protected _addCustomEffectDefines(defines: string[]): void;
  48653. /**
  48654. * Checks for the readiness of the element composing the layer.
  48655. * @param subMesh the mesh to check for
  48656. * @param useInstances specify wether or not to use instances to render the mesh
  48657. * @param emissiveTexture the associated emissive texture used to generate the glow
  48658. * @return true if ready otherwise, false
  48659. */
  48660. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48661. /**
  48662. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48663. */
  48664. render(): void;
  48665. /**
  48666. * Determine if a given mesh will be used in the current effect.
  48667. * @param mesh mesh to test
  48668. * @returns true if the mesh will be used
  48669. */
  48670. hasMesh(mesh: AbstractMesh): boolean;
  48671. /**
  48672. * Returns true if the layer contains information to display, otherwise false.
  48673. * @returns true if the glow layer should be rendered
  48674. */
  48675. shouldRender(): boolean;
  48676. /**
  48677. * Returns true if the mesh should render, otherwise false.
  48678. * @param mesh The mesh to render
  48679. * @returns true if it should render otherwise false
  48680. */
  48681. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48682. /**
  48683. * Returns true if the mesh can be rendered, otherwise false.
  48684. * @param mesh The mesh to render
  48685. * @param material The material used on the mesh
  48686. * @returns true if it can be rendered otherwise false
  48687. */
  48688. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48689. /**
  48690. * Returns true if the mesh should render, otherwise false.
  48691. * @param mesh The mesh to render
  48692. * @returns true if it should render otherwise false
  48693. */
  48694. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48695. /**
  48696. * Renders the submesh passed in parameter to the generation map.
  48697. */
  48698. protected _renderSubMesh(subMesh: SubMesh): void;
  48699. /**
  48700. * Rebuild the required buffers.
  48701. * @hidden Internal use only.
  48702. */
  48703. _rebuild(): void;
  48704. /**
  48705. * Dispose only the render target textures and post process.
  48706. */
  48707. private _disposeTextureAndPostProcesses;
  48708. /**
  48709. * Dispose the highlight layer and free resources.
  48710. */
  48711. dispose(): void;
  48712. /**
  48713. * Gets the class name of the effect layer
  48714. * @returns the string with the class name of the effect layer
  48715. */
  48716. getClassName(): string;
  48717. /**
  48718. * Creates an effect layer from parsed effect layer data
  48719. * @param parsedEffectLayer defines effect layer data
  48720. * @param scene defines the current scene
  48721. * @param rootUrl defines the root URL containing the effect layer information
  48722. * @returns a parsed effect Layer
  48723. */
  48724. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48725. }
  48726. }
  48727. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48728. import { Scene } from "babylonjs/scene";
  48729. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48730. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48731. import { AbstractScene } from "babylonjs/abstractScene";
  48732. module "babylonjs/abstractScene" {
  48733. interface AbstractScene {
  48734. /**
  48735. * The list of effect layers (highlights/glow) added to the scene
  48736. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48737. * @see http://doc.babylonjs.com/how_to/glow_layer
  48738. */
  48739. effectLayers: Array<EffectLayer>;
  48740. /**
  48741. * Removes the given effect layer from this scene.
  48742. * @param toRemove defines the effect layer to remove
  48743. * @returns the index of the removed effect layer
  48744. */
  48745. removeEffectLayer(toRemove: EffectLayer): number;
  48746. /**
  48747. * Adds the given effect layer to this scene
  48748. * @param newEffectLayer defines the effect layer to add
  48749. */
  48750. addEffectLayer(newEffectLayer: EffectLayer): void;
  48751. }
  48752. }
  48753. /**
  48754. * Defines the layer scene component responsible to manage any effect layers
  48755. * in a given scene.
  48756. */
  48757. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48758. /**
  48759. * The component name helpfull to identify the component in the list of scene components.
  48760. */
  48761. readonly name: string;
  48762. /**
  48763. * The scene the component belongs to.
  48764. */
  48765. scene: Scene;
  48766. private _engine;
  48767. private _renderEffects;
  48768. private _needStencil;
  48769. private _previousStencilState;
  48770. /**
  48771. * Creates a new instance of the component for the given scene
  48772. * @param scene Defines the scene to register the component in
  48773. */
  48774. constructor(scene: Scene);
  48775. /**
  48776. * Registers the component in a given scene
  48777. */
  48778. register(): void;
  48779. /**
  48780. * Rebuilds the elements related to this component in case of
  48781. * context lost for instance.
  48782. */
  48783. rebuild(): void;
  48784. /**
  48785. * Serializes the component data to the specified json object
  48786. * @param serializationObject The object to serialize to
  48787. */
  48788. serialize(serializationObject: any): void;
  48789. /**
  48790. * Adds all the element from the container to the scene
  48791. * @param container the container holding the elements
  48792. */
  48793. addFromContainer(container: AbstractScene): void;
  48794. /**
  48795. * Removes all the elements in the container from the scene
  48796. * @param container contains the elements to remove
  48797. * @param dispose if the removed element should be disposed (default: false)
  48798. */
  48799. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48800. /**
  48801. * Disposes the component and the associated ressources.
  48802. */
  48803. dispose(): void;
  48804. private _isReadyForMesh;
  48805. private _renderMainTexture;
  48806. private _setStencil;
  48807. private _setStencilBack;
  48808. private _draw;
  48809. private _drawCamera;
  48810. private _drawRenderingGroup;
  48811. }
  48812. }
  48813. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48814. /** @hidden */
  48815. export var glowMapMergePixelShader: {
  48816. name: string;
  48817. shader: string;
  48818. };
  48819. }
  48820. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48821. /** @hidden */
  48822. export var glowMapMergeVertexShader: {
  48823. name: string;
  48824. shader: string;
  48825. };
  48826. }
  48827. declare module "babylonjs/Layers/glowLayer" {
  48828. import { Nullable } from "babylonjs/types";
  48829. import { Camera } from "babylonjs/Cameras/camera";
  48830. import { Scene } from "babylonjs/scene";
  48831. import { Color4 } from "babylonjs/Maths/math";
  48832. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48834. import { Mesh } from "babylonjs/Meshes/mesh";
  48835. import { Texture } from "babylonjs/Materials/Textures/texture";
  48836. import { Effect } from "babylonjs/Materials/effect";
  48837. import { Material } from "babylonjs/Materials/material";
  48838. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48839. import "babylonjs/Shaders/glowMapMerge.fragment";
  48840. import "babylonjs/Shaders/glowMapMerge.vertex";
  48841. import "babylonjs/Layers/effectLayerSceneComponent";
  48842. module "babylonjs/abstractScene" {
  48843. interface AbstractScene {
  48844. /**
  48845. * Return a the first highlight layer of the scene with a given name.
  48846. * @param name The name of the highlight layer to look for.
  48847. * @return The highlight layer if found otherwise null.
  48848. */
  48849. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48850. }
  48851. }
  48852. /**
  48853. * Glow layer options. This helps customizing the behaviour
  48854. * of the glow layer.
  48855. */
  48856. export interface IGlowLayerOptions {
  48857. /**
  48858. * Multiplication factor apply to the canvas size to compute the render target size
  48859. * used to generated the glowing objects (the smaller the faster).
  48860. */
  48861. mainTextureRatio: number;
  48862. /**
  48863. * Enforces a fixed size texture to ensure resize independant blur.
  48864. */
  48865. mainTextureFixedSize?: number;
  48866. /**
  48867. * How big is the kernel of the blur texture.
  48868. */
  48869. blurKernelSize: number;
  48870. /**
  48871. * The camera attached to the layer.
  48872. */
  48873. camera: Nullable<Camera>;
  48874. /**
  48875. * Enable MSAA by chosing the number of samples.
  48876. */
  48877. mainTextureSamples?: number;
  48878. /**
  48879. * The rendering group to draw the layer in.
  48880. */
  48881. renderingGroupId: number;
  48882. }
  48883. /**
  48884. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48885. *
  48886. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48887. * glowy meshes to your scene.
  48888. *
  48889. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48890. */
  48891. export class GlowLayer extends EffectLayer {
  48892. /**
  48893. * Effect Name of the layer.
  48894. */
  48895. static readonly EffectName: string;
  48896. /**
  48897. * The default blur kernel size used for the glow.
  48898. */
  48899. static DefaultBlurKernelSize: number;
  48900. /**
  48901. * The default texture size ratio used for the glow.
  48902. */
  48903. static DefaultTextureRatio: number;
  48904. /**
  48905. * Sets the kernel size of the blur.
  48906. */
  48907. /**
  48908. * Gets the kernel size of the blur.
  48909. */
  48910. blurKernelSize: number;
  48911. /**
  48912. * Sets the glow intensity.
  48913. */
  48914. /**
  48915. * Gets the glow intensity.
  48916. */
  48917. intensity: number;
  48918. private _options;
  48919. private _intensity;
  48920. private _horizontalBlurPostprocess1;
  48921. private _verticalBlurPostprocess1;
  48922. private _horizontalBlurPostprocess2;
  48923. private _verticalBlurPostprocess2;
  48924. private _blurTexture1;
  48925. private _blurTexture2;
  48926. private _postProcesses1;
  48927. private _postProcesses2;
  48928. private _includedOnlyMeshes;
  48929. private _excludedMeshes;
  48930. /**
  48931. * Callback used to let the user override the color selection on a per mesh basis
  48932. */
  48933. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48934. /**
  48935. * Callback used to let the user override the texture selection on a per mesh basis
  48936. */
  48937. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48938. /**
  48939. * Instantiates a new glow Layer and references it to the scene.
  48940. * @param name The name of the layer
  48941. * @param scene The scene to use the layer in
  48942. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48943. */
  48944. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48945. /**
  48946. * Get the effect name of the layer.
  48947. * @return The effect name
  48948. */
  48949. getEffectName(): string;
  48950. /**
  48951. * Create the merge effect. This is the shader use to blit the information back
  48952. * to the main canvas at the end of the scene rendering.
  48953. */
  48954. protected _createMergeEffect(): Effect;
  48955. /**
  48956. * Creates the render target textures and post processes used in the glow layer.
  48957. */
  48958. protected _createTextureAndPostProcesses(): void;
  48959. /**
  48960. * Checks for the readiness of the element composing the layer.
  48961. * @param subMesh the mesh to check for
  48962. * @param useInstances specify wether or not to use instances to render the mesh
  48963. * @param emissiveTexture the associated emissive texture used to generate the glow
  48964. * @return true if ready otherwise, false
  48965. */
  48966. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48967. /**
  48968. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48969. */
  48970. needStencil(): boolean;
  48971. /**
  48972. * Returns true if the mesh can be rendered, otherwise false.
  48973. * @param mesh The mesh to render
  48974. * @param material The material used on the mesh
  48975. * @returns true if it can be rendered otherwise false
  48976. */
  48977. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48978. /**
  48979. * Implementation specific of rendering the generating effect on the main canvas.
  48980. * @param effect The effect used to render through
  48981. */
  48982. protected _internalRender(effect: Effect): void;
  48983. /**
  48984. * Sets the required values for both the emissive texture and and the main color.
  48985. */
  48986. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48987. /**
  48988. * Returns true if the mesh should render, otherwise false.
  48989. * @param mesh The mesh to render
  48990. * @returns true if it should render otherwise false
  48991. */
  48992. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48993. /**
  48994. * Adds specific effects defines.
  48995. * @param defines The defines to add specifics to.
  48996. */
  48997. protected _addCustomEffectDefines(defines: string[]): void;
  48998. /**
  48999. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49000. * @param mesh The mesh to exclude from the glow layer
  49001. */
  49002. addExcludedMesh(mesh: Mesh): void;
  49003. /**
  49004. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49005. * @param mesh The mesh to remove
  49006. */
  49007. removeExcludedMesh(mesh: Mesh): void;
  49008. /**
  49009. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49010. * @param mesh The mesh to include in the glow layer
  49011. */
  49012. addIncludedOnlyMesh(mesh: Mesh): void;
  49013. /**
  49014. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49015. * @param mesh The mesh to remove
  49016. */
  49017. removeIncludedOnlyMesh(mesh: Mesh): void;
  49018. /**
  49019. * Determine if a given mesh will be used in the glow layer
  49020. * @param mesh The mesh to test
  49021. * @returns true if the mesh will be highlighted by the current glow layer
  49022. */
  49023. hasMesh(mesh: AbstractMesh): boolean;
  49024. /**
  49025. * Free any resources and references associated to a mesh.
  49026. * Internal use
  49027. * @param mesh The mesh to free.
  49028. * @hidden
  49029. */
  49030. _disposeMesh(mesh: Mesh): void;
  49031. /**
  49032. * Gets the class name of the effect layer
  49033. * @returns the string with the class name of the effect layer
  49034. */
  49035. getClassName(): string;
  49036. /**
  49037. * Serializes this glow layer
  49038. * @returns a serialized glow layer object
  49039. */
  49040. serialize(): any;
  49041. /**
  49042. * Creates a Glow Layer from parsed glow layer data
  49043. * @param parsedGlowLayer defines glow layer data
  49044. * @param scene defines the current scene
  49045. * @param rootUrl defines the root URL containing the glow layer information
  49046. * @returns a parsed Glow Layer
  49047. */
  49048. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49049. }
  49050. }
  49051. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49052. /** @hidden */
  49053. export var glowBlurPostProcessPixelShader: {
  49054. name: string;
  49055. shader: string;
  49056. };
  49057. }
  49058. declare module "babylonjs/Layers/highlightLayer" {
  49059. import { Observable } from "babylonjs/Misc/observable";
  49060. import { Nullable } from "babylonjs/types";
  49061. import { Camera } from "babylonjs/Cameras/camera";
  49062. import { Scene } from "babylonjs/scene";
  49063. import { Color3, Color4 } from "babylonjs/Maths/math";
  49064. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49066. import { Mesh } from "babylonjs/Meshes/mesh";
  49067. import { Effect } from "babylonjs/Materials/effect";
  49068. import { Material } from "babylonjs/Materials/material";
  49069. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49070. import "babylonjs/Shaders/glowMapMerge.fragment";
  49071. import "babylonjs/Shaders/glowMapMerge.vertex";
  49072. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49073. module "babylonjs/abstractScene" {
  49074. interface AbstractScene {
  49075. /**
  49076. * Return a the first highlight layer of the scene with a given name.
  49077. * @param name The name of the highlight layer to look for.
  49078. * @return The highlight layer if found otherwise null.
  49079. */
  49080. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49081. }
  49082. }
  49083. /**
  49084. * Highlight layer options. This helps customizing the behaviour
  49085. * of the highlight layer.
  49086. */
  49087. export interface IHighlightLayerOptions {
  49088. /**
  49089. * Multiplication factor apply to the canvas size to compute the render target size
  49090. * used to generated the glowing objects (the smaller the faster).
  49091. */
  49092. mainTextureRatio: number;
  49093. /**
  49094. * Enforces a fixed size texture to ensure resize independant blur.
  49095. */
  49096. mainTextureFixedSize?: number;
  49097. /**
  49098. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49099. * of the picture to blur (the smaller the faster).
  49100. */
  49101. blurTextureSizeRatio: number;
  49102. /**
  49103. * How big in texel of the blur texture is the vertical blur.
  49104. */
  49105. blurVerticalSize: number;
  49106. /**
  49107. * How big in texel of the blur texture is the horizontal blur.
  49108. */
  49109. blurHorizontalSize: number;
  49110. /**
  49111. * Alpha blending mode used to apply the blur. Default is combine.
  49112. */
  49113. alphaBlendingMode: number;
  49114. /**
  49115. * The camera attached to the layer.
  49116. */
  49117. camera: Nullable<Camera>;
  49118. /**
  49119. * Should we display highlight as a solid stroke?
  49120. */
  49121. isStroke?: boolean;
  49122. /**
  49123. * The rendering group to draw the layer in.
  49124. */
  49125. renderingGroupId: number;
  49126. }
  49127. /**
  49128. * The highlight layer Helps adding a glow effect around a mesh.
  49129. *
  49130. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49131. * glowy meshes to your scene.
  49132. *
  49133. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49134. */
  49135. export class HighlightLayer extends EffectLayer {
  49136. name: string;
  49137. /**
  49138. * Effect Name of the highlight layer.
  49139. */
  49140. static readonly EffectName: string;
  49141. /**
  49142. * The neutral color used during the preparation of the glow effect.
  49143. * This is black by default as the blend operation is a blend operation.
  49144. */
  49145. static NeutralColor: Color4;
  49146. /**
  49147. * Stencil value used for glowing meshes.
  49148. */
  49149. static GlowingMeshStencilReference: number;
  49150. /**
  49151. * Stencil value used for the other meshes in the scene.
  49152. */
  49153. static NormalMeshStencilReference: number;
  49154. /**
  49155. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49156. */
  49157. innerGlow: boolean;
  49158. /**
  49159. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49160. */
  49161. outerGlow: boolean;
  49162. /**
  49163. * Specifies the horizontal size of the blur.
  49164. */
  49165. /**
  49166. * Gets the horizontal size of the blur.
  49167. */
  49168. blurHorizontalSize: number;
  49169. /**
  49170. * Specifies the vertical size of the blur.
  49171. */
  49172. /**
  49173. * Gets the vertical size of the blur.
  49174. */
  49175. blurVerticalSize: number;
  49176. /**
  49177. * An event triggered when the highlight layer is being blurred.
  49178. */
  49179. onBeforeBlurObservable: Observable<HighlightLayer>;
  49180. /**
  49181. * An event triggered when the highlight layer has been blurred.
  49182. */
  49183. onAfterBlurObservable: Observable<HighlightLayer>;
  49184. private _instanceGlowingMeshStencilReference;
  49185. private _options;
  49186. private _downSamplePostprocess;
  49187. private _horizontalBlurPostprocess;
  49188. private _verticalBlurPostprocess;
  49189. private _blurTexture;
  49190. private _meshes;
  49191. private _excludedMeshes;
  49192. /**
  49193. * Instantiates a new highlight Layer and references it to the scene..
  49194. * @param name The name of the layer
  49195. * @param scene The scene to use the layer in
  49196. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49197. */
  49198. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49199. /**
  49200. * Get the effect name of the layer.
  49201. * @return The effect name
  49202. */
  49203. getEffectName(): string;
  49204. /**
  49205. * Create the merge effect. This is the shader use to blit the information back
  49206. * to the main canvas at the end of the scene rendering.
  49207. */
  49208. protected _createMergeEffect(): Effect;
  49209. /**
  49210. * Creates the render target textures and post processes used in the highlight layer.
  49211. */
  49212. protected _createTextureAndPostProcesses(): void;
  49213. /**
  49214. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49215. */
  49216. needStencil(): boolean;
  49217. /**
  49218. * Checks for the readiness of the element composing the layer.
  49219. * @param subMesh the mesh to check for
  49220. * @param useInstances specify wether or not to use instances to render the mesh
  49221. * @param emissiveTexture the associated emissive texture used to generate the glow
  49222. * @return true if ready otherwise, false
  49223. */
  49224. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49225. /**
  49226. * Implementation specific of rendering the generating effect on the main canvas.
  49227. * @param effect The effect used to render through
  49228. */
  49229. protected _internalRender(effect: Effect): void;
  49230. /**
  49231. * Returns true if the layer contains information to display, otherwise false.
  49232. */
  49233. shouldRender(): boolean;
  49234. /**
  49235. * Returns true if the mesh should render, otherwise false.
  49236. * @param mesh The mesh to render
  49237. * @returns true if it should render otherwise false
  49238. */
  49239. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49240. /**
  49241. * Sets the required values for both the emissive texture and and the main color.
  49242. */
  49243. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49244. /**
  49245. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49246. * @param mesh The mesh to exclude from the highlight layer
  49247. */
  49248. addExcludedMesh(mesh: Mesh): void;
  49249. /**
  49250. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49251. * @param mesh The mesh to highlight
  49252. */
  49253. removeExcludedMesh(mesh: Mesh): void;
  49254. /**
  49255. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49256. * @param mesh mesh to test
  49257. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49258. */
  49259. hasMesh(mesh: AbstractMesh): boolean;
  49260. /**
  49261. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49262. * @param mesh The mesh to highlight
  49263. * @param color The color of the highlight
  49264. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49265. */
  49266. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49267. /**
  49268. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49269. * @param mesh The mesh to highlight
  49270. */
  49271. removeMesh(mesh: Mesh): void;
  49272. /**
  49273. * Force the stencil to the normal expected value for none glowing parts
  49274. */
  49275. private _defaultStencilReference;
  49276. /**
  49277. * Free any resources and references associated to a mesh.
  49278. * Internal use
  49279. * @param mesh The mesh to free.
  49280. * @hidden
  49281. */
  49282. _disposeMesh(mesh: Mesh): void;
  49283. /**
  49284. * Dispose the highlight layer and free resources.
  49285. */
  49286. dispose(): void;
  49287. /**
  49288. * Gets the class name of the effect layer
  49289. * @returns the string with the class name of the effect layer
  49290. */
  49291. getClassName(): string;
  49292. /**
  49293. * Serializes this Highlight layer
  49294. * @returns a serialized Highlight layer object
  49295. */
  49296. serialize(): any;
  49297. /**
  49298. * Creates a Highlight layer from parsed Highlight layer data
  49299. * @param parsedHightlightLayer defines the Highlight layer data
  49300. * @param scene defines the current scene
  49301. * @param rootUrl defines the root URL containing the Highlight layer information
  49302. * @returns a parsed Highlight layer
  49303. */
  49304. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49305. }
  49306. }
  49307. declare module "babylonjs/Layers/index" {
  49308. export * from "babylonjs/Layers/effectLayer";
  49309. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49310. export * from "babylonjs/Layers/glowLayer";
  49311. export * from "babylonjs/Layers/highlightLayer";
  49312. export * from "babylonjs/Layers/layer";
  49313. export * from "babylonjs/Layers/layerSceneComponent";
  49314. }
  49315. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49316. /** @hidden */
  49317. export var lensFlarePixelShader: {
  49318. name: string;
  49319. shader: string;
  49320. };
  49321. }
  49322. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49323. /** @hidden */
  49324. export var lensFlareVertexShader: {
  49325. name: string;
  49326. shader: string;
  49327. };
  49328. }
  49329. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49330. import { Scene } from "babylonjs/scene";
  49331. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49333. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49334. import "babylonjs/Shaders/lensFlare.fragment";
  49335. import "babylonjs/Shaders/lensFlare.vertex";
  49336. /**
  49337. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49338. * It is usually composed of several `lensFlare`.
  49339. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49340. */
  49341. export class LensFlareSystem {
  49342. /**
  49343. * Define the name of the lens flare system
  49344. */
  49345. name: string;
  49346. /**
  49347. * List of lens flares used in this system.
  49348. */
  49349. lensFlares: LensFlare[];
  49350. /**
  49351. * Define a limit from the border the lens flare can be visible.
  49352. */
  49353. borderLimit: number;
  49354. /**
  49355. * Define a viewport border we do not want to see the lens flare in.
  49356. */
  49357. viewportBorder: number;
  49358. /**
  49359. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49360. */
  49361. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49362. /**
  49363. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49364. */
  49365. layerMask: number;
  49366. /**
  49367. * Define the id of the lens flare system in the scene.
  49368. * (equal to name by default)
  49369. */
  49370. id: string;
  49371. private _scene;
  49372. private _emitter;
  49373. private _vertexBuffers;
  49374. private _indexBuffer;
  49375. private _effect;
  49376. private _positionX;
  49377. private _positionY;
  49378. private _isEnabled;
  49379. /** @hidden */
  49380. static _SceneComponentInitialization: (scene: Scene) => void;
  49381. /**
  49382. * Instantiates a lens flare system.
  49383. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49384. * It is usually composed of several `lensFlare`.
  49385. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49386. * @param name Define the name of the lens flare system in the scene
  49387. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49388. * @param scene Define the scene the lens flare system belongs to
  49389. */
  49390. constructor(
  49391. /**
  49392. * Define the name of the lens flare system
  49393. */
  49394. name: string, emitter: any, scene: Scene);
  49395. /**
  49396. * Define if the lens flare system is enabled.
  49397. */
  49398. isEnabled: boolean;
  49399. /**
  49400. * Get the scene the effects belongs to.
  49401. * @returns the scene holding the lens flare system
  49402. */
  49403. getScene(): Scene;
  49404. /**
  49405. * Get the emitter of the lens flare system.
  49406. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49407. * @returns the emitter of the lens flare system
  49408. */
  49409. getEmitter(): any;
  49410. /**
  49411. * Set the emitter of the lens flare system.
  49412. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49413. * @param newEmitter Define the new emitter of the system
  49414. */
  49415. setEmitter(newEmitter: any): void;
  49416. /**
  49417. * Get the lens flare system emitter position.
  49418. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49419. * @returns the position
  49420. */
  49421. getEmitterPosition(): Vector3;
  49422. /**
  49423. * @hidden
  49424. */
  49425. computeEffectivePosition(globalViewport: Viewport): boolean;
  49426. /** @hidden */
  49427. _isVisible(): boolean;
  49428. /**
  49429. * @hidden
  49430. */
  49431. render(): boolean;
  49432. /**
  49433. * Dispose and release the lens flare with its associated resources.
  49434. */
  49435. dispose(): void;
  49436. /**
  49437. * Parse a lens flare system from a JSON repressentation
  49438. * @param parsedLensFlareSystem Define the JSON to parse
  49439. * @param scene Define the scene the parsed system should be instantiated in
  49440. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49441. * @returns the parsed system
  49442. */
  49443. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49444. /**
  49445. * Serialize the current Lens Flare System into a JSON representation.
  49446. * @returns the serialized JSON
  49447. */
  49448. serialize(): any;
  49449. }
  49450. }
  49451. declare module "babylonjs/LensFlares/lensFlare" {
  49452. import { Nullable } from "babylonjs/types";
  49453. import { Color3 } from "babylonjs/Maths/math";
  49454. import { Texture } from "babylonjs/Materials/Textures/texture";
  49455. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49456. /**
  49457. * This represents one of the lens effect in a `lensFlareSystem`.
  49458. * It controls one of the indiviual texture used in the effect.
  49459. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49460. */
  49461. export class LensFlare {
  49462. /**
  49463. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49464. */
  49465. size: number;
  49466. /**
  49467. * 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.
  49468. */
  49469. position: number;
  49470. /**
  49471. * Define the lens color.
  49472. */
  49473. color: Color3;
  49474. /**
  49475. * Define the lens texture.
  49476. */
  49477. texture: Nullable<Texture>;
  49478. /**
  49479. * Define the alpha mode to render this particular lens.
  49480. */
  49481. alphaMode: number;
  49482. private _system;
  49483. /**
  49484. * Creates a new Lens Flare.
  49485. * This represents one of the lens effect in a `lensFlareSystem`.
  49486. * It controls one of the indiviual texture used in the effect.
  49487. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49488. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49489. * @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.
  49490. * @param color Define the lens color
  49491. * @param imgUrl Define the lens texture url
  49492. * @param system Define the `lensFlareSystem` this flare is part of
  49493. * @returns The newly created Lens Flare
  49494. */
  49495. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49496. /**
  49497. * Instantiates a new Lens Flare.
  49498. * This represents one of the lens effect in a `lensFlareSystem`.
  49499. * It controls one of the indiviual texture used in the effect.
  49500. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49501. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49502. * @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.
  49503. * @param color Define the lens color
  49504. * @param imgUrl Define the lens texture url
  49505. * @param system Define the `lensFlareSystem` this flare is part of
  49506. */
  49507. constructor(
  49508. /**
  49509. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49510. */
  49511. size: number,
  49512. /**
  49513. * 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.
  49514. */
  49515. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49516. /**
  49517. * Dispose and release the lens flare with its associated resources.
  49518. */
  49519. dispose(): void;
  49520. }
  49521. }
  49522. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49523. import { Nullable } from "babylonjs/types";
  49524. import { Scene } from "babylonjs/scene";
  49525. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49526. import { AbstractScene } from "babylonjs/abstractScene";
  49527. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49528. module "babylonjs/abstractScene" {
  49529. interface AbstractScene {
  49530. /**
  49531. * The list of lens flare system added to the scene
  49532. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49533. */
  49534. lensFlareSystems: Array<LensFlareSystem>;
  49535. /**
  49536. * Removes the given lens flare system from this scene.
  49537. * @param toRemove The lens flare system to remove
  49538. * @returns The index of the removed lens flare system
  49539. */
  49540. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49541. /**
  49542. * Adds the given lens flare system to this scene
  49543. * @param newLensFlareSystem The lens flare system to add
  49544. */
  49545. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49546. /**
  49547. * Gets a lens flare system using its name
  49548. * @param name defines the name to look for
  49549. * @returns the lens flare system or null if not found
  49550. */
  49551. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49552. /**
  49553. * Gets a lens flare system using its id
  49554. * @param id defines the id to look for
  49555. * @returns the lens flare system or null if not found
  49556. */
  49557. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49558. }
  49559. }
  49560. /**
  49561. * Defines the lens flare scene component responsible to manage any lens flares
  49562. * in a given scene.
  49563. */
  49564. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49565. /**
  49566. * The component name helpfull to identify the component in the list of scene components.
  49567. */
  49568. readonly name: string;
  49569. /**
  49570. * The scene the component belongs to.
  49571. */
  49572. scene: Scene;
  49573. /**
  49574. * Creates a new instance of the component for the given scene
  49575. * @param scene Defines the scene to register the component in
  49576. */
  49577. constructor(scene: Scene);
  49578. /**
  49579. * Registers the component in a given scene
  49580. */
  49581. register(): void;
  49582. /**
  49583. * Rebuilds the elements related to this component in case of
  49584. * context lost for instance.
  49585. */
  49586. rebuild(): void;
  49587. /**
  49588. * Adds all the element from the container to the scene
  49589. * @param container the container holding the elements
  49590. */
  49591. addFromContainer(container: AbstractScene): void;
  49592. /**
  49593. * Removes all the elements in the container from the scene
  49594. * @param container contains the elements to remove
  49595. * @param dispose if the removed element should be disposed (default: false)
  49596. */
  49597. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49598. /**
  49599. * Serializes the component data to the specified json object
  49600. * @param serializationObject The object to serialize to
  49601. */
  49602. serialize(serializationObject: any): void;
  49603. /**
  49604. * Disposes the component and the associated ressources.
  49605. */
  49606. dispose(): void;
  49607. private _draw;
  49608. }
  49609. }
  49610. declare module "babylonjs/LensFlares/index" {
  49611. export * from "babylonjs/LensFlares/lensFlare";
  49612. export * from "babylonjs/LensFlares/lensFlareSystem";
  49613. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49614. }
  49615. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49616. import { Scene } from "babylonjs/scene";
  49617. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49618. import { AbstractScene } from "babylonjs/abstractScene";
  49619. /**
  49620. * Defines the shadow generator component responsible to manage any shadow generators
  49621. * in a given scene.
  49622. */
  49623. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49624. /**
  49625. * The component name helpfull to identify the component in the list of scene components.
  49626. */
  49627. readonly name: string;
  49628. /**
  49629. * The scene the component belongs to.
  49630. */
  49631. scene: Scene;
  49632. /**
  49633. * Creates a new instance of the component for the given scene
  49634. * @param scene Defines the scene to register the component in
  49635. */
  49636. constructor(scene: Scene);
  49637. /**
  49638. * Registers the component in a given scene
  49639. */
  49640. register(): void;
  49641. /**
  49642. * Rebuilds the elements related to this component in case of
  49643. * context lost for instance.
  49644. */
  49645. rebuild(): void;
  49646. /**
  49647. * Serializes the component data to the specified json object
  49648. * @param serializationObject The object to serialize to
  49649. */
  49650. serialize(serializationObject: any): void;
  49651. /**
  49652. * Adds all the element from the container to the scene
  49653. * @param container the container holding the elements
  49654. */
  49655. addFromContainer(container: AbstractScene): void;
  49656. /**
  49657. * Removes all the elements in the container from the scene
  49658. * @param container contains the elements to remove
  49659. * @param dispose if the removed element should be disposed (default: false)
  49660. */
  49661. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49662. /**
  49663. * Rebuilds the elements related to this component in case of
  49664. * context lost for instance.
  49665. */
  49666. dispose(): void;
  49667. private _gatherRenderTargets;
  49668. }
  49669. }
  49670. declare module "babylonjs/Lights/Shadows/index" {
  49671. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49672. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49673. }
  49674. declare module "babylonjs/Lights/pointLight" {
  49675. import { Scene } from "babylonjs/scene";
  49676. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49678. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49679. import { Effect } from "babylonjs/Materials/effect";
  49680. /**
  49681. * A point light is a light defined by an unique point in world space.
  49682. * The light is emitted in every direction from this point.
  49683. * A good example of a point light is a standard light bulb.
  49684. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49685. */
  49686. export class PointLight extends ShadowLight {
  49687. private _shadowAngle;
  49688. /**
  49689. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49690. * This specifies what angle the shadow will use to be created.
  49691. *
  49692. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49693. */
  49694. /**
  49695. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49696. * This specifies what angle the shadow will use to be created.
  49697. *
  49698. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49699. */
  49700. shadowAngle: number;
  49701. /**
  49702. * Gets the direction if it has been set.
  49703. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49704. */
  49705. /**
  49706. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49707. */
  49708. direction: Vector3;
  49709. /**
  49710. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49711. * A PointLight emits the light in every direction.
  49712. * It can cast shadows.
  49713. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49714. * ```javascript
  49715. * var pointLight = new PointLight("pl", camera.position, scene);
  49716. * ```
  49717. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49718. * @param name The light friendly name
  49719. * @param position The position of the point light in the scene
  49720. * @param scene The scene the lights belongs to
  49721. */
  49722. constructor(name: string, position: Vector3, scene: Scene);
  49723. /**
  49724. * Returns the string "PointLight"
  49725. * @returns the class name
  49726. */
  49727. getClassName(): string;
  49728. /**
  49729. * Returns the integer 0.
  49730. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49731. */
  49732. getTypeID(): number;
  49733. /**
  49734. * Specifies wether or not the shadowmap should be a cube texture.
  49735. * @returns true if the shadowmap needs to be a cube texture.
  49736. */
  49737. needCube(): boolean;
  49738. /**
  49739. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49740. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49741. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49742. */
  49743. getShadowDirection(faceIndex?: number): Vector3;
  49744. /**
  49745. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49746. * - fov = PI / 2
  49747. * - aspect ratio : 1.0
  49748. * - z-near and far equal to the active camera minZ and maxZ.
  49749. * Returns the PointLight.
  49750. */
  49751. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49752. protected _buildUniformLayout(): void;
  49753. /**
  49754. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49755. * @param effect The effect to update
  49756. * @param lightIndex The index of the light in the effect to update
  49757. * @returns The point light
  49758. */
  49759. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49760. /**
  49761. * Prepares the list of defines specific to the light type.
  49762. * @param defines the list of defines
  49763. * @param lightIndex defines the index of the light for the effect
  49764. */
  49765. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49766. }
  49767. }
  49768. declare module "babylonjs/Lights/index" {
  49769. export * from "babylonjs/Lights/light";
  49770. export * from "babylonjs/Lights/shadowLight";
  49771. export * from "babylonjs/Lights/Shadows/index";
  49772. export * from "babylonjs/Lights/directionalLight";
  49773. export * from "babylonjs/Lights/hemisphericLight";
  49774. export * from "babylonjs/Lights/pointLight";
  49775. export * from "babylonjs/Lights/spotLight";
  49776. }
  49777. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49778. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49779. /**
  49780. * Header information of HDR texture files.
  49781. */
  49782. export interface HDRInfo {
  49783. /**
  49784. * The height of the texture in pixels.
  49785. */
  49786. height: number;
  49787. /**
  49788. * The width of the texture in pixels.
  49789. */
  49790. width: number;
  49791. /**
  49792. * The index of the beginning of the data in the binary file.
  49793. */
  49794. dataPosition: number;
  49795. }
  49796. /**
  49797. * This groups tools to convert HDR texture to native colors array.
  49798. */
  49799. export class HDRTools {
  49800. private static Ldexp;
  49801. private static Rgbe2float;
  49802. private static readStringLine;
  49803. /**
  49804. * Reads header information from an RGBE texture stored in a native array.
  49805. * More information on this format are available here:
  49806. * https://en.wikipedia.org/wiki/RGBE_image_format
  49807. *
  49808. * @param uint8array The binary file stored in native array.
  49809. * @return The header information.
  49810. */
  49811. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49812. /**
  49813. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49814. * This RGBE texture needs to store the information as a panorama.
  49815. *
  49816. * More information on this format are available here:
  49817. * https://en.wikipedia.org/wiki/RGBE_image_format
  49818. *
  49819. * @param buffer The binary file stored in an array buffer.
  49820. * @param size The expected size of the extracted cubemap.
  49821. * @return The Cube Map information.
  49822. */
  49823. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49824. /**
  49825. * Returns the pixels data extracted from an RGBE texture.
  49826. * This pixels will be stored left to right up to down in the R G B order in one array.
  49827. *
  49828. * More information on this format are available here:
  49829. * https://en.wikipedia.org/wiki/RGBE_image_format
  49830. *
  49831. * @param uint8array The binary file stored in an array buffer.
  49832. * @param hdrInfo The header information of the file.
  49833. * @return The pixels data in RGB right to left up to down order.
  49834. */
  49835. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49836. private static RGBE_ReadPixels_RLE;
  49837. }
  49838. }
  49839. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49840. import { Nullable } from "babylonjs/types";
  49841. import { Scene } from "babylonjs/scene";
  49842. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49843. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49844. import "babylonjs/Engines/Extensions/engine.rawTexture";
  49845. /**
  49846. * This represents a texture coming from an HDR input.
  49847. *
  49848. * The only supported format is currently panorama picture stored in RGBE format.
  49849. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49850. */
  49851. export class HDRCubeTexture extends BaseTexture {
  49852. private static _facesMapping;
  49853. private _generateHarmonics;
  49854. private _noMipmap;
  49855. private _textureMatrix;
  49856. private _size;
  49857. private _onLoad;
  49858. private _onError;
  49859. /**
  49860. * The texture URL.
  49861. */
  49862. url: string;
  49863. /**
  49864. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49865. */
  49866. coordinatesMode: number;
  49867. protected _isBlocking: boolean;
  49868. /**
  49869. * Sets wether or not the texture is blocking during loading.
  49870. */
  49871. /**
  49872. * Gets wether or not the texture is blocking during loading.
  49873. */
  49874. isBlocking: boolean;
  49875. protected _rotationY: number;
  49876. /**
  49877. * Sets texture matrix rotation angle around Y axis in radians.
  49878. */
  49879. /**
  49880. * Gets texture matrix rotation angle around Y axis radians.
  49881. */
  49882. rotationY: number;
  49883. /**
  49884. * Gets or sets the center of the bounding box associated with the cube texture
  49885. * It must define where the camera used to render the texture was set
  49886. */
  49887. boundingBoxPosition: Vector3;
  49888. private _boundingBoxSize;
  49889. /**
  49890. * Gets or sets the size of the bounding box associated with the cube texture
  49891. * When defined, the cubemap will switch to local mode
  49892. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49893. * @example https://www.babylonjs-playground.com/#RNASML
  49894. */
  49895. boundingBoxSize: Vector3;
  49896. /**
  49897. * Instantiates an HDRTexture from the following parameters.
  49898. *
  49899. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49900. * @param scene The scene the texture will be used in
  49901. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49902. * @param noMipmap Forces to not generate the mipmap if true
  49903. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49904. * @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)
  49905. * @param reserved Reserved flag for internal use.
  49906. */
  49907. 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>);
  49908. /**
  49909. * Get the current class name of the texture useful for serialization or dynamic coding.
  49910. * @returns "HDRCubeTexture"
  49911. */
  49912. getClassName(): string;
  49913. /**
  49914. * Occurs when the file is raw .hdr file.
  49915. */
  49916. private loadTexture;
  49917. clone(): HDRCubeTexture;
  49918. delayLoad(): void;
  49919. /**
  49920. * Get the texture reflection matrix used to rotate/transform the reflection.
  49921. * @returns the reflection matrix
  49922. */
  49923. getReflectionTextureMatrix(): Matrix;
  49924. /**
  49925. * Set the texture reflection matrix used to rotate/transform the reflection.
  49926. * @param value Define the reflection matrix to set
  49927. */
  49928. setReflectionTextureMatrix(value: Matrix): void;
  49929. /**
  49930. * Parses a JSON representation of an HDR Texture in order to create the texture
  49931. * @param parsedTexture Define the JSON representation
  49932. * @param scene Define the scene the texture should be created in
  49933. * @param rootUrl Define the root url in case we need to load relative dependencies
  49934. * @returns the newly created texture after parsing
  49935. */
  49936. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49937. serialize(): any;
  49938. }
  49939. }
  49940. declare module "babylonjs/Physics/physicsEngine" {
  49941. import { Nullable } from "babylonjs/types";
  49942. import { Vector3 } from "babylonjs/Maths/math";
  49943. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49944. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49945. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49946. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49947. /**
  49948. * Class used to control physics engine
  49949. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49950. */
  49951. export class PhysicsEngine implements IPhysicsEngine {
  49952. private _physicsPlugin;
  49953. /**
  49954. * Global value used to control the smallest number supported by the simulation
  49955. */
  49956. static Epsilon: number;
  49957. private _impostors;
  49958. private _joints;
  49959. /**
  49960. * Gets the gravity vector used by the simulation
  49961. */
  49962. gravity: Vector3;
  49963. /**
  49964. * Factory used to create the default physics plugin.
  49965. * @returns The default physics plugin
  49966. */
  49967. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49968. /**
  49969. * Creates a new Physics Engine
  49970. * @param gravity defines the gravity vector used by the simulation
  49971. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49972. */
  49973. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49974. /**
  49975. * Sets the gravity vector used by the simulation
  49976. * @param gravity defines the gravity vector to use
  49977. */
  49978. setGravity(gravity: Vector3): void;
  49979. /**
  49980. * Set the time step of the physics engine.
  49981. * Default is 1/60.
  49982. * To slow it down, enter 1/600 for example.
  49983. * To speed it up, 1/30
  49984. * @param newTimeStep defines the new timestep to apply to this world.
  49985. */
  49986. setTimeStep(newTimeStep?: number): void;
  49987. /**
  49988. * Get the time step of the physics engine.
  49989. * @returns the current time step
  49990. */
  49991. getTimeStep(): number;
  49992. /**
  49993. * Release all resources
  49994. */
  49995. dispose(): void;
  49996. /**
  49997. * Gets the name of the current physics plugin
  49998. * @returns the name of the plugin
  49999. */
  50000. getPhysicsPluginName(): string;
  50001. /**
  50002. * Adding a new impostor for the impostor tracking.
  50003. * This will be done by the impostor itself.
  50004. * @param impostor the impostor to add
  50005. */
  50006. addImpostor(impostor: PhysicsImpostor): void;
  50007. /**
  50008. * Remove an impostor from the engine.
  50009. * This impostor and its mesh will not longer be updated by the physics engine.
  50010. * @param impostor the impostor to remove
  50011. */
  50012. removeImpostor(impostor: PhysicsImpostor): void;
  50013. /**
  50014. * Add a joint to the physics engine
  50015. * @param mainImpostor defines the main impostor to which the joint is added.
  50016. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50017. * @param joint defines the joint that will connect both impostors.
  50018. */
  50019. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50020. /**
  50021. * Removes a joint from the simulation
  50022. * @param mainImpostor defines the impostor used with the joint
  50023. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50024. * @param joint defines the joint to remove
  50025. */
  50026. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50027. /**
  50028. * Called by the scene. No need to call it.
  50029. * @param delta defines the timespam between frames
  50030. */
  50031. _step(delta: number): void;
  50032. /**
  50033. * Gets the current plugin used to run the simulation
  50034. * @returns current plugin
  50035. */
  50036. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50037. /**
  50038. * Gets the list of physic impostors
  50039. * @returns an array of PhysicsImpostor
  50040. */
  50041. getImpostors(): Array<PhysicsImpostor>;
  50042. /**
  50043. * Gets the impostor for a physics enabled object
  50044. * @param object defines the object impersonated by the impostor
  50045. * @returns the PhysicsImpostor or null if not found
  50046. */
  50047. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50048. /**
  50049. * Gets the impostor for a physics body object
  50050. * @param body defines physics body used by the impostor
  50051. * @returns the PhysicsImpostor or null if not found
  50052. */
  50053. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50054. /**
  50055. * Does a raycast in the physics world
  50056. * @param from when should the ray start?
  50057. * @param to when should the ray end?
  50058. * @returns PhysicsRaycastResult
  50059. */
  50060. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50061. }
  50062. }
  50063. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50064. import { Nullable } from "babylonjs/types";
  50065. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50067. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50068. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50069. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50070. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50071. /** @hidden */
  50072. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50073. private _useDeltaForWorldStep;
  50074. world: any;
  50075. name: string;
  50076. private _physicsMaterials;
  50077. private _fixedTimeStep;
  50078. private _cannonRaycastResult;
  50079. private _raycastResult;
  50080. private _removeAfterStep;
  50081. BJSCANNON: any;
  50082. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50083. setGravity(gravity: Vector3): void;
  50084. setTimeStep(timeStep: number): void;
  50085. getTimeStep(): number;
  50086. executeStep(delta: number): void;
  50087. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50088. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50089. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50090. private _processChildMeshes;
  50091. removePhysicsBody(impostor: PhysicsImpostor): void;
  50092. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50093. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50094. private _addMaterial;
  50095. private _checkWithEpsilon;
  50096. private _createShape;
  50097. private _createHeightmap;
  50098. private _minus90X;
  50099. private _plus90X;
  50100. private _tmpPosition;
  50101. private _tmpDeltaPosition;
  50102. private _tmpUnityRotation;
  50103. private _updatePhysicsBodyTransformation;
  50104. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50105. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50106. isSupported(): boolean;
  50107. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50108. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50109. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50110. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50111. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50112. getBodyMass(impostor: PhysicsImpostor): number;
  50113. getBodyFriction(impostor: PhysicsImpostor): number;
  50114. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50115. getBodyRestitution(impostor: PhysicsImpostor): number;
  50116. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50117. sleepBody(impostor: PhysicsImpostor): void;
  50118. wakeUpBody(impostor: PhysicsImpostor): void;
  50119. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50120. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50121. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50122. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50123. getRadius(impostor: PhysicsImpostor): number;
  50124. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50125. dispose(): void;
  50126. private _extendNamespace;
  50127. /**
  50128. * Does a raycast in the physics world
  50129. * @param from when should the ray start?
  50130. * @param to when should the ray end?
  50131. * @returns PhysicsRaycastResult
  50132. */
  50133. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50134. }
  50135. }
  50136. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50137. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50138. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50139. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50141. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50142. import { Nullable } from "babylonjs/types";
  50143. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50144. /** @hidden */
  50145. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50146. world: any;
  50147. name: string;
  50148. BJSOIMO: any;
  50149. private _raycastResult;
  50150. constructor(iterations?: number, oimoInjection?: any);
  50151. setGravity(gravity: Vector3): void;
  50152. setTimeStep(timeStep: number): void;
  50153. getTimeStep(): number;
  50154. private _tmpImpostorsArray;
  50155. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50156. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50157. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50158. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50159. private _tmpPositionVector;
  50160. removePhysicsBody(impostor: PhysicsImpostor): void;
  50161. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50162. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50163. isSupported(): boolean;
  50164. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50165. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50166. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50167. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50168. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50169. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50170. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50171. getBodyMass(impostor: PhysicsImpostor): number;
  50172. getBodyFriction(impostor: PhysicsImpostor): number;
  50173. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50174. getBodyRestitution(impostor: PhysicsImpostor): number;
  50175. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50176. sleepBody(impostor: PhysicsImpostor): void;
  50177. wakeUpBody(impostor: PhysicsImpostor): void;
  50178. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50179. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50180. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50181. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50182. getRadius(impostor: PhysicsImpostor): number;
  50183. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50184. dispose(): void;
  50185. /**
  50186. * Does a raycast in the physics world
  50187. * @param from when should the ray start?
  50188. * @param to when should the ray end?
  50189. * @returns PhysicsRaycastResult
  50190. */
  50191. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50192. }
  50193. }
  50194. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50195. import { Nullable } from "babylonjs/types";
  50196. import { Scene } from "babylonjs/scene";
  50197. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50198. import { Mesh } from "babylonjs/Meshes/mesh";
  50199. /**
  50200. * Class containing static functions to help procedurally build meshes
  50201. */
  50202. export class RibbonBuilder {
  50203. /**
  50204. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50205. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50206. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50207. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50208. * * 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
  50209. * * 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
  50210. * * 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
  50211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50213. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50214. * * 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
  50215. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50216. * * 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
  50217. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50219. * @param name defines the name of the mesh
  50220. * @param options defines the options used to create the mesh
  50221. * @param scene defines the hosting scene
  50222. * @returns the ribbon mesh
  50223. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50224. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50225. */
  50226. static CreateRibbon(name: string, options: {
  50227. pathArray: Vector3[][];
  50228. closeArray?: boolean;
  50229. closePath?: boolean;
  50230. offset?: number;
  50231. updatable?: boolean;
  50232. sideOrientation?: number;
  50233. frontUVs?: Vector4;
  50234. backUVs?: Vector4;
  50235. instance?: Mesh;
  50236. invertUV?: boolean;
  50237. uvs?: Vector2[];
  50238. colors?: Color4[];
  50239. }, scene?: Nullable<Scene>): Mesh;
  50240. }
  50241. }
  50242. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50243. import { Nullable } from "babylonjs/types";
  50244. import { Scene } from "babylonjs/scene";
  50245. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50246. import { Mesh } from "babylonjs/Meshes/mesh";
  50247. /**
  50248. * Class containing static functions to help procedurally build meshes
  50249. */
  50250. export class ShapeBuilder {
  50251. /**
  50252. * 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.
  50253. * * 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.
  50254. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50255. * * 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.
  50256. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50257. * * 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
  50258. * * 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
  50259. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50262. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50264. * @param name defines the name of the mesh
  50265. * @param options defines the options used to create the mesh
  50266. * @param scene defines the hosting scene
  50267. * @returns the extruded shape mesh
  50268. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50270. */
  50271. static ExtrudeShape(name: string, options: {
  50272. shape: Vector3[];
  50273. path: Vector3[];
  50274. scale?: number;
  50275. rotation?: number;
  50276. cap?: number;
  50277. updatable?: boolean;
  50278. sideOrientation?: number;
  50279. frontUVs?: Vector4;
  50280. backUVs?: Vector4;
  50281. instance?: Mesh;
  50282. invertUV?: boolean;
  50283. }, scene?: Nullable<Scene>): Mesh;
  50284. /**
  50285. * Creates an custom extruded shape mesh.
  50286. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50287. * * 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.
  50288. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50289. * * 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
  50290. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50291. * * 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
  50292. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50293. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50294. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50295. * * 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
  50296. * * 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
  50297. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50300. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50302. * @param name defines the name of the mesh
  50303. * @param options defines the options used to create the mesh
  50304. * @param scene defines the hosting scene
  50305. * @returns the custom extruded shape mesh
  50306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50307. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50309. */
  50310. static ExtrudeShapeCustom(name: string, options: {
  50311. shape: Vector3[];
  50312. path: Vector3[];
  50313. scaleFunction?: any;
  50314. rotationFunction?: any;
  50315. ribbonCloseArray?: boolean;
  50316. ribbonClosePath?: boolean;
  50317. cap?: number;
  50318. updatable?: boolean;
  50319. sideOrientation?: number;
  50320. frontUVs?: Vector4;
  50321. backUVs?: Vector4;
  50322. instance?: Mesh;
  50323. invertUV?: boolean;
  50324. }, scene?: Nullable<Scene>): Mesh;
  50325. private static _ExtrudeShapeGeneric;
  50326. }
  50327. }
  50328. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50329. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50330. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50331. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50332. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50333. import { Nullable } from "babylonjs/types";
  50334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50335. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50336. /**
  50337. * AmmoJS Physics plugin
  50338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50339. * @see https://github.com/kripken/ammo.js/
  50340. */
  50341. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50342. private _useDeltaForWorldStep;
  50343. /**
  50344. * Reference to the Ammo library
  50345. */
  50346. bjsAMMO: any;
  50347. /**
  50348. * Created ammoJS world which physics bodies are added to
  50349. */
  50350. world: any;
  50351. /**
  50352. * Name of the plugin
  50353. */
  50354. name: string;
  50355. private _timeStep;
  50356. private _fixedTimeStep;
  50357. private _maxSteps;
  50358. private _tmpQuaternion;
  50359. private _tmpAmmoTransform;
  50360. private _tmpAmmoQuaternion;
  50361. private _tmpAmmoConcreteContactResultCallback;
  50362. private _collisionConfiguration;
  50363. private _dispatcher;
  50364. private _overlappingPairCache;
  50365. private _solver;
  50366. private _softBodySolver;
  50367. private _tmpAmmoVectorA;
  50368. private _tmpAmmoVectorB;
  50369. private _tmpAmmoVectorC;
  50370. private _tmpAmmoVectorD;
  50371. private _tmpContactCallbackResult;
  50372. private _tmpAmmoVectorRCA;
  50373. private _tmpAmmoVectorRCB;
  50374. private _raycastResult;
  50375. private static readonly DISABLE_COLLISION_FLAG;
  50376. private static readonly KINEMATIC_FLAG;
  50377. private static readonly DISABLE_DEACTIVATION_FLAG;
  50378. /**
  50379. * Initializes the ammoJS plugin
  50380. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50381. * @param ammoInjection can be used to inject your own ammo reference
  50382. */
  50383. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50384. /**
  50385. * Sets the gravity of the physics world (m/(s^2))
  50386. * @param gravity Gravity to set
  50387. */
  50388. setGravity(gravity: Vector3): void;
  50389. /**
  50390. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50391. * @param timeStep timestep to use in seconds
  50392. */
  50393. setTimeStep(timeStep: number): void;
  50394. /**
  50395. * 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)
  50396. * @param fixedTimeStep fixedTimeStep to use in seconds
  50397. */
  50398. setFixedTimeStep(fixedTimeStep: number): void;
  50399. /**
  50400. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50401. * @param maxSteps the maximum number of steps by the physics engine per frame
  50402. */
  50403. setMaxSteps(maxSteps: number): void;
  50404. /**
  50405. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50406. * @returns the current timestep in seconds
  50407. */
  50408. getTimeStep(): number;
  50409. private _isImpostorInContact;
  50410. private _isImpostorPairInContact;
  50411. private _stepSimulation;
  50412. /**
  50413. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50414. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50415. * After the step the babylon meshes are set to the position of the physics imposters
  50416. * @param delta amount of time to step forward
  50417. * @param impostors array of imposters to update before/after the step
  50418. */
  50419. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50420. /**
  50421. * Update babylon mesh to match physics world object
  50422. * @param impostor imposter to match
  50423. */
  50424. private _afterSoftStep;
  50425. /**
  50426. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50427. * @param impostor imposter to match
  50428. */
  50429. private _ropeStep;
  50430. /**
  50431. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50432. * @param impostor imposter to match
  50433. */
  50434. private _softbodyOrClothStep;
  50435. private _tmpVector;
  50436. private _tmpMatrix;
  50437. /**
  50438. * Applies an impulse on the imposter
  50439. * @param impostor imposter to apply impulse to
  50440. * @param force amount of force to be applied to the imposter
  50441. * @param contactPoint the location to apply the impulse on the imposter
  50442. */
  50443. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50444. /**
  50445. * Applies a force on the imposter
  50446. * @param impostor imposter to apply force
  50447. * @param force amount of force to be applied to the imposter
  50448. * @param contactPoint the location to apply the force on the imposter
  50449. */
  50450. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50451. /**
  50452. * Creates a physics body using the plugin
  50453. * @param impostor the imposter to create the physics body on
  50454. */
  50455. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50456. /**
  50457. * Removes the physics body from the imposter and disposes of the body's memory
  50458. * @param impostor imposter to remove the physics body from
  50459. */
  50460. removePhysicsBody(impostor: PhysicsImpostor): void;
  50461. /**
  50462. * Generates a joint
  50463. * @param impostorJoint the imposter joint to create the joint with
  50464. */
  50465. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50466. /**
  50467. * Removes a joint
  50468. * @param impostorJoint the imposter joint to remove the joint from
  50469. */
  50470. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50471. private _addMeshVerts;
  50472. /**
  50473. * Initialise the soft body vertices to match its object's (mesh) vertices
  50474. * Softbody vertices (nodes) are in world space and to match this
  50475. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50476. * @param impostor to create the softbody for
  50477. */
  50478. private _softVertexData;
  50479. /**
  50480. * Create an impostor's soft body
  50481. * @param impostor to create the softbody for
  50482. */
  50483. private _createSoftbody;
  50484. /**
  50485. * Create cloth for an impostor
  50486. * @param impostor to create the softbody for
  50487. */
  50488. private _createCloth;
  50489. /**
  50490. * Create rope for an impostor
  50491. * @param impostor to create the softbody for
  50492. */
  50493. private _createRope;
  50494. private _addHullVerts;
  50495. private _createShape;
  50496. /**
  50497. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50498. * @param impostor imposter containing the physics body and babylon object
  50499. */
  50500. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50501. /**
  50502. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50503. * @param impostor imposter containing the physics body and babylon object
  50504. * @param newPosition new position
  50505. * @param newRotation new rotation
  50506. */
  50507. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50508. /**
  50509. * If this plugin is supported
  50510. * @returns true if its supported
  50511. */
  50512. isSupported(): boolean;
  50513. /**
  50514. * Sets the linear velocity of the physics body
  50515. * @param impostor imposter to set the velocity on
  50516. * @param velocity velocity to set
  50517. */
  50518. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50519. /**
  50520. * Sets the angular velocity of the physics body
  50521. * @param impostor imposter to set the velocity on
  50522. * @param velocity velocity to set
  50523. */
  50524. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50525. /**
  50526. * gets the linear velocity
  50527. * @param impostor imposter to get linear velocity from
  50528. * @returns linear velocity
  50529. */
  50530. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50531. /**
  50532. * gets the angular velocity
  50533. * @param impostor imposter to get angular velocity from
  50534. * @returns angular velocity
  50535. */
  50536. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50537. /**
  50538. * Sets the mass of physics body
  50539. * @param impostor imposter to set the mass on
  50540. * @param mass mass to set
  50541. */
  50542. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50543. /**
  50544. * Gets the mass of the physics body
  50545. * @param impostor imposter to get the mass from
  50546. * @returns mass
  50547. */
  50548. getBodyMass(impostor: PhysicsImpostor): number;
  50549. /**
  50550. * Gets friction of the impostor
  50551. * @param impostor impostor to get friction from
  50552. * @returns friction value
  50553. */
  50554. getBodyFriction(impostor: PhysicsImpostor): number;
  50555. /**
  50556. * Sets friction of the impostor
  50557. * @param impostor impostor to set friction on
  50558. * @param friction friction value
  50559. */
  50560. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50561. /**
  50562. * Gets restitution of the impostor
  50563. * @param impostor impostor to get restitution from
  50564. * @returns restitution value
  50565. */
  50566. getBodyRestitution(impostor: PhysicsImpostor): number;
  50567. /**
  50568. * Sets resitution of the impostor
  50569. * @param impostor impostor to set resitution on
  50570. * @param restitution resitution value
  50571. */
  50572. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50573. /**
  50574. * Gets pressure inside the impostor
  50575. * @param impostor impostor to get pressure from
  50576. * @returns pressure value
  50577. */
  50578. getBodyPressure(impostor: PhysicsImpostor): number;
  50579. /**
  50580. * Sets pressure inside a soft body impostor
  50581. * Cloth and rope must remain 0 pressure
  50582. * @param impostor impostor to set pressure on
  50583. * @param pressure pressure value
  50584. */
  50585. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50586. /**
  50587. * Gets stiffness of the impostor
  50588. * @param impostor impostor to get stiffness from
  50589. * @returns pressure value
  50590. */
  50591. getBodyStiffness(impostor: PhysicsImpostor): number;
  50592. /**
  50593. * Sets stiffness of the impostor
  50594. * @param impostor impostor to set stiffness on
  50595. * @param stiffness stiffness value from 0 to 1
  50596. */
  50597. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50598. /**
  50599. * Gets velocityIterations of the impostor
  50600. * @param impostor impostor to get velocity iterations from
  50601. * @returns velocityIterations value
  50602. */
  50603. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50604. /**
  50605. * Sets velocityIterations of the impostor
  50606. * @param impostor impostor to set velocity iterations on
  50607. * @param velocityIterations velocityIterations value
  50608. */
  50609. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50610. /**
  50611. * Gets positionIterations of the impostor
  50612. * @param impostor impostor to get position iterations from
  50613. * @returns positionIterations value
  50614. */
  50615. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50616. /**
  50617. * Sets positionIterations of the impostor
  50618. * @param impostor impostor to set position on
  50619. * @param positionIterations positionIterations value
  50620. */
  50621. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50622. /**
  50623. * Append an anchor to a cloth object
  50624. * @param impostor is the cloth impostor to add anchor to
  50625. * @param otherImpostor is the rigid impostor to anchor to
  50626. * @param width ratio across width from 0 to 1
  50627. * @param height ratio up height from 0 to 1
  50628. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50629. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50630. */
  50631. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50632. /**
  50633. * Append an hook to a rope object
  50634. * @param impostor is the rope impostor to add hook to
  50635. * @param otherImpostor is the rigid impostor to hook to
  50636. * @param length ratio along the rope from 0 to 1
  50637. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50638. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50639. */
  50640. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50641. /**
  50642. * Sleeps the physics body and stops it from being active
  50643. * @param impostor impostor to sleep
  50644. */
  50645. sleepBody(impostor: PhysicsImpostor): void;
  50646. /**
  50647. * Activates the physics body
  50648. * @param impostor impostor to activate
  50649. */
  50650. wakeUpBody(impostor: PhysicsImpostor): void;
  50651. /**
  50652. * Updates the distance parameters of the joint
  50653. * @param joint joint to update
  50654. * @param maxDistance maximum distance of the joint
  50655. * @param minDistance minimum distance of the joint
  50656. */
  50657. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50658. /**
  50659. * Sets a motor on the joint
  50660. * @param joint joint to set motor on
  50661. * @param speed speed of the motor
  50662. * @param maxForce maximum force of the motor
  50663. * @param motorIndex index of the motor
  50664. */
  50665. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50666. /**
  50667. * Sets the motors limit
  50668. * @param joint joint to set limit on
  50669. * @param upperLimit upper limit
  50670. * @param lowerLimit lower limit
  50671. */
  50672. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50673. /**
  50674. * Syncs the position and rotation of a mesh with the impostor
  50675. * @param mesh mesh to sync
  50676. * @param impostor impostor to update the mesh with
  50677. */
  50678. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50679. /**
  50680. * Gets the radius of the impostor
  50681. * @param impostor impostor to get radius from
  50682. * @returns the radius
  50683. */
  50684. getRadius(impostor: PhysicsImpostor): number;
  50685. /**
  50686. * Gets the box size of the impostor
  50687. * @param impostor impostor to get box size from
  50688. * @param result the resulting box size
  50689. */
  50690. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50691. /**
  50692. * Disposes of the impostor
  50693. */
  50694. dispose(): void;
  50695. /**
  50696. * Does a raycast in the physics world
  50697. * @param from when should the ray start?
  50698. * @param to when should the ray end?
  50699. * @returns PhysicsRaycastResult
  50700. */
  50701. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50702. }
  50703. }
  50704. declare module "babylonjs/Probes/reflectionProbe" {
  50705. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50706. import { Vector3 } from "babylonjs/Maths/math";
  50707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50708. import { Nullable } from "babylonjs/types";
  50709. import { Scene } from "babylonjs/scene";
  50710. module "babylonjs/abstractScene" {
  50711. interface AbstractScene {
  50712. /**
  50713. * The list of reflection probes added to the scene
  50714. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50715. */
  50716. reflectionProbes: Array<ReflectionProbe>;
  50717. /**
  50718. * Removes the given reflection probe from this scene.
  50719. * @param toRemove The reflection probe to remove
  50720. * @returns The index of the removed reflection probe
  50721. */
  50722. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50723. /**
  50724. * Adds the given reflection probe to this scene.
  50725. * @param newReflectionProbe The reflection probe to add
  50726. */
  50727. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50728. }
  50729. }
  50730. /**
  50731. * Class used to generate realtime reflection / refraction cube textures
  50732. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50733. */
  50734. export class ReflectionProbe {
  50735. /** defines the name of the probe */
  50736. name: string;
  50737. private _scene;
  50738. private _renderTargetTexture;
  50739. private _projectionMatrix;
  50740. private _viewMatrix;
  50741. private _target;
  50742. private _add;
  50743. private _attachedMesh;
  50744. private _invertYAxis;
  50745. /** Gets or sets probe position (center of the cube map) */
  50746. position: Vector3;
  50747. /**
  50748. * Creates a new reflection probe
  50749. * @param name defines the name of the probe
  50750. * @param size defines the texture resolution (for each face)
  50751. * @param scene defines the hosting scene
  50752. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50753. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50754. */
  50755. constructor(
  50756. /** defines the name of the probe */
  50757. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50758. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50759. samples: number;
  50760. /** Gets or sets the refresh rate to use (on every frame by default) */
  50761. refreshRate: number;
  50762. /**
  50763. * Gets the hosting scene
  50764. * @returns a Scene
  50765. */
  50766. getScene(): Scene;
  50767. /** Gets the internal CubeTexture used to render to */
  50768. readonly cubeTexture: RenderTargetTexture;
  50769. /** Gets the list of meshes to render */
  50770. readonly renderList: Nullable<AbstractMesh[]>;
  50771. /**
  50772. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50773. * @param mesh defines the mesh to attach to
  50774. */
  50775. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50776. /**
  50777. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50778. * @param renderingGroupId The rendering group id corresponding to its index
  50779. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50780. */
  50781. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50782. /**
  50783. * Clean all associated resources
  50784. */
  50785. dispose(): void;
  50786. /**
  50787. * Converts the reflection probe information to a readable string for debug purpose.
  50788. * @param fullDetails Supports for multiple levels of logging within scene loading
  50789. * @returns the human readable reflection probe info
  50790. */
  50791. toString(fullDetails?: boolean): string;
  50792. /**
  50793. * Get the class name of the relfection probe.
  50794. * @returns "ReflectionProbe"
  50795. */
  50796. getClassName(): string;
  50797. /**
  50798. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50799. * @returns The JSON representation of the texture
  50800. */
  50801. serialize(): any;
  50802. /**
  50803. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50804. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50805. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50806. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50807. * @returns The parsed reflection probe if successful
  50808. */
  50809. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50810. }
  50811. }
  50812. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50813. /** @hidden */
  50814. export var _BabylonLoaderRegistered: boolean;
  50815. }
  50816. declare module "babylonjs/Loading/Plugins/index" {
  50817. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50818. }
  50819. declare module "babylonjs/Loading/index" {
  50820. export * from "babylonjs/Loading/loadingScreen";
  50821. export * from "babylonjs/Loading/Plugins/index";
  50822. export * from "babylonjs/Loading/sceneLoader";
  50823. export * from "babylonjs/Loading/sceneLoaderFlags";
  50824. }
  50825. declare module "babylonjs/Materials/Background/index" {
  50826. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50827. }
  50828. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50829. import { Scene } from "babylonjs/scene";
  50830. import { Color3 } from "babylonjs/Maths/math";
  50831. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50832. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50833. /**
  50834. * The Physically based simple base material of BJS.
  50835. *
  50836. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50837. * It is used as the base class for both the specGloss and metalRough conventions.
  50838. */
  50839. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50840. /**
  50841. * Number of Simultaneous lights allowed on the material.
  50842. */
  50843. maxSimultaneousLights: number;
  50844. /**
  50845. * If sets to true, disables all the lights affecting the material.
  50846. */
  50847. disableLighting: boolean;
  50848. /**
  50849. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50850. */
  50851. environmentTexture: BaseTexture;
  50852. /**
  50853. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50854. */
  50855. invertNormalMapX: boolean;
  50856. /**
  50857. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50858. */
  50859. invertNormalMapY: boolean;
  50860. /**
  50861. * Normal map used in the model.
  50862. */
  50863. normalTexture: BaseTexture;
  50864. /**
  50865. * Emissivie color used to self-illuminate the model.
  50866. */
  50867. emissiveColor: Color3;
  50868. /**
  50869. * Emissivie texture used to self-illuminate the model.
  50870. */
  50871. emissiveTexture: BaseTexture;
  50872. /**
  50873. * Occlusion Channel Strenght.
  50874. */
  50875. occlusionStrength: number;
  50876. /**
  50877. * Occlusion Texture of the material (adding extra occlusion effects).
  50878. */
  50879. occlusionTexture: BaseTexture;
  50880. /**
  50881. * Defines the alpha limits in alpha test mode.
  50882. */
  50883. alphaCutOff: number;
  50884. /**
  50885. * Gets the current double sided mode.
  50886. */
  50887. /**
  50888. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50889. */
  50890. doubleSided: boolean;
  50891. /**
  50892. * Stores the pre-calculated light information of a mesh in a texture.
  50893. */
  50894. lightmapTexture: BaseTexture;
  50895. /**
  50896. * If true, the light map contains occlusion information instead of lighting info.
  50897. */
  50898. useLightmapAsShadowmap: boolean;
  50899. /**
  50900. * Instantiates a new PBRMaterial instance.
  50901. *
  50902. * @param name The material name
  50903. * @param scene The scene the material will be use in.
  50904. */
  50905. constructor(name: string, scene: Scene);
  50906. getClassName(): string;
  50907. }
  50908. }
  50909. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50910. import { Scene } from "babylonjs/scene";
  50911. import { Color3 } from "babylonjs/Maths/math";
  50912. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50913. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50914. /**
  50915. * The PBR material of BJS following the metal roughness convention.
  50916. *
  50917. * This fits to the PBR convention in the GLTF definition:
  50918. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50919. */
  50920. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50921. /**
  50922. * The base color has two different interpretations depending on the value of metalness.
  50923. * When the material is a metal, the base color is the specific measured reflectance value
  50924. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50925. * of the material.
  50926. */
  50927. baseColor: Color3;
  50928. /**
  50929. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50930. * well as opacity information in the alpha channel.
  50931. */
  50932. baseTexture: BaseTexture;
  50933. /**
  50934. * Specifies the metallic scalar value of the material.
  50935. * Can also be used to scale the metalness values of the metallic texture.
  50936. */
  50937. metallic: number;
  50938. /**
  50939. * Specifies the roughness scalar value of the material.
  50940. * Can also be used to scale the roughness values of the metallic texture.
  50941. */
  50942. roughness: number;
  50943. /**
  50944. * Texture containing both the metallic value in the B channel and the
  50945. * roughness value in the G channel to keep better precision.
  50946. */
  50947. metallicRoughnessTexture: BaseTexture;
  50948. /**
  50949. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50950. *
  50951. * @param name The material name
  50952. * @param scene The scene the material will be use in.
  50953. */
  50954. constructor(name: string, scene: Scene);
  50955. /**
  50956. * Return the currrent class name of the material.
  50957. */
  50958. getClassName(): string;
  50959. /**
  50960. * Makes a duplicate of the current material.
  50961. * @param name - name to use for the new material.
  50962. */
  50963. clone(name: string): PBRMetallicRoughnessMaterial;
  50964. /**
  50965. * Serialize the material to a parsable JSON object.
  50966. */
  50967. serialize(): any;
  50968. /**
  50969. * Parses a JSON object correponding to the serialize function.
  50970. */
  50971. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50972. }
  50973. }
  50974. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  50975. import { Scene } from "babylonjs/scene";
  50976. import { Color3 } from "babylonjs/Maths/math";
  50977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50978. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50979. /**
  50980. * The PBR material of BJS following the specular glossiness convention.
  50981. *
  50982. * This fits to the PBR convention in the GLTF definition:
  50983. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50984. */
  50985. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50986. /**
  50987. * Specifies the diffuse color of the material.
  50988. */
  50989. diffuseColor: Color3;
  50990. /**
  50991. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50992. * channel.
  50993. */
  50994. diffuseTexture: BaseTexture;
  50995. /**
  50996. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50997. */
  50998. specularColor: Color3;
  50999. /**
  51000. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51001. */
  51002. glossiness: number;
  51003. /**
  51004. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51005. */
  51006. specularGlossinessTexture: BaseTexture;
  51007. /**
  51008. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51009. *
  51010. * @param name The material name
  51011. * @param scene The scene the material will be use in.
  51012. */
  51013. constructor(name: string, scene: Scene);
  51014. /**
  51015. * Return the currrent class name of the material.
  51016. */
  51017. getClassName(): string;
  51018. /**
  51019. * Makes a duplicate of the current material.
  51020. * @param name - name to use for the new material.
  51021. */
  51022. clone(name: string): PBRSpecularGlossinessMaterial;
  51023. /**
  51024. * Serialize the material to a parsable JSON object.
  51025. */
  51026. serialize(): any;
  51027. /**
  51028. * Parses a JSON object correponding to the serialize function.
  51029. */
  51030. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51031. }
  51032. }
  51033. declare module "babylonjs/Materials/PBR/index" {
  51034. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51035. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51036. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51037. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51038. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51039. }
  51040. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51041. import { Nullable } from "babylonjs/types";
  51042. import { Scene } from "babylonjs/scene";
  51043. import { Matrix } from "babylonjs/Maths/math";
  51044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51045. /**
  51046. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51047. * It can help converting any input color in a desired output one. This can then be used to create effects
  51048. * from sepia, black and white to sixties or futuristic rendering...
  51049. *
  51050. * The only supported format is currently 3dl.
  51051. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51052. */
  51053. export class ColorGradingTexture extends BaseTexture {
  51054. /**
  51055. * The current texture matrix. (will always be identity in color grading texture)
  51056. */
  51057. private _textureMatrix;
  51058. /**
  51059. * The texture URL.
  51060. */
  51061. url: string;
  51062. /**
  51063. * Empty line regex stored for GC.
  51064. */
  51065. private static _noneEmptyLineRegex;
  51066. private _engine;
  51067. /**
  51068. * Instantiates a ColorGradingTexture from the following parameters.
  51069. *
  51070. * @param url The location of the color gradind data (currently only supporting 3dl)
  51071. * @param scene The scene the texture will be used in
  51072. */
  51073. constructor(url: string, scene: Scene);
  51074. /**
  51075. * Returns the texture matrix used in most of the material.
  51076. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51077. */
  51078. getTextureMatrix(): Matrix;
  51079. /**
  51080. * Occurs when the file being loaded is a .3dl LUT file.
  51081. */
  51082. private load3dlTexture;
  51083. /**
  51084. * Starts the loading process of the texture.
  51085. */
  51086. private loadTexture;
  51087. /**
  51088. * Clones the color gradind texture.
  51089. */
  51090. clone(): ColorGradingTexture;
  51091. /**
  51092. * Called during delayed load for textures.
  51093. */
  51094. delayLoad(): void;
  51095. /**
  51096. * Parses a color grading texture serialized by Babylon.
  51097. * @param parsedTexture The texture information being parsedTexture
  51098. * @param scene The scene to load the texture in
  51099. * @param rootUrl The root url of the data assets to load
  51100. * @return A color gradind texture
  51101. */
  51102. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51103. /**
  51104. * Serializes the LUT texture to json format.
  51105. */
  51106. serialize(): any;
  51107. }
  51108. }
  51109. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51110. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51111. import { Scene } from "babylonjs/scene";
  51112. import { Nullable } from "babylonjs/types";
  51113. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51114. /**
  51115. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51116. */
  51117. export class EquiRectangularCubeTexture extends BaseTexture {
  51118. /** The six faces of the cube. */
  51119. private static _FacesMapping;
  51120. private _noMipmap;
  51121. private _onLoad;
  51122. private _onError;
  51123. /** The size of the cubemap. */
  51124. private _size;
  51125. /** The buffer of the image. */
  51126. private _buffer;
  51127. /** The width of the input image. */
  51128. private _width;
  51129. /** The height of the input image. */
  51130. private _height;
  51131. /** The URL to the image. */
  51132. url: string;
  51133. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51134. coordinatesMode: number;
  51135. /**
  51136. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51137. * @param url The location of the image
  51138. * @param scene The scene the texture will be used in
  51139. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51140. * @param noMipmap Forces to not generate the mipmap if true
  51141. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51142. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51143. * @param onLoad — defines a callback called when texture is loaded
  51144. * @param onError — defines a callback called if there is an error
  51145. */
  51146. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51147. /**
  51148. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51149. */
  51150. private loadImage;
  51151. /**
  51152. * Convert the image buffer into a cubemap and create a CubeTexture.
  51153. */
  51154. private loadTexture;
  51155. /**
  51156. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51157. * @param buffer The ArrayBuffer that should be converted.
  51158. * @returns The buffer as Float32Array.
  51159. */
  51160. private getFloat32ArrayFromArrayBuffer;
  51161. /**
  51162. * Get the current class name of the texture useful for serialization or dynamic coding.
  51163. * @returns "EquiRectangularCubeTexture"
  51164. */
  51165. getClassName(): string;
  51166. /**
  51167. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51168. * @returns A clone of the current EquiRectangularCubeTexture.
  51169. */
  51170. clone(): EquiRectangularCubeTexture;
  51171. }
  51172. }
  51173. declare module "babylonjs/Misc/tga" {
  51174. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51175. /**
  51176. * Based on jsTGALoader - Javascript loader for TGA file
  51177. * By Vincent Thibault
  51178. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51179. */
  51180. export class TGATools {
  51181. private static _TYPE_INDEXED;
  51182. private static _TYPE_RGB;
  51183. private static _TYPE_GREY;
  51184. private static _TYPE_RLE_INDEXED;
  51185. private static _TYPE_RLE_RGB;
  51186. private static _TYPE_RLE_GREY;
  51187. private static _ORIGIN_MASK;
  51188. private static _ORIGIN_SHIFT;
  51189. private static _ORIGIN_BL;
  51190. private static _ORIGIN_BR;
  51191. private static _ORIGIN_UL;
  51192. private static _ORIGIN_UR;
  51193. /**
  51194. * Gets the header of a TGA file
  51195. * @param data defines the TGA data
  51196. * @returns the header
  51197. */
  51198. static GetTGAHeader(data: Uint8Array): any;
  51199. /**
  51200. * Uploads TGA content to a Babylon Texture
  51201. * @hidden
  51202. */
  51203. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51204. /** @hidden */
  51205. 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;
  51206. /** @hidden */
  51207. 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;
  51208. /** @hidden */
  51209. 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;
  51210. /** @hidden */
  51211. 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;
  51212. /** @hidden */
  51213. 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;
  51214. /** @hidden */
  51215. 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;
  51216. }
  51217. }
  51218. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51219. import { Nullable } from "babylonjs/types";
  51220. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51221. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51222. /**
  51223. * Implementation of the TGA Texture Loader.
  51224. * @hidden
  51225. */
  51226. export class _TGATextureLoader implements IInternalTextureLoader {
  51227. /**
  51228. * Defines wether the loader supports cascade loading the different faces.
  51229. */
  51230. readonly supportCascades: boolean;
  51231. /**
  51232. * This returns if the loader support the current file information.
  51233. * @param extension defines the file extension of the file being loaded
  51234. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51235. * @param fallback defines the fallback internal texture if any
  51236. * @param isBase64 defines whether the texture is encoded as a base64
  51237. * @param isBuffer defines whether the texture data are stored as a buffer
  51238. * @returns true if the loader can load the specified file
  51239. */
  51240. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51241. /**
  51242. * Transform the url before loading if required.
  51243. * @param rootUrl the url of the texture
  51244. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51245. * @returns the transformed texture
  51246. */
  51247. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51248. /**
  51249. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51250. * @param rootUrl the url of the texture
  51251. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51252. * @returns the fallback texture
  51253. */
  51254. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51255. /**
  51256. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51257. * @param data contains the texture data
  51258. * @param texture defines the BabylonJS internal texture
  51259. * @param createPolynomials will be true if polynomials have been requested
  51260. * @param onLoad defines the callback to trigger once the texture is ready
  51261. * @param onError defines the callback to trigger in case of error
  51262. */
  51263. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51264. /**
  51265. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51266. * @param data contains the texture data
  51267. * @param texture defines the BabylonJS internal texture
  51268. * @param callback defines the method to call once ready to upload
  51269. */
  51270. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51271. }
  51272. }
  51273. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51274. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51275. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51276. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51277. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51278. }
  51279. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51280. import { Scene } from "babylonjs/scene";
  51281. import { Texture } from "babylonjs/Materials/Textures/texture";
  51282. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51283. /**
  51284. * 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.
  51285. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51286. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51287. */
  51288. export class CustomProceduralTexture extends ProceduralTexture {
  51289. private _animate;
  51290. private _time;
  51291. private _config;
  51292. private _texturePath;
  51293. /**
  51294. * Instantiates a new Custom Procedural Texture.
  51295. * 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.
  51296. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51297. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51298. * @param name Define the name of the texture
  51299. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51300. * @param size Define the size of the texture to create
  51301. * @param scene Define the scene the texture belongs to
  51302. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51303. * @param generateMipMaps Define if the texture should creates mip maps or not
  51304. */
  51305. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51306. private _loadJson;
  51307. /**
  51308. * Is the texture ready to be used ? (rendered at least once)
  51309. * @returns true if ready, otherwise, false.
  51310. */
  51311. isReady(): boolean;
  51312. /**
  51313. * Render the texture to its associated render target.
  51314. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51315. */
  51316. render(useCameraPostProcess?: boolean): void;
  51317. /**
  51318. * Update the list of dependant textures samplers in the shader.
  51319. */
  51320. updateTextures(): void;
  51321. /**
  51322. * Update the uniform values of the procedural texture in the shader.
  51323. */
  51324. updateShaderUniforms(): void;
  51325. /**
  51326. * Define if the texture animates or not.
  51327. */
  51328. animate: boolean;
  51329. }
  51330. }
  51331. declare module "babylonjs/Shaders/noise.fragment" {
  51332. /** @hidden */
  51333. export var noisePixelShader: {
  51334. name: string;
  51335. shader: string;
  51336. };
  51337. }
  51338. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51339. import { Nullable } from "babylonjs/types";
  51340. import { Scene } from "babylonjs/scene";
  51341. import { Texture } from "babylonjs/Materials/Textures/texture";
  51342. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51343. import "babylonjs/Shaders/noise.fragment";
  51344. /**
  51345. * Class used to generate noise procedural textures
  51346. */
  51347. export class NoiseProceduralTexture extends ProceduralTexture {
  51348. private _time;
  51349. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51350. brightness: number;
  51351. /** Defines the number of octaves to process */
  51352. octaves: number;
  51353. /** Defines the level of persistence (0.8 by default) */
  51354. persistence: number;
  51355. /** Gets or sets animation speed factor (default is 1) */
  51356. animationSpeedFactor: number;
  51357. /**
  51358. * Creates a new NoiseProceduralTexture
  51359. * @param name defines the name fo the texture
  51360. * @param size defines the size of the texture (default is 256)
  51361. * @param scene defines the hosting scene
  51362. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51363. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51364. */
  51365. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51366. private _updateShaderUniforms;
  51367. protected _getDefines(): string;
  51368. /** Generate the current state of the procedural texture */
  51369. render(useCameraPostProcess?: boolean): void;
  51370. /**
  51371. * Serializes this noise procedural texture
  51372. * @returns a serialized noise procedural texture object
  51373. */
  51374. serialize(): any;
  51375. /**
  51376. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51377. * @param parsedTexture defines parsed texture data
  51378. * @param scene defines the current scene
  51379. * @param rootUrl defines the root URL containing noise procedural texture information
  51380. * @returns a parsed NoiseProceduralTexture
  51381. */
  51382. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51383. }
  51384. }
  51385. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51386. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51387. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51388. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51389. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51390. }
  51391. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51392. import { Nullable } from "babylonjs/types";
  51393. import { Scene } from "babylonjs/scene";
  51394. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51395. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51396. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51397. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51398. /**
  51399. * Raw cube texture where the raw buffers are passed in
  51400. */
  51401. export class RawCubeTexture extends CubeTexture {
  51402. /**
  51403. * Creates a cube texture where the raw buffers are passed in.
  51404. * @param scene defines the scene the texture is attached to
  51405. * @param data defines the array of data to use to create each face
  51406. * @param size defines the size of the textures
  51407. * @param format defines the format of the data
  51408. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51409. * @param generateMipMaps defines if the engine should generate the mip levels
  51410. * @param invertY defines if data must be stored with Y axis inverted
  51411. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51412. * @param compression defines the compression used (null by default)
  51413. */
  51414. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51415. /**
  51416. * Updates the raw cube texture.
  51417. * @param data defines the data to store
  51418. * @param format defines the data format
  51419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51420. * @param invertY defines if data must be stored with Y axis inverted
  51421. * @param compression defines the compression used (null by default)
  51422. * @param level defines which level of the texture to update
  51423. */
  51424. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51425. /**
  51426. * Updates a raw cube texture with RGBD encoded data.
  51427. * @param data defines the array of data [mipmap][face] to use to create each face
  51428. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51429. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51430. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51431. * @returns a promsie that resolves when the operation is complete
  51432. */
  51433. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51434. /**
  51435. * Clones the raw cube texture.
  51436. * @return a new cube texture
  51437. */
  51438. clone(): CubeTexture;
  51439. /** @hidden */
  51440. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51441. }
  51442. }
  51443. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51444. import { Scene } from "babylonjs/scene";
  51445. import { Texture } from "babylonjs/Materials/Textures/texture";
  51446. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51447. /**
  51448. * Class used to store 3D textures containing user data
  51449. */
  51450. export class RawTexture3D extends Texture {
  51451. /** Gets or sets the texture format to use */
  51452. format: number;
  51453. private _engine;
  51454. /**
  51455. * Create a new RawTexture3D
  51456. * @param data defines the data of the texture
  51457. * @param width defines the width of the texture
  51458. * @param height defines the height of the texture
  51459. * @param depth defines the depth of the texture
  51460. * @param format defines the texture format to use
  51461. * @param scene defines the hosting scene
  51462. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51463. * @param invertY defines if texture must be stored with Y axis inverted
  51464. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51465. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51466. */
  51467. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51468. /** Gets or sets the texture format to use */
  51469. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51470. /**
  51471. * Update the texture with new data
  51472. * @param data defines the data to store in the texture
  51473. */
  51474. update(data: ArrayBufferView): void;
  51475. }
  51476. }
  51477. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51478. import { Scene } from "babylonjs/scene";
  51479. import { Plane } from "babylonjs/Maths/math";
  51480. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51481. /**
  51482. * Creates a refraction texture used by refraction channel of the standard material.
  51483. * It is like a mirror but to see through a material.
  51484. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51485. */
  51486. export class RefractionTexture extends RenderTargetTexture {
  51487. /**
  51488. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51489. * 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.
  51490. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51491. */
  51492. refractionPlane: Plane;
  51493. /**
  51494. * Define how deep under the surface we should see.
  51495. */
  51496. depth: number;
  51497. /**
  51498. * Creates a refraction texture used by refraction channel of the standard material.
  51499. * It is like a mirror but to see through a material.
  51500. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51501. * @param name Define the texture name
  51502. * @param size Define the size of the underlying texture
  51503. * @param scene Define the scene the refraction belongs to
  51504. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51505. */
  51506. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51507. /**
  51508. * Clone the refraction texture.
  51509. * @returns the cloned texture
  51510. */
  51511. clone(): RefractionTexture;
  51512. /**
  51513. * Serialize the texture to a JSON representation you could use in Parse later on
  51514. * @returns the serialized JSON representation
  51515. */
  51516. serialize(): any;
  51517. }
  51518. }
  51519. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51520. import { Nullable } from "babylonjs/types";
  51521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51522. import { Matrix } from "babylonjs/Maths/math";
  51523. import { Engine } from "babylonjs/Engines/engine";
  51524. import { Scene } from "babylonjs/scene";
  51525. /**
  51526. * Defines the options related to the creation of an HtmlElementTexture
  51527. */
  51528. export interface IHtmlElementTextureOptions {
  51529. /**
  51530. * Defines wether mip maps should be created or not.
  51531. */
  51532. generateMipMaps?: boolean;
  51533. /**
  51534. * Defines the sampling mode of the texture.
  51535. */
  51536. samplingMode?: number;
  51537. /**
  51538. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51539. */
  51540. engine: Nullable<Engine>;
  51541. /**
  51542. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51543. */
  51544. scene: Nullable<Scene>;
  51545. }
  51546. /**
  51547. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51548. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51549. * is automatically managed.
  51550. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51551. * in your application.
  51552. *
  51553. * As the update is not automatic, you need to call them manually.
  51554. */
  51555. export class HtmlElementTexture extends BaseTexture {
  51556. /**
  51557. * The texture URL.
  51558. */
  51559. element: HTMLVideoElement | HTMLCanvasElement;
  51560. private static readonly DefaultOptions;
  51561. private _textureMatrix;
  51562. private _engine;
  51563. private _isVideo;
  51564. private _generateMipMaps;
  51565. private _samplingMode;
  51566. /**
  51567. * Instantiates a HtmlElementTexture from the following parameters.
  51568. *
  51569. * @param name Defines the name of the texture
  51570. * @param element Defines the video or canvas the texture is filled with
  51571. * @param options Defines the other none mandatory texture creation options
  51572. */
  51573. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51574. private _createInternalTexture;
  51575. /**
  51576. * Returns the texture matrix used in most of the material.
  51577. */
  51578. getTextureMatrix(): Matrix;
  51579. /**
  51580. * Updates the content of the texture.
  51581. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51582. */
  51583. update(invertY?: Nullable<boolean>): void;
  51584. }
  51585. }
  51586. declare module "babylonjs/Materials/Textures/index" {
  51587. export * from "babylonjs/Materials/Textures/baseTexture";
  51588. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51589. export * from "babylonjs/Materials/Textures/cubeTexture";
  51590. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51591. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51592. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51593. export * from "babylonjs/Materials/Textures/internalTexture";
  51594. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51595. export * from "babylonjs/Materials/Textures/Loaders/index";
  51596. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51597. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51598. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51599. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51600. export * from "babylonjs/Materials/Textures/rawTexture";
  51601. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51602. export * from "babylonjs/Materials/Textures/refractionTexture";
  51603. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51604. export * from "babylonjs/Materials/Textures/texture";
  51605. export * from "babylonjs/Materials/Textures/videoTexture";
  51606. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51607. }
  51608. declare module "babylonjs/Materials/index" {
  51609. export * from "babylonjs/Materials/Background/index";
  51610. export * from "babylonjs/Materials/colorCurves";
  51611. export * from "babylonjs/Materials/effect";
  51612. export * from "babylonjs/Materials/fresnelParameters";
  51613. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51614. export * from "babylonjs/Materials/material";
  51615. export * from "babylonjs/Materials/materialDefines";
  51616. export * from "babylonjs/Materials/materialHelper";
  51617. export * from "babylonjs/Materials/multiMaterial";
  51618. export * from "babylonjs/Materials/PBR/index";
  51619. export * from "babylonjs/Materials/pushMaterial";
  51620. export * from "babylonjs/Materials/shaderMaterial";
  51621. export * from "babylonjs/Materials/standardMaterial";
  51622. export * from "babylonjs/Materials/Textures/index";
  51623. export * from "babylonjs/Materials/uniformBuffer";
  51624. export * from "babylonjs/Materials/materialFlags";
  51625. }
  51626. declare module "babylonjs/Maths/index" {
  51627. export * from "babylonjs/Maths/math.scalar";
  51628. export * from "babylonjs/Maths/math";
  51629. export * from "babylonjs/Maths/sphericalPolynomial";
  51630. }
  51631. declare module "babylonjs/Misc/workerPool" {
  51632. import { IDisposable } from "babylonjs/scene";
  51633. /**
  51634. * Helper class to push actions to a pool of workers.
  51635. */
  51636. export class WorkerPool implements IDisposable {
  51637. private _workerInfos;
  51638. private _pendingActions;
  51639. /**
  51640. * Constructor
  51641. * @param workers Array of workers to use for actions
  51642. */
  51643. constructor(workers: Array<Worker>);
  51644. /**
  51645. * Terminates all workers and clears any pending actions.
  51646. */
  51647. dispose(): void;
  51648. /**
  51649. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51650. * pended until a worker has completed its action.
  51651. * @param action The action to perform. Call onComplete when the action is complete.
  51652. */
  51653. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51654. private _execute;
  51655. }
  51656. }
  51657. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51658. import { IDisposable } from "babylonjs/scene";
  51659. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51660. /**
  51661. * Configuration for Draco compression
  51662. */
  51663. export interface IDracoCompressionConfiguration {
  51664. /**
  51665. * Configuration for the decoder.
  51666. */
  51667. decoder?: {
  51668. /**
  51669. * The url to the WebAssembly module.
  51670. */
  51671. wasmUrl?: string;
  51672. /**
  51673. * The url to the WebAssembly binary.
  51674. */
  51675. wasmBinaryUrl?: string;
  51676. /**
  51677. * The url to the fallback JavaScript module.
  51678. */
  51679. fallbackUrl?: string;
  51680. };
  51681. }
  51682. /**
  51683. * Draco compression (https://google.github.io/draco/)
  51684. *
  51685. * This class wraps the Draco module.
  51686. *
  51687. * **Encoder**
  51688. *
  51689. * The encoder is not currently implemented.
  51690. *
  51691. * **Decoder**
  51692. *
  51693. * 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.
  51694. *
  51695. * To update the configuration, use the following code:
  51696. * ```javascript
  51697. * DracoCompression.Configuration = {
  51698. * decoder: {
  51699. * wasmUrl: "<url to the WebAssembly library>",
  51700. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51701. * fallbackUrl: "<url to the fallback JavaScript library>",
  51702. * }
  51703. * };
  51704. * ```
  51705. *
  51706. * 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.
  51707. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51708. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51709. *
  51710. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51711. * ```javascript
  51712. * var dracoCompression = new DracoCompression();
  51713. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51714. * [VertexBuffer.PositionKind]: 0
  51715. * });
  51716. * ```
  51717. *
  51718. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51719. */
  51720. export class DracoCompression implements IDisposable {
  51721. private _workerPoolPromise;
  51722. /**
  51723. * The configuration. Defaults to the following urls:
  51724. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51725. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51726. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51727. */
  51728. static Configuration: IDracoCompressionConfiguration;
  51729. /**
  51730. * Returns true if the decoder is available.
  51731. */
  51732. static readonly DecoderAvailable: boolean;
  51733. /**
  51734. * Default number of workers to create when creating the draco compression object.
  51735. */
  51736. static DefaultNumWorkers: number;
  51737. private static GetDefaultNumWorkers;
  51738. /**
  51739. * Constructor
  51740. * @param numWorkers The number of workers for async operations
  51741. */
  51742. constructor(numWorkers?: number);
  51743. /**
  51744. * Stop all async operations and release resources.
  51745. */
  51746. dispose(): void;
  51747. /**
  51748. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51749. * @returns a promise that resolves when ready
  51750. */
  51751. whenReadyAsync(): Promise<void>;
  51752. /**
  51753. * Decode Draco compressed mesh data to vertex data.
  51754. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51755. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51756. * @returns A promise that resolves with the decoded vertex data
  51757. */
  51758. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51759. [kind: string]: number;
  51760. }): Promise<VertexData>;
  51761. /**
  51762. * The worker function that gets converted to a blob url to pass into a worker.
  51763. */
  51764. private static _Worker;
  51765. private _loadDecoderWasmBinaryAsync;
  51766. }
  51767. }
  51768. declare module "babylonjs/Meshes/Compression/index" {
  51769. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51770. }
  51771. declare module "babylonjs/Meshes/csg" {
  51772. import { Nullable } from "babylonjs/types";
  51773. import { Scene } from "babylonjs/scene";
  51774. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51775. import { Mesh } from "babylonjs/Meshes/mesh";
  51776. import { Material } from "babylonjs/Materials/material";
  51777. /**
  51778. * Class for building Constructive Solid Geometry
  51779. */
  51780. export class CSG {
  51781. private polygons;
  51782. /**
  51783. * The world matrix
  51784. */
  51785. matrix: Matrix;
  51786. /**
  51787. * Stores the position
  51788. */
  51789. position: Vector3;
  51790. /**
  51791. * Stores the rotation
  51792. */
  51793. rotation: Vector3;
  51794. /**
  51795. * Stores the rotation quaternion
  51796. */
  51797. rotationQuaternion: Nullable<Quaternion>;
  51798. /**
  51799. * Stores the scaling vector
  51800. */
  51801. scaling: Vector3;
  51802. /**
  51803. * Convert the Mesh to CSG
  51804. * @param mesh The Mesh to convert to CSG
  51805. * @returns A new CSG from the Mesh
  51806. */
  51807. static FromMesh(mesh: Mesh): CSG;
  51808. /**
  51809. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51810. * @param polygons Polygons used to construct a CSG solid
  51811. */
  51812. private static FromPolygons;
  51813. /**
  51814. * Clones, or makes a deep copy, of the CSG
  51815. * @returns A new CSG
  51816. */
  51817. clone(): CSG;
  51818. /**
  51819. * Unions this CSG with another CSG
  51820. * @param csg The CSG to union against this CSG
  51821. * @returns The unioned CSG
  51822. */
  51823. union(csg: CSG): CSG;
  51824. /**
  51825. * Unions this CSG with another CSG in place
  51826. * @param csg The CSG to union against this CSG
  51827. */
  51828. unionInPlace(csg: CSG): void;
  51829. /**
  51830. * Subtracts this CSG with another CSG
  51831. * @param csg The CSG to subtract against this CSG
  51832. * @returns A new CSG
  51833. */
  51834. subtract(csg: CSG): CSG;
  51835. /**
  51836. * Subtracts this CSG with another CSG in place
  51837. * @param csg The CSG to subtact against this CSG
  51838. */
  51839. subtractInPlace(csg: CSG): void;
  51840. /**
  51841. * Intersect this CSG with another CSG
  51842. * @param csg The CSG to intersect against this CSG
  51843. * @returns A new CSG
  51844. */
  51845. intersect(csg: CSG): CSG;
  51846. /**
  51847. * Intersects this CSG with another CSG in place
  51848. * @param csg The CSG to intersect against this CSG
  51849. */
  51850. intersectInPlace(csg: CSG): void;
  51851. /**
  51852. * Return a new CSG solid with solid and empty space switched. This solid is
  51853. * not modified.
  51854. * @returns A new CSG solid with solid and empty space switched
  51855. */
  51856. inverse(): CSG;
  51857. /**
  51858. * Inverses the CSG in place
  51859. */
  51860. inverseInPlace(): void;
  51861. /**
  51862. * This is used to keep meshes transformations so they can be restored
  51863. * when we build back a Babylon Mesh
  51864. * NB : All CSG operations are performed in world coordinates
  51865. * @param csg The CSG to copy the transform attributes from
  51866. * @returns This CSG
  51867. */
  51868. copyTransformAttributes(csg: CSG): CSG;
  51869. /**
  51870. * Build Raw mesh from CSG
  51871. * Coordinates here are in world space
  51872. * @param name The name of the mesh geometry
  51873. * @param scene The Scene
  51874. * @param keepSubMeshes Specifies if the submeshes should be kept
  51875. * @returns A new Mesh
  51876. */
  51877. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51878. /**
  51879. * Build Mesh from CSG taking material and transforms into account
  51880. * @param name The name of the Mesh
  51881. * @param material The material of the Mesh
  51882. * @param scene The Scene
  51883. * @param keepSubMeshes Specifies if submeshes should be kept
  51884. * @returns The new Mesh
  51885. */
  51886. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51887. }
  51888. }
  51889. declare module "babylonjs/Meshes/trailMesh" {
  51890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51891. import { Mesh } from "babylonjs/Meshes/mesh";
  51892. import { Scene } from "babylonjs/scene";
  51893. /**
  51894. * Class used to create a trail following a mesh
  51895. */
  51896. export class TrailMesh extends Mesh {
  51897. private _generator;
  51898. private _autoStart;
  51899. private _running;
  51900. private _diameter;
  51901. private _length;
  51902. private _sectionPolygonPointsCount;
  51903. private _sectionVectors;
  51904. private _sectionNormalVectors;
  51905. private _beforeRenderObserver;
  51906. /**
  51907. * @constructor
  51908. * @param name The value used by scene.getMeshByName() to do a lookup.
  51909. * @param generator The mesh to generate a trail.
  51910. * @param scene The scene to add this mesh to.
  51911. * @param diameter Diameter of trailing mesh. Default is 1.
  51912. * @param length Length of trailing mesh. Default is 60.
  51913. * @param autoStart Automatically start trailing mesh. Default true.
  51914. */
  51915. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51916. /**
  51917. * "TrailMesh"
  51918. * @returns "TrailMesh"
  51919. */
  51920. getClassName(): string;
  51921. private _createMesh;
  51922. /**
  51923. * Start trailing mesh.
  51924. */
  51925. start(): void;
  51926. /**
  51927. * Stop trailing mesh.
  51928. */
  51929. stop(): void;
  51930. /**
  51931. * Update trailing mesh geometry.
  51932. */
  51933. update(): void;
  51934. /**
  51935. * Returns a new TrailMesh object.
  51936. * @param name is a string, the name given to the new mesh
  51937. * @param newGenerator use new generator object for cloned trail mesh
  51938. * @returns a new mesh
  51939. */
  51940. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51941. /**
  51942. * Serializes this trail mesh
  51943. * @param serializationObject object to write serialization to
  51944. */
  51945. serialize(serializationObject: any): void;
  51946. /**
  51947. * Parses a serialized trail mesh
  51948. * @param parsedMesh the serialized mesh
  51949. * @param scene the scene to create the trail mesh in
  51950. * @returns the created trail mesh
  51951. */
  51952. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51953. }
  51954. }
  51955. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  51956. import { Vector4 } from "babylonjs/Maths/math";
  51957. import { Mesh } from "babylonjs/Meshes/mesh";
  51958. /**
  51959. * Class containing static functions to help procedurally build meshes
  51960. */
  51961. export class TorusKnotBuilder {
  51962. /**
  51963. * Creates a torus knot mesh
  51964. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51965. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51966. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51967. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51971. * @param name defines the name of the mesh
  51972. * @param options defines the options used to create the mesh
  51973. * @param scene defines the hosting scene
  51974. * @returns the torus knot mesh
  51975. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51976. */
  51977. static CreateTorusKnot(name: string, options: {
  51978. radius?: number;
  51979. tube?: number;
  51980. radialSegments?: number;
  51981. tubularSegments?: number;
  51982. p?: number;
  51983. q?: number;
  51984. updatable?: boolean;
  51985. sideOrientation?: number;
  51986. frontUVs?: Vector4;
  51987. backUVs?: Vector4;
  51988. }, scene: any): Mesh;
  51989. }
  51990. }
  51991. declare module "babylonjs/Meshes/polygonMesh" {
  51992. import { Scene } from "babylonjs/scene";
  51993. import { Vector2, Path2 } from "babylonjs/Maths/math";
  51994. import { Mesh } from "babylonjs/Meshes/mesh";
  51995. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51996. /**
  51997. * Polygon
  51998. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51999. */
  52000. export class Polygon {
  52001. /**
  52002. * Creates a rectangle
  52003. * @param xmin bottom X coord
  52004. * @param ymin bottom Y coord
  52005. * @param xmax top X coord
  52006. * @param ymax top Y coord
  52007. * @returns points that make the resulting rectation
  52008. */
  52009. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52010. /**
  52011. * Creates a circle
  52012. * @param radius radius of circle
  52013. * @param cx scale in x
  52014. * @param cy scale in y
  52015. * @param numberOfSides number of sides that make up the circle
  52016. * @returns points that make the resulting circle
  52017. */
  52018. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52019. /**
  52020. * Creates a polygon from input string
  52021. * @param input Input polygon data
  52022. * @returns the parsed points
  52023. */
  52024. static Parse(input: string): Vector2[];
  52025. /**
  52026. * Starts building a polygon from x and y coordinates
  52027. * @param x x coordinate
  52028. * @param y y coordinate
  52029. * @returns the started path2
  52030. */
  52031. static StartingAt(x: number, y: number): Path2;
  52032. }
  52033. /**
  52034. * Builds a polygon
  52035. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52036. */
  52037. export class PolygonMeshBuilder {
  52038. private _points;
  52039. private _outlinepoints;
  52040. private _holes;
  52041. private _name;
  52042. private _scene;
  52043. private _epoints;
  52044. private _eholes;
  52045. private _addToepoint;
  52046. /**
  52047. * Babylon reference to the earcut plugin.
  52048. */
  52049. bjsEarcut: any;
  52050. /**
  52051. * Creates a PolygonMeshBuilder
  52052. * @param name name of the builder
  52053. * @param contours Path of the polygon
  52054. * @param scene scene to add to when creating the mesh
  52055. * @param earcutInjection can be used to inject your own earcut reference
  52056. */
  52057. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52058. /**
  52059. * Adds a whole within the polygon
  52060. * @param hole Array of points defining the hole
  52061. * @returns this
  52062. */
  52063. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52064. /**
  52065. * Creates the polygon
  52066. * @param updatable If the mesh should be updatable
  52067. * @param depth The depth of the mesh created
  52068. * @returns the created mesh
  52069. */
  52070. build(updatable?: boolean, depth?: number): Mesh;
  52071. /**
  52072. * Creates the polygon
  52073. * @param depth The depth of the mesh created
  52074. * @returns the created VertexData
  52075. */
  52076. buildVertexData(depth?: number): VertexData;
  52077. /**
  52078. * Adds a side to the polygon
  52079. * @param positions points that make the polygon
  52080. * @param normals normals of the polygon
  52081. * @param uvs uvs of the polygon
  52082. * @param indices indices of the polygon
  52083. * @param bounds bounds of the polygon
  52084. * @param points points of the polygon
  52085. * @param depth depth of the polygon
  52086. * @param flip flip of the polygon
  52087. */
  52088. private addSide;
  52089. }
  52090. }
  52091. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52092. import { Scene } from "babylonjs/scene";
  52093. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52094. import { Mesh } from "babylonjs/Meshes/mesh";
  52095. import { Nullable } from "babylonjs/types";
  52096. /**
  52097. * Class containing static functions to help procedurally build meshes
  52098. */
  52099. export class PolygonBuilder {
  52100. /**
  52101. * Creates a polygon mesh
  52102. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52103. * * 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
  52104. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52107. * * Remember you can only change the shape positions, not their number when updating a polygon
  52108. * @param name defines the name of the mesh
  52109. * @param options defines the options used to create the mesh
  52110. * @param scene defines the hosting scene
  52111. * @param earcutInjection can be used to inject your own earcut reference
  52112. * @returns the polygon mesh
  52113. */
  52114. static CreatePolygon(name: string, options: {
  52115. shape: Vector3[];
  52116. holes?: Vector3[][];
  52117. depth?: number;
  52118. faceUV?: Vector4[];
  52119. faceColors?: Color4[];
  52120. updatable?: boolean;
  52121. sideOrientation?: number;
  52122. frontUVs?: Vector4;
  52123. backUVs?: Vector4;
  52124. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52125. /**
  52126. * Creates an extruded polygon mesh, with depth in the Y direction.
  52127. * * 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)
  52128. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52129. * @param name defines the name of the mesh
  52130. * @param options defines the options used to create the mesh
  52131. * @param scene defines the hosting scene
  52132. * @param earcutInjection can be used to inject your own earcut reference
  52133. * @returns the polygon mesh
  52134. */
  52135. static ExtrudePolygon(name: string, options: {
  52136. shape: Vector3[];
  52137. holes?: Vector3[][];
  52138. depth?: number;
  52139. faceUV?: Vector4[];
  52140. faceColors?: Color4[];
  52141. updatable?: boolean;
  52142. sideOrientation?: number;
  52143. frontUVs?: Vector4;
  52144. backUVs?: Vector4;
  52145. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52146. }
  52147. }
  52148. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52149. import { Scene } from "babylonjs/scene";
  52150. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52151. import { Mesh } from "babylonjs/Meshes/mesh";
  52152. import { Nullable } from "babylonjs/types";
  52153. /**
  52154. * Class containing static functions to help procedurally build meshes
  52155. */
  52156. export class LatheBuilder {
  52157. /**
  52158. * Creates lathe mesh.
  52159. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52160. * * 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
  52161. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52162. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52163. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52164. * * 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
  52165. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52166. * * 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
  52167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52169. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52171. * @param name defines the name of the mesh
  52172. * @param options defines the options used to create the mesh
  52173. * @param scene defines the hosting scene
  52174. * @returns the lathe mesh
  52175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52176. */
  52177. static CreateLathe(name: string, options: {
  52178. shape: Vector3[];
  52179. radius?: number;
  52180. tessellation?: number;
  52181. clip?: number;
  52182. arc?: number;
  52183. closed?: boolean;
  52184. updatable?: boolean;
  52185. sideOrientation?: number;
  52186. frontUVs?: Vector4;
  52187. backUVs?: Vector4;
  52188. cap?: number;
  52189. invertUV?: boolean;
  52190. }, scene?: Nullable<Scene>): Mesh;
  52191. }
  52192. }
  52193. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52194. import { Nullable } from "babylonjs/types";
  52195. import { Scene } from "babylonjs/scene";
  52196. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52197. import { Mesh } from "babylonjs/Meshes/mesh";
  52198. /**
  52199. * Class containing static functions to help procedurally build meshes
  52200. */
  52201. export class TubeBuilder {
  52202. /**
  52203. * Creates a tube mesh.
  52204. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52205. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52206. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52207. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52208. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52209. * * 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)
  52210. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52211. * * 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
  52212. * * 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
  52213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52215. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52217. * @param name defines the name of the mesh
  52218. * @param options defines the options used to create the mesh
  52219. * @param scene defines the hosting scene
  52220. * @returns the tube mesh
  52221. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52222. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52223. */
  52224. static CreateTube(name: string, options: {
  52225. path: Vector3[];
  52226. radius?: number;
  52227. tessellation?: number;
  52228. radiusFunction?: {
  52229. (i: number, distance: number): number;
  52230. };
  52231. cap?: number;
  52232. arc?: number;
  52233. updatable?: boolean;
  52234. sideOrientation?: number;
  52235. frontUVs?: Vector4;
  52236. backUVs?: Vector4;
  52237. instance?: Mesh;
  52238. invertUV?: boolean;
  52239. }, scene?: Nullable<Scene>): Mesh;
  52240. }
  52241. }
  52242. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52243. import { Scene } from "babylonjs/scene";
  52244. import { Vector4 } from "babylonjs/Maths/math";
  52245. import { Mesh } from "babylonjs/Meshes/mesh";
  52246. import { Nullable } from "babylonjs/types";
  52247. /**
  52248. * Class containing static functions to help procedurally build meshes
  52249. */
  52250. export class IcoSphereBuilder {
  52251. /**
  52252. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52253. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52254. * * 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`)
  52255. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52256. * * 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
  52257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52260. * @param name defines the name of the mesh
  52261. * @param options defines the options used to create the mesh
  52262. * @param scene defines the hosting scene
  52263. * @returns the icosahedron mesh
  52264. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52265. */
  52266. static CreateIcoSphere(name: string, options: {
  52267. radius?: number;
  52268. radiusX?: number;
  52269. radiusY?: number;
  52270. radiusZ?: number;
  52271. flat?: boolean;
  52272. subdivisions?: number;
  52273. sideOrientation?: number;
  52274. frontUVs?: Vector4;
  52275. backUVs?: Vector4;
  52276. updatable?: boolean;
  52277. }, scene?: Nullable<Scene>): Mesh;
  52278. }
  52279. }
  52280. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52281. import { Vector3 } from "babylonjs/Maths/math";
  52282. import { Mesh } from "babylonjs/Meshes/mesh";
  52283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52284. /**
  52285. * Class containing static functions to help procedurally build meshes
  52286. */
  52287. export class DecalBuilder {
  52288. /**
  52289. * Creates a decal mesh.
  52290. * 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
  52291. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52292. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52293. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52294. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52295. * @param name defines the name of the mesh
  52296. * @param sourceMesh defines the mesh where the decal must be applied
  52297. * @param options defines the options used to create the mesh
  52298. * @param scene defines the hosting scene
  52299. * @returns the decal mesh
  52300. * @see https://doc.babylonjs.com/how_to/decals
  52301. */
  52302. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52303. position?: Vector3;
  52304. normal?: Vector3;
  52305. size?: Vector3;
  52306. angle?: number;
  52307. }): Mesh;
  52308. }
  52309. }
  52310. declare module "babylonjs/Meshes/meshBuilder" {
  52311. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52312. import { Nullable } from "babylonjs/types";
  52313. import { Scene } from "babylonjs/scene";
  52314. import { Mesh } from "babylonjs/Meshes/mesh";
  52315. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52316. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52318. /**
  52319. * Class containing static functions to help procedurally build meshes
  52320. */
  52321. export class MeshBuilder {
  52322. /**
  52323. * Creates a box mesh
  52324. * * The parameter `size` sets the size (float) of each box side (default 1)
  52325. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52326. * * 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)
  52327. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52331. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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 box mesh
  52336. */
  52337. static CreateBox(name: string, options: {
  52338. size?: number;
  52339. width?: number;
  52340. height?: number;
  52341. depth?: number;
  52342. faceUV?: Vector4[];
  52343. faceColors?: Color4[];
  52344. sideOrientation?: number;
  52345. frontUVs?: Vector4;
  52346. backUVs?: Vector4;
  52347. updatable?: boolean;
  52348. }, scene?: Nullable<Scene>): Mesh;
  52349. /**
  52350. * Creates a sphere mesh
  52351. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52352. * * 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`)
  52353. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52354. * * 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
  52355. * * 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)
  52356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52359. * @param name defines the name of the mesh
  52360. * @param options defines the options used to create the mesh
  52361. * @param scene defines the hosting scene
  52362. * @returns the sphere mesh
  52363. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52364. */
  52365. static CreateSphere(name: string, options: {
  52366. segments?: number;
  52367. diameter?: number;
  52368. diameterX?: number;
  52369. diameterY?: number;
  52370. diameterZ?: number;
  52371. arc?: number;
  52372. slice?: number;
  52373. sideOrientation?: number;
  52374. frontUVs?: Vector4;
  52375. backUVs?: Vector4;
  52376. updatable?: boolean;
  52377. }, scene?: Nullable<Scene>): Mesh;
  52378. /**
  52379. * Creates a plane polygonal mesh. By default, this is a disc
  52380. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52381. * * 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
  52382. * * 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
  52383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52386. * @param name defines the name of the mesh
  52387. * @param options defines the options used to create the mesh
  52388. * @param scene defines the hosting scene
  52389. * @returns the plane polygonal mesh
  52390. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52391. */
  52392. static CreateDisc(name: string, options: {
  52393. radius?: number;
  52394. tessellation?: number;
  52395. arc?: number;
  52396. updatable?: boolean;
  52397. sideOrientation?: number;
  52398. frontUVs?: Vector4;
  52399. backUVs?: Vector4;
  52400. }, scene?: Nullable<Scene>): Mesh;
  52401. /**
  52402. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52403. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52404. * * 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`)
  52405. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52406. * * 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
  52407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52410. * @param name defines the name of the mesh
  52411. * @param options defines the options used to create the mesh
  52412. * @param scene defines the hosting scene
  52413. * @returns the icosahedron mesh
  52414. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52415. */
  52416. static CreateIcoSphere(name: string, options: {
  52417. radius?: number;
  52418. radiusX?: number;
  52419. radiusY?: number;
  52420. radiusZ?: number;
  52421. flat?: boolean;
  52422. subdivisions?: number;
  52423. sideOrientation?: number;
  52424. frontUVs?: Vector4;
  52425. backUVs?: Vector4;
  52426. updatable?: boolean;
  52427. }, scene?: Nullable<Scene>): Mesh;
  52428. /**
  52429. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52430. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52431. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52432. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52433. * * 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
  52434. * * 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
  52435. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52439. * * 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
  52440. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52441. * * 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
  52442. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52444. * @param name defines the name of the mesh
  52445. * @param options defines the options used to create the mesh
  52446. * @param scene defines the hosting scene
  52447. * @returns the ribbon mesh
  52448. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52449. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52450. */
  52451. static CreateRibbon(name: string, options: {
  52452. pathArray: Vector3[][];
  52453. closeArray?: boolean;
  52454. closePath?: boolean;
  52455. offset?: number;
  52456. updatable?: boolean;
  52457. sideOrientation?: number;
  52458. frontUVs?: Vector4;
  52459. backUVs?: Vector4;
  52460. instance?: Mesh;
  52461. invertUV?: boolean;
  52462. uvs?: Vector2[];
  52463. colors?: Color4[];
  52464. }, scene?: Nullable<Scene>): Mesh;
  52465. /**
  52466. * Creates a cylinder or a cone mesh
  52467. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52468. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52469. * * 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.
  52470. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52471. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52472. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52473. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52474. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52475. * * 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).
  52476. * * 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
  52477. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52478. * * 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
  52479. * * 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.
  52480. * * If `enclose` is false, a ring surface is one element.
  52481. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52482. * * 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
  52483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52486. * @param name defines the name of the mesh
  52487. * @param options defines the options used to create the mesh
  52488. * @param scene defines the hosting scene
  52489. * @returns the cylinder mesh
  52490. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52491. */
  52492. static CreateCylinder(name: string, options: {
  52493. height?: number;
  52494. diameterTop?: number;
  52495. diameterBottom?: number;
  52496. diameter?: number;
  52497. tessellation?: number;
  52498. subdivisions?: number;
  52499. arc?: number;
  52500. faceColors?: Color4[];
  52501. faceUV?: Vector4[];
  52502. updatable?: boolean;
  52503. hasRings?: boolean;
  52504. enclose?: boolean;
  52505. sideOrientation?: number;
  52506. frontUVs?: Vector4;
  52507. backUVs?: Vector4;
  52508. }, scene?: Nullable<Scene>): Mesh;
  52509. /**
  52510. * Creates a torus mesh
  52511. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52512. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52513. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52517. * @param name defines the name of the mesh
  52518. * @param options defines the options used to create the mesh
  52519. * @param scene defines the hosting scene
  52520. * @returns the torus mesh
  52521. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52522. */
  52523. static CreateTorus(name: string, options: {
  52524. diameter?: number;
  52525. thickness?: number;
  52526. tessellation?: number;
  52527. updatable?: boolean;
  52528. sideOrientation?: number;
  52529. frontUVs?: Vector4;
  52530. backUVs?: Vector4;
  52531. }, scene?: Nullable<Scene>): Mesh;
  52532. /**
  52533. * Creates a torus knot mesh
  52534. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52535. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52536. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52537. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52541. * @param name defines the name of the mesh
  52542. * @param options defines the options used to create the mesh
  52543. * @param scene defines the hosting scene
  52544. * @returns the torus knot mesh
  52545. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52546. */
  52547. static CreateTorusKnot(name: string, options: {
  52548. radius?: number;
  52549. tube?: number;
  52550. radialSegments?: number;
  52551. tubularSegments?: number;
  52552. p?: number;
  52553. q?: number;
  52554. updatable?: boolean;
  52555. sideOrientation?: number;
  52556. frontUVs?: Vector4;
  52557. backUVs?: Vector4;
  52558. }, scene?: Nullable<Scene>): Mesh;
  52559. /**
  52560. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52561. * * 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
  52562. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52563. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52564. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52565. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52566. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52567. * * 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
  52568. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52570. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52571. * @param name defines the name of the new line system
  52572. * @param options defines the options used to create the line system
  52573. * @param scene defines the hosting scene
  52574. * @returns a new line system mesh
  52575. */
  52576. static CreateLineSystem(name: string, options: {
  52577. lines: Vector3[][];
  52578. updatable?: boolean;
  52579. instance?: Nullable<LinesMesh>;
  52580. colors?: Nullable<Color4[][]>;
  52581. useVertexAlpha?: boolean;
  52582. }, scene: Nullable<Scene>): LinesMesh;
  52583. /**
  52584. * Creates a line mesh
  52585. * 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
  52586. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52587. * * The parameter `points` is an array successive Vector3
  52588. * * 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
  52589. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52590. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52591. * * When updating an instance, remember that only point positions can change, not the number of points
  52592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52594. * @param name defines the name of the new line system
  52595. * @param options defines the options used to create the line system
  52596. * @param scene defines the hosting scene
  52597. * @returns a new line mesh
  52598. */
  52599. static CreateLines(name: string, options: {
  52600. points: Vector3[];
  52601. updatable?: boolean;
  52602. instance?: Nullable<LinesMesh>;
  52603. colors?: Color4[];
  52604. useVertexAlpha?: boolean;
  52605. }, scene?: Nullable<Scene>): LinesMesh;
  52606. /**
  52607. * Creates a dashed line mesh
  52608. * * 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
  52609. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52610. * * The parameter `points` is an array successive Vector3
  52611. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52612. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52613. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52614. * * 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
  52615. * * When updating an instance, remember that only point positions can change, not the number of points
  52616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52617. * @param name defines the name of the mesh
  52618. * @param options defines the options used to create the mesh
  52619. * @param scene defines the hosting scene
  52620. * @returns the dashed line mesh
  52621. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52622. */
  52623. static CreateDashedLines(name: string, options: {
  52624. points: Vector3[];
  52625. dashSize?: number;
  52626. gapSize?: number;
  52627. dashNb?: number;
  52628. updatable?: boolean;
  52629. instance?: LinesMesh;
  52630. }, scene?: Nullable<Scene>): LinesMesh;
  52631. /**
  52632. * 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.
  52633. * * 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.
  52634. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52635. * * 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.
  52636. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52637. * * 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
  52638. * * 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
  52639. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52642. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52644. * @param name defines the name of the mesh
  52645. * @param options defines the options used to create the mesh
  52646. * @param scene defines the hosting scene
  52647. * @returns the extruded shape mesh
  52648. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52650. */
  52651. static ExtrudeShape(name: string, options: {
  52652. shape: Vector3[];
  52653. path: Vector3[];
  52654. scale?: number;
  52655. rotation?: number;
  52656. cap?: number;
  52657. updatable?: boolean;
  52658. sideOrientation?: number;
  52659. frontUVs?: Vector4;
  52660. backUVs?: Vector4;
  52661. instance?: Mesh;
  52662. invertUV?: boolean;
  52663. }, scene?: Nullable<Scene>): Mesh;
  52664. /**
  52665. * Creates an custom extruded shape mesh.
  52666. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52667. * * 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.
  52668. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52669. * * 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
  52670. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52671. * * 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
  52672. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52673. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52674. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52675. * * 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
  52676. * * 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
  52677. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52680. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52682. * @param name defines the name of the mesh
  52683. * @param options defines the options used to create the mesh
  52684. * @param scene defines the hosting scene
  52685. * @returns the custom extruded shape mesh
  52686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52687. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52689. */
  52690. static ExtrudeShapeCustom(name: string, options: {
  52691. shape: Vector3[];
  52692. path: Vector3[];
  52693. scaleFunction?: any;
  52694. rotationFunction?: any;
  52695. ribbonCloseArray?: boolean;
  52696. ribbonClosePath?: boolean;
  52697. cap?: number;
  52698. updatable?: boolean;
  52699. sideOrientation?: number;
  52700. frontUVs?: Vector4;
  52701. backUVs?: Vector4;
  52702. instance?: Mesh;
  52703. invertUV?: boolean;
  52704. }, scene?: Nullable<Scene>): Mesh;
  52705. /**
  52706. * Creates lathe mesh.
  52707. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52708. * * 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
  52709. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52710. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52711. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52712. * * 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
  52713. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52714. * * 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
  52715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52717. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52719. * @param name defines the name of the mesh
  52720. * @param options defines the options used to create the mesh
  52721. * @param scene defines the hosting scene
  52722. * @returns the lathe mesh
  52723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52724. */
  52725. static CreateLathe(name: string, options: {
  52726. shape: Vector3[];
  52727. radius?: number;
  52728. tessellation?: number;
  52729. clip?: number;
  52730. arc?: number;
  52731. closed?: boolean;
  52732. updatable?: boolean;
  52733. sideOrientation?: number;
  52734. frontUVs?: Vector4;
  52735. backUVs?: Vector4;
  52736. cap?: number;
  52737. invertUV?: boolean;
  52738. }, scene?: Nullable<Scene>): Mesh;
  52739. /**
  52740. * Creates a plane mesh
  52741. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52742. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52743. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52747. * @param name defines the name of the mesh
  52748. * @param options defines the options used to create the mesh
  52749. * @param scene defines the hosting scene
  52750. * @returns the plane mesh
  52751. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52752. */
  52753. static CreatePlane(name: string, options: {
  52754. size?: number;
  52755. width?: number;
  52756. height?: number;
  52757. sideOrientation?: number;
  52758. frontUVs?: Vector4;
  52759. backUVs?: Vector4;
  52760. updatable?: boolean;
  52761. sourcePlane?: Plane;
  52762. }, scene?: Nullable<Scene>): Mesh;
  52763. /**
  52764. * Creates a ground mesh
  52765. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52766. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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. * @param name defines the name of the mesh
  52769. * @param options defines the options used to create the mesh
  52770. * @param scene defines the hosting scene
  52771. * @returns the ground mesh
  52772. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52773. */
  52774. static CreateGround(name: string, options: {
  52775. width?: number;
  52776. height?: number;
  52777. subdivisions?: number;
  52778. subdivisionsX?: number;
  52779. subdivisionsY?: number;
  52780. updatable?: boolean;
  52781. }, scene?: Nullable<Scene>): Mesh;
  52782. /**
  52783. * Creates a tiled ground mesh
  52784. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52785. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52786. * * 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
  52787. * * 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
  52788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52789. * @param name defines the name of the mesh
  52790. * @param options defines the options used to create the mesh
  52791. * @param scene defines the hosting scene
  52792. * @returns the tiled ground mesh
  52793. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52794. */
  52795. static CreateTiledGround(name: string, options: {
  52796. xmin: number;
  52797. zmin: number;
  52798. xmax: number;
  52799. zmax: number;
  52800. subdivisions?: {
  52801. w: number;
  52802. h: number;
  52803. };
  52804. precision?: {
  52805. w: number;
  52806. h: number;
  52807. };
  52808. updatable?: boolean;
  52809. }, scene?: Nullable<Scene>): Mesh;
  52810. /**
  52811. * Creates a ground mesh from a height map
  52812. * * The parameter `url` sets the URL of the height map image resource.
  52813. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52814. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52815. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52816. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52817. * * 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.
  52818. * * 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).
  52819. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52821. * @param name defines the name of the mesh
  52822. * @param url defines the url to the height map
  52823. * @param options defines the options used to create the mesh
  52824. * @param scene defines the hosting scene
  52825. * @returns the ground mesh
  52826. * @see https://doc.babylonjs.com/babylon101/height_map
  52827. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52828. */
  52829. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52830. width?: number;
  52831. height?: number;
  52832. subdivisions?: number;
  52833. minHeight?: number;
  52834. maxHeight?: number;
  52835. colorFilter?: Color3;
  52836. alphaFilter?: number;
  52837. updatable?: boolean;
  52838. onReady?: (mesh: GroundMesh) => void;
  52839. }, scene?: Nullable<Scene>): GroundMesh;
  52840. /**
  52841. * Creates a polygon mesh
  52842. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52843. * * 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
  52844. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52847. * * Remember you can only change the shape positions, not their number when updating a polygon
  52848. * @param name defines the name of the mesh
  52849. * @param options defines the options used to create the mesh
  52850. * @param scene defines the hosting scene
  52851. * @param earcutInjection can be used to inject your own earcut reference
  52852. * @returns the polygon mesh
  52853. */
  52854. static CreatePolygon(name: string, options: {
  52855. shape: Vector3[];
  52856. holes?: Vector3[][];
  52857. depth?: number;
  52858. faceUV?: Vector4[];
  52859. faceColors?: Color4[];
  52860. updatable?: boolean;
  52861. sideOrientation?: number;
  52862. frontUVs?: Vector4;
  52863. backUVs?: Vector4;
  52864. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52865. /**
  52866. * Creates an extruded polygon mesh, with depth in the Y direction.
  52867. * * 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)
  52868. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52869. * @param name defines the name of the mesh
  52870. * @param options defines the options used to create the mesh
  52871. * @param scene defines the hosting scene
  52872. * @param earcutInjection can be used to inject your own earcut reference
  52873. * @returns the polygon mesh
  52874. */
  52875. static ExtrudePolygon(name: string, options: {
  52876. shape: Vector3[];
  52877. holes?: Vector3[][];
  52878. depth?: number;
  52879. faceUV?: Vector4[];
  52880. faceColors?: Color4[];
  52881. updatable?: boolean;
  52882. sideOrientation?: number;
  52883. frontUVs?: Vector4;
  52884. backUVs?: Vector4;
  52885. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52886. /**
  52887. * Creates a tube mesh.
  52888. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52889. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52890. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52891. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52892. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52893. * * 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)
  52894. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52895. * * 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
  52896. * * 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
  52897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52899. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52901. * @param name defines the name of the mesh
  52902. * @param options defines the options used to create the mesh
  52903. * @param scene defines the hosting scene
  52904. * @returns the tube mesh
  52905. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52906. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52907. */
  52908. static CreateTube(name: string, options: {
  52909. path: Vector3[];
  52910. radius?: number;
  52911. tessellation?: number;
  52912. radiusFunction?: {
  52913. (i: number, distance: number): number;
  52914. };
  52915. cap?: number;
  52916. arc?: number;
  52917. updatable?: boolean;
  52918. sideOrientation?: number;
  52919. frontUVs?: Vector4;
  52920. backUVs?: Vector4;
  52921. instance?: Mesh;
  52922. invertUV?: boolean;
  52923. }, scene?: Nullable<Scene>): Mesh;
  52924. /**
  52925. * Creates a polyhedron mesh
  52926. * * 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
  52927. * * The parameter `size` (positive float, default 1) sets the polygon size
  52928. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52929. * * 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`
  52930. * * 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
  52931. * * 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)`)
  52932. * * 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
  52933. * * 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
  52934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52937. * @param name defines the name of the mesh
  52938. * @param options defines the options used to create the mesh
  52939. * @param scene defines the hosting scene
  52940. * @returns the polyhedron mesh
  52941. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52942. */
  52943. static CreatePolyhedron(name: string, options: {
  52944. type?: number;
  52945. size?: number;
  52946. sizeX?: number;
  52947. sizeY?: number;
  52948. sizeZ?: number;
  52949. custom?: any;
  52950. faceUV?: Vector4[];
  52951. faceColors?: Color4[];
  52952. flat?: boolean;
  52953. updatable?: boolean;
  52954. sideOrientation?: number;
  52955. frontUVs?: Vector4;
  52956. backUVs?: Vector4;
  52957. }, scene?: Nullable<Scene>): Mesh;
  52958. /**
  52959. * Creates a decal mesh.
  52960. * 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
  52961. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52962. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52963. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52964. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52965. * @param name defines the name of the mesh
  52966. * @param sourceMesh defines the mesh where the decal must be applied
  52967. * @param options defines the options used to create the mesh
  52968. * @param scene defines the hosting scene
  52969. * @returns the decal mesh
  52970. * @see https://doc.babylonjs.com/how_to/decals
  52971. */
  52972. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52973. position?: Vector3;
  52974. normal?: Vector3;
  52975. size?: Vector3;
  52976. angle?: number;
  52977. }): Mesh;
  52978. }
  52979. }
  52980. declare module "babylonjs/Meshes/meshSimplification" {
  52981. import { Mesh } from "babylonjs/Meshes/mesh";
  52982. /**
  52983. * A simplifier interface for future simplification implementations
  52984. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52985. */
  52986. export interface ISimplifier {
  52987. /**
  52988. * Simplification of a given mesh according to the given settings.
  52989. * Since this requires computation, it is assumed that the function runs async.
  52990. * @param settings The settings of the simplification, including quality and distance
  52991. * @param successCallback A callback that will be called after the mesh was simplified.
  52992. * @param errorCallback in case of an error, this callback will be called. optional.
  52993. */
  52994. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52995. }
  52996. /**
  52997. * Expected simplification settings.
  52998. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52999. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53000. */
  53001. export interface ISimplificationSettings {
  53002. /**
  53003. * Gets or sets the expected quality
  53004. */
  53005. quality: number;
  53006. /**
  53007. * Gets or sets the distance when this optimized version should be used
  53008. */
  53009. distance: number;
  53010. /**
  53011. * Gets an already optimized mesh
  53012. */
  53013. optimizeMesh?: boolean;
  53014. }
  53015. /**
  53016. * Class used to specify simplification options
  53017. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53018. */
  53019. export class SimplificationSettings implements ISimplificationSettings {
  53020. /** expected quality */
  53021. quality: number;
  53022. /** distance when this optimized version should be used */
  53023. distance: number;
  53024. /** already optimized mesh */
  53025. optimizeMesh?: boolean | undefined;
  53026. /**
  53027. * Creates a SimplificationSettings
  53028. * @param quality expected quality
  53029. * @param distance distance when this optimized version should be used
  53030. * @param optimizeMesh already optimized mesh
  53031. */
  53032. constructor(
  53033. /** expected quality */
  53034. quality: number,
  53035. /** distance when this optimized version should be used */
  53036. distance: number,
  53037. /** already optimized mesh */
  53038. optimizeMesh?: boolean | undefined);
  53039. }
  53040. /**
  53041. * Interface used to define a simplification task
  53042. */
  53043. export interface ISimplificationTask {
  53044. /**
  53045. * Array of settings
  53046. */
  53047. settings: Array<ISimplificationSettings>;
  53048. /**
  53049. * Simplification type
  53050. */
  53051. simplificationType: SimplificationType;
  53052. /**
  53053. * Mesh to simplify
  53054. */
  53055. mesh: Mesh;
  53056. /**
  53057. * Callback called on success
  53058. */
  53059. successCallback?: () => void;
  53060. /**
  53061. * Defines if parallel processing can be used
  53062. */
  53063. parallelProcessing: boolean;
  53064. }
  53065. /**
  53066. * Queue used to order the simplification tasks
  53067. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53068. */
  53069. export class SimplificationQueue {
  53070. private _simplificationArray;
  53071. /**
  53072. * Gets a boolean indicating that the process is still running
  53073. */
  53074. running: boolean;
  53075. /**
  53076. * Creates a new queue
  53077. */
  53078. constructor();
  53079. /**
  53080. * Adds a new simplification task
  53081. * @param task defines a task to add
  53082. */
  53083. addTask(task: ISimplificationTask): void;
  53084. /**
  53085. * Execute next task
  53086. */
  53087. executeNext(): void;
  53088. /**
  53089. * Execute a simplification task
  53090. * @param task defines the task to run
  53091. */
  53092. runSimplification(task: ISimplificationTask): void;
  53093. private getSimplifier;
  53094. }
  53095. /**
  53096. * The implemented types of simplification
  53097. * At the moment only Quadratic Error Decimation is implemented
  53098. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53099. */
  53100. export enum SimplificationType {
  53101. /** Quadratic error decimation */
  53102. QUADRATIC = 0
  53103. }
  53104. }
  53105. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53106. import { Scene } from "babylonjs/scene";
  53107. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53108. import { ISceneComponent } from "babylonjs/sceneComponent";
  53109. module "babylonjs/scene" {
  53110. interface Scene {
  53111. /** @hidden (Backing field) */
  53112. _simplificationQueue: SimplificationQueue;
  53113. /**
  53114. * Gets or sets the simplification queue attached to the scene
  53115. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53116. */
  53117. simplificationQueue: SimplificationQueue;
  53118. }
  53119. }
  53120. module "babylonjs/Meshes/mesh" {
  53121. interface Mesh {
  53122. /**
  53123. * Simplify the mesh according to the given array of settings.
  53124. * Function will return immediately and will simplify async
  53125. * @param settings a collection of simplification settings
  53126. * @param parallelProcessing should all levels calculate parallel or one after the other
  53127. * @param simplificationType the type of simplification to run
  53128. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53129. * @returns the current mesh
  53130. */
  53131. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53132. }
  53133. }
  53134. /**
  53135. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53136. * created in a scene
  53137. */
  53138. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53139. /**
  53140. * The component name helpfull to identify the component in the list of scene components.
  53141. */
  53142. readonly name: string;
  53143. /**
  53144. * The scene the component belongs to.
  53145. */
  53146. scene: Scene;
  53147. /**
  53148. * Creates a new instance of the component for the given scene
  53149. * @param scene Defines the scene to register the component in
  53150. */
  53151. constructor(scene: Scene);
  53152. /**
  53153. * Registers the component in a given scene
  53154. */
  53155. register(): void;
  53156. /**
  53157. * Rebuilds the elements related to this component in case of
  53158. * context lost for instance.
  53159. */
  53160. rebuild(): void;
  53161. /**
  53162. * Disposes the component and the associated ressources
  53163. */
  53164. dispose(): void;
  53165. private _beforeCameraUpdate;
  53166. }
  53167. }
  53168. declare module "babylonjs/Meshes/Builders/index" {
  53169. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53170. export * from "babylonjs/Meshes/Builders/discBuilder";
  53171. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53172. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53173. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53174. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53175. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53176. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53177. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53178. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53179. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53180. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53181. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53182. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53183. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53184. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53185. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53186. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53187. }
  53188. declare module "babylonjs/Meshes/index" {
  53189. export * from "babylonjs/Meshes/abstractMesh";
  53190. export * from "babylonjs/Meshes/buffer";
  53191. export * from "babylonjs/Meshes/Compression/index";
  53192. export * from "babylonjs/Meshes/csg";
  53193. export * from "babylonjs/Meshes/geometry";
  53194. export * from "babylonjs/Meshes/groundMesh";
  53195. export * from "babylonjs/Meshes/trailMesh";
  53196. export * from "babylonjs/Meshes/instancedMesh";
  53197. export * from "babylonjs/Meshes/linesMesh";
  53198. export * from "babylonjs/Meshes/mesh";
  53199. export * from "babylonjs/Meshes/mesh.vertexData";
  53200. export * from "babylonjs/Meshes/meshBuilder";
  53201. export * from "babylonjs/Meshes/meshSimplification";
  53202. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53203. export * from "babylonjs/Meshes/polygonMesh";
  53204. export * from "babylonjs/Meshes/subMesh";
  53205. export * from "babylonjs/Meshes/transformNode";
  53206. export * from "babylonjs/Meshes/Builders/index";
  53207. }
  53208. declare module "babylonjs/Morph/index" {
  53209. export * from "babylonjs/Morph/morphTarget";
  53210. export * from "babylonjs/Morph/morphTargetManager";
  53211. }
  53212. declare module "babylonjs/Offline/database" {
  53213. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53214. /**
  53215. * Class used to enable access to IndexedDB
  53216. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53217. */
  53218. export class Database implements IOfflineProvider {
  53219. private _callbackManifestChecked;
  53220. private _currentSceneUrl;
  53221. private _db;
  53222. private _enableSceneOffline;
  53223. private _enableTexturesOffline;
  53224. private _manifestVersionFound;
  53225. private _mustUpdateRessources;
  53226. private _hasReachedQuota;
  53227. private _isSupported;
  53228. private _idbFactory;
  53229. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53230. private static IsUASupportingBlobStorage;
  53231. /**
  53232. * Gets a boolean indicating if Database storate is enabled (off by default)
  53233. */
  53234. static IDBStorageEnabled: boolean;
  53235. /**
  53236. * Gets a boolean indicating if scene must be saved in the database
  53237. */
  53238. readonly enableSceneOffline: boolean;
  53239. /**
  53240. * Gets a boolean indicating if textures must be saved in the database
  53241. */
  53242. readonly enableTexturesOffline: boolean;
  53243. /**
  53244. * Creates a new Database
  53245. * @param urlToScene defines the url to load the scene
  53246. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53247. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53248. */
  53249. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53250. private static _ParseURL;
  53251. private static _ReturnFullUrlLocation;
  53252. private _checkManifestFile;
  53253. /**
  53254. * Open the database and make it available
  53255. * @param successCallback defines the callback to call on success
  53256. * @param errorCallback defines the callback to call on error
  53257. */
  53258. open(successCallback: () => void, errorCallback: () => void): void;
  53259. /**
  53260. * Loads an image from the database
  53261. * @param url defines the url to load from
  53262. * @param image defines the target DOM image
  53263. */
  53264. loadImage(url: string, image: HTMLImageElement): void;
  53265. private _loadImageFromDBAsync;
  53266. private _saveImageIntoDBAsync;
  53267. private _checkVersionFromDB;
  53268. private _loadVersionFromDBAsync;
  53269. private _saveVersionIntoDBAsync;
  53270. /**
  53271. * Loads a file from database
  53272. * @param url defines the URL to load from
  53273. * @param sceneLoaded defines a callback to call on success
  53274. * @param progressCallBack defines a callback to call when progress changed
  53275. * @param errorCallback defines a callback to call on error
  53276. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53277. */
  53278. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53279. private _loadFileAsync;
  53280. private _saveFileAsync;
  53281. /**
  53282. * Validates if xhr data is correct
  53283. * @param xhr defines the request to validate
  53284. * @param dataType defines the expected data type
  53285. * @returns true if data is correct
  53286. */
  53287. private static _ValidateXHRData;
  53288. }
  53289. }
  53290. declare module "babylonjs/Offline/index" {
  53291. export * from "babylonjs/Offline/database";
  53292. export * from "babylonjs/Offline/IOfflineProvider";
  53293. }
  53294. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53295. /** @hidden */
  53296. export var gpuUpdateParticlesPixelShader: {
  53297. name: string;
  53298. shader: string;
  53299. };
  53300. }
  53301. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53302. /** @hidden */
  53303. export var gpuUpdateParticlesVertexShader: {
  53304. name: string;
  53305. shader: string;
  53306. };
  53307. }
  53308. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53309. /** @hidden */
  53310. export var clipPlaneFragmentDeclaration2: {
  53311. name: string;
  53312. shader: string;
  53313. };
  53314. }
  53315. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53316. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53317. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53318. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53319. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53320. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53321. /** @hidden */
  53322. export var gpuRenderParticlesPixelShader: {
  53323. name: string;
  53324. shader: string;
  53325. };
  53326. }
  53327. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53328. /** @hidden */
  53329. export var clipPlaneVertexDeclaration2: {
  53330. name: string;
  53331. shader: string;
  53332. };
  53333. }
  53334. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53335. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53336. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53337. /** @hidden */
  53338. export var gpuRenderParticlesVertexShader: {
  53339. name: string;
  53340. shader: string;
  53341. };
  53342. }
  53343. declare module "babylonjs/Particles/gpuParticleSystem" {
  53344. import { Nullable } from "babylonjs/types";
  53345. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53346. import { Observable } from "babylonjs/Misc/observable";
  53347. import { Color4, Color3 } from "babylonjs/Maths/math";
  53348. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53349. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53350. import { Scene, IDisposable } from "babylonjs/scene";
  53351. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53352. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53353. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53354. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53355. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53356. /**
  53357. * This represents a GPU particle system in Babylon
  53358. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53359. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53360. */
  53361. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53362. /**
  53363. * The layer mask we are rendering the particles through.
  53364. */
  53365. layerMask: number;
  53366. private _capacity;
  53367. private _activeCount;
  53368. private _currentActiveCount;
  53369. private _accumulatedCount;
  53370. private _renderEffect;
  53371. private _updateEffect;
  53372. private _buffer0;
  53373. private _buffer1;
  53374. private _spriteBuffer;
  53375. private _updateVAO;
  53376. private _renderVAO;
  53377. private _targetIndex;
  53378. private _sourceBuffer;
  53379. private _targetBuffer;
  53380. private _engine;
  53381. private _currentRenderId;
  53382. private _started;
  53383. private _stopped;
  53384. private _timeDelta;
  53385. private _randomTexture;
  53386. private _randomTexture2;
  53387. private _attributesStrideSize;
  53388. private _updateEffectOptions;
  53389. private _randomTextureSize;
  53390. private _actualFrame;
  53391. private readonly _rawTextureWidth;
  53392. /**
  53393. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53394. */
  53395. static readonly IsSupported: boolean;
  53396. /**
  53397. * An event triggered when the system is disposed.
  53398. */
  53399. onDisposeObservable: Observable<GPUParticleSystem>;
  53400. /**
  53401. * Gets the maximum number of particles active at the same time.
  53402. * @returns The max number of active particles.
  53403. */
  53404. getCapacity(): number;
  53405. /**
  53406. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53407. * to override the particles.
  53408. */
  53409. forceDepthWrite: boolean;
  53410. /**
  53411. * Gets or set the number of active particles
  53412. */
  53413. activeParticleCount: number;
  53414. private _preWarmDone;
  53415. /**
  53416. * Is this system ready to be used/rendered
  53417. * @return true if the system is ready
  53418. */
  53419. isReady(): boolean;
  53420. /**
  53421. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53422. * @returns True if it has been started, otherwise false.
  53423. */
  53424. isStarted(): boolean;
  53425. /**
  53426. * Starts the particle system and begins to emit
  53427. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53428. */
  53429. start(delay?: number): void;
  53430. /**
  53431. * Stops the particle system.
  53432. */
  53433. stop(): void;
  53434. /**
  53435. * Remove all active particles
  53436. */
  53437. reset(): void;
  53438. /**
  53439. * Returns the string "GPUParticleSystem"
  53440. * @returns a string containing the class name
  53441. */
  53442. getClassName(): string;
  53443. private _colorGradientsTexture;
  53444. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53445. /**
  53446. * Adds a new color gradient
  53447. * @param gradient defines the gradient to use (between 0 and 1)
  53448. * @param color1 defines the color to affect to the specified gradient
  53449. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53450. * @returns the current particle system
  53451. */
  53452. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53453. /**
  53454. * Remove a specific color gradient
  53455. * @param gradient defines the gradient to remove
  53456. * @returns the current particle system
  53457. */
  53458. removeColorGradient(gradient: number): GPUParticleSystem;
  53459. private _angularSpeedGradientsTexture;
  53460. private _sizeGradientsTexture;
  53461. private _velocityGradientsTexture;
  53462. private _limitVelocityGradientsTexture;
  53463. private _dragGradientsTexture;
  53464. private _addFactorGradient;
  53465. /**
  53466. * Adds a new size gradient
  53467. * @param gradient defines the gradient to use (between 0 and 1)
  53468. * @param factor defines the size factor to affect to the specified gradient
  53469. * @returns the current particle system
  53470. */
  53471. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53472. /**
  53473. * Remove a specific size gradient
  53474. * @param gradient defines the gradient to remove
  53475. * @returns the current particle system
  53476. */
  53477. removeSizeGradient(gradient: number): GPUParticleSystem;
  53478. /**
  53479. * Adds a new angular speed gradient
  53480. * @param gradient defines the gradient to use (between 0 and 1)
  53481. * @param factor defines the angular speed to affect to the specified gradient
  53482. * @returns the current particle system
  53483. */
  53484. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53485. /**
  53486. * Remove a specific angular speed gradient
  53487. * @param gradient defines the gradient to remove
  53488. * @returns the current particle system
  53489. */
  53490. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53491. /**
  53492. * Adds a new velocity gradient
  53493. * @param gradient defines the gradient to use (between 0 and 1)
  53494. * @param factor defines the velocity to affect to the specified gradient
  53495. * @returns the current particle system
  53496. */
  53497. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53498. /**
  53499. * Remove a specific velocity gradient
  53500. * @param gradient defines the gradient to remove
  53501. * @returns the current particle system
  53502. */
  53503. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53504. /**
  53505. * Adds a new limit velocity gradient
  53506. * @param gradient defines the gradient to use (between 0 and 1)
  53507. * @param factor defines the limit velocity value to affect to the specified gradient
  53508. * @returns the current particle system
  53509. */
  53510. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53511. /**
  53512. * Remove a specific limit velocity gradient
  53513. * @param gradient defines the gradient to remove
  53514. * @returns the current particle system
  53515. */
  53516. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53517. /**
  53518. * Adds a new drag gradient
  53519. * @param gradient defines the gradient to use (between 0 and 1)
  53520. * @param factor defines the drag value to affect to the specified gradient
  53521. * @returns the current particle system
  53522. */
  53523. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53524. /**
  53525. * Remove a specific drag gradient
  53526. * @param gradient defines the gradient to remove
  53527. * @returns the current particle system
  53528. */
  53529. removeDragGradient(gradient: number): GPUParticleSystem;
  53530. /**
  53531. * Not supported by GPUParticleSystem
  53532. * @param gradient defines the gradient to use (between 0 and 1)
  53533. * @param factor defines the emit rate value to affect to the specified gradient
  53534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53535. * @returns the current particle system
  53536. */
  53537. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53538. /**
  53539. * Not supported by GPUParticleSystem
  53540. * @param gradient defines the gradient to remove
  53541. * @returns the current particle system
  53542. */
  53543. removeEmitRateGradient(gradient: number): IParticleSystem;
  53544. /**
  53545. * Not supported by GPUParticleSystem
  53546. * @param gradient defines the gradient to use (between 0 and 1)
  53547. * @param factor defines the start size value to affect to the specified gradient
  53548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53549. * @returns the current particle system
  53550. */
  53551. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53552. /**
  53553. * Not supported by GPUParticleSystem
  53554. * @param gradient defines the gradient to remove
  53555. * @returns the current particle system
  53556. */
  53557. removeStartSizeGradient(gradient: number): IParticleSystem;
  53558. /**
  53559. * Not supported by GPUParticleSystem
  53560. * @param gradient defines the gradient to use (between 0 and 1)
  53561. * @param min defines the color remap minimal range
  53562. * @param max defines the color remap maximal range
  53563. * @returns the current particle system
  53564. */
  53565. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53566. /**
  53567. * Not supported by GPUParticleSystem
  53568. * @param gradient defines the gradient to remove
  53569. * @returns the current particle system
  53570. */
  53571. removeColorRemapGradient(): IParticleSystem;
  53572. /**
  53573. * Not supported by GPUParticleSystem
  53574. * @param gradient defines the gradient to use (between 0 and 1)
  53575. * @param min defines the alpha remap minimal range
  53576. * @param max defines the alpha remap maximal range
  53577. * @returns the current particle system
  53578. */
  53579. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53580. /**
  53581. * Not supported by GPUParticleSystem
  53582. * @param gradient defines the gradient to remove
  53583. * @returns the current particle system
  53584. */
  53585. removeAlphaRemapGradient(): IParticleSystem;
  53586. /**
  53587. * Not supported by GPUParticleSystem
  53588. * @param gradient defines the gradient to use (between 0 and 1)
  53589. * @param color defines the color to affect to the specified gradient
  53590. * @returns the current particle system
  53591. */
  53592. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53593. /**
  53594. * Not supported by GPUParticleSystem
  53595. * @param gradient defines the gradient to remove
  53596. * @returns the current particle system
  53597. */
  53598. removeRampGradient(): IParticleSystem;
  53599. /**
  53600. * Not supported by GPUParticleSystem
  53601. * @returns the list of ramp gradients
  53602. */
  53603. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53604. /**
  53605. * Not supported by GPUParticleSystem
  53606. * Gets or sets a boolean indicating that ramp gradients must be used
  53607. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53608. */
  53609. useRampGradients: boolean;
  53610. /**
  53611. * Not supported by GPUParticleSystem
  53612. * @param gradient defines the gradient to use (between 0 and 1)
  53613. * @param factor defines the life time factor to affect to the specified gradient
  53614. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53615. * @returns the current particle system
  53616. */
  53617. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53618. /**
  53619. * Not supported by GPUParticleSystem
  53620. * @param gradient defines the gradient to remove
  53621. * @returns the current particle system
  53622. */
  53623. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53624. /**
  53625. * Instantiates a GPU particle system.
  53626. * 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.
  53627. * @param name The name of the particle system
  53628. * @param options The options used to create the system
  53629. * @param scene The scene the particle system belongs to
  53630. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53631. */
  53632. constructor(name: string, options: Partial<{
  53633. capacity: number;
  53634. randomTextureSize: number;
  53635. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53636. protected _reset(): void;
  53637. private _createUpdateVAO;
  53638. private _createRenderVAO;
  53639. private _initialize;
  53640. /** @hidden */
  53641. _recreateUpdateEffect(): void;
  53642. /** @hidden */
  53643. _recreateRenderEffect(): void;
  53644. /**
  53645. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53646. * @param preWarm defines if we are in the pre-warmimg phase
  53647. */
  53648. animate(preWarm?: boolean): void;
  53649. private _createFactorGradientTexture;
  53650. private _createSizeGradientTexture;
  53651. private _createAngularSpeedGradientTexture;
  53652. private _createVelocityGradientTexture;
  53653. private _createLimitVelocityGradientTexture;
  53654. private _createDragGradientTexture;
  53655. private _createColorGradientTexture;
  53656. /**
  53657. * Renders the particle system in its current state
  53658. * @param preWarm defines if the system should only update the particles but not render them
  53659. * @returns the current number of particles
  53660. */
  53661. render(preWarm?: boolean): number;
  53662. /**
  53663. * Rebuilds the particle system
  53664. */
  53665. rebuild(): void;
  53666. private _releaseBuffers;
  53667. private _releaseVAOs;
  53668. /**
  53669. * Disposes the particle system and free the associated resources
  53670. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53671. */
  53672. dispose(disposeTexture?: boolean): void;
  53673. /**
  53674. * Clones the particle system.
  53675. * @param name The name of the cloned object
  53676. * @param newEmitter The new emitter to use
  53677. * @returns the cloned particle system
  53678. */
  53679. clone(name: string, newEmitter: any): GPUParticleSystem;
  53680. /**
  53681. * Serializes the particle system to a JSON object.
  53682. * @returns the JSON object
  53683. */
  53684. serialize(): any;
  53685. /**
  53686. * Parses a JSON object to create a GPU particle system.
  53687. * @param parsedParticleSystem The JSON object to parse
  53688. * @param scene The scene to create the particle system in
  53689. * @param rootUrl The root url to use to load external dependencies like texture
  53690. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53691. * @returns the parsed GPU particle system
  53692. */
  53693. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53694. }
  53695. }
  53696. declare module "babylonjs/Particles/particleSystemSet" {
  53697. import { Nullable } from "babylonjs/types";
  53698. import { Color3 } from "babylonjs/Maths/math";
  53699. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53701. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53702. import { Scene, IDisposable } from "babylonjs/scene";
  53703. /**
  53704. * Represents a set of particle systems working together to create a specific effect
  53705. */
  53706. export class ParticleSystemSet implements IDisposable {
  53707. private _emitterCreationOptions;
  53708. private _emitterNode;
  53709. /**
  53710. * Gets the particle system list
  53711. */
  53712. systems: IParticleSystem[];
  53713. /**
  53714. * Gets the emitter node used with this set
  53715. */
  53716. readonly emitterNode: Nullable<TransformNode>;
  53717. /**
  53718. * Creates a new emitter mesh as a sphere
  53719. * @param options defines the options used to create the sphere
  53720. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53721. * @param scene defines the hosting scene
  53722. */
  53723. setEmitterAsSphere(options: {
  53724. diameter: number;
  53725. segments: number;
  53726. color: Color3;
  53727. }, renderingGroupId: number, scene: Scene): void;
  53728. /**
  53729. * Starts all particle systems of the set
  53730. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53731. */
  53732. start(emitter?: AbstractMesh): void;
  53733. /**
  53734. * Release all associated resources
  53735. */
  53736. dispose(): void;
  53737. /**
  53738. * Serialize the set into a JSON compatible object
  53739. * @returns a JSON compatible representation of the set
  53740. */
  53741. serialize(): any;
  53742. /**
  53743. * Parse a new ParticleSystemSet from a serialized source
  53744. * @param data defines a JSON compatible representation of the set
  53745. * @param scene defines the hosting scene
  53746. * @param gpu defines if we want GPU particles or CPU particles
  53747. * @returns a new ParticleSystemSet
  53748. */
  53749. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53750. }
  53751. }
  53752. declare module "babylonjs/Particles/particleHelper" {
  53753. import { Nullable } from "babylonjs/types";
  53754. import { Scene } from "babylonjs/scene";
  53755. import { Vector3 } from "babylonjs/Maths/math";
  53756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53757. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53758. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53759. /**
  53760. * This class is made for on one-liner static method to help creating particle system set.
  53761. */
  53762. export class ParticleHelper {
  53763. /**
  53764. * Gets or sets base Assets URL
  53765. */
  53766. static BaseAssetsUrl: string;
  53767. /**
  53768. * Create a default particle system that you can tweak
  53769. * @param emitter defines the emitter to use
  53770. * @param capacity defines the system capacity (default is 500 particles)
  53771. * @param scene defines the hosting scene
  53772. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53773. * @returns the new Particle system
  53774. */
  53775. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53776. /**
  53777. * This is the main static method (one-liner) of this helper to create different particle systems
  53778. * @param type This string represents the type to the particle system to create
  53779. * @param scene The scene where the particle system should live
  53780. * @param gpu If the system will use gpu
  53781. * @returns the ParticleSystemSet created
  53782. */
  53783. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53784. /**
  53785. * Static function used to export a particle system to a ParticleSystemSet variable.
  53786. * Please note that the emitter shape is not exported
  53787. * @param systems defines the particle systems to export
  53788. * @returns the created particle system set
  53789. */
  53790. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53791. }
  53792. }
  53793. declare module "babylonjs/Particles/particleSystemComponent" {
  53794. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53795. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53796. import "babylonjs/Shaders/particles.vertex";
  53797. module "babylonjs/Engines/engine" {
  53798. interface Engine {
  53799. /**
  53800. * Create an effect to use with particle systems.
  53801. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53802. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53803. * @param uniformsNames defines a list of attribute names
  53804. * @param samplers defines an array of string used to represent textures
  53805. * @param defines defines the string containing the defines to use to compile the shaders
  53806. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53807. * @param onCompiled defines a function to call when the effect creation is successful
  53808. * @param onError defines a function to call when the effect creation has failed
  53809. * @returns the new Effect
  53810. */
  53811. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53812. }
  53813. }
  53814. module "babylonjs/Meshes/mesh" {
  53815. interface Mesh {
  53816. /**
  53817. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53818. * @returns an array of IParticleSystem
  53819. */
  53820. getEmittedParticleSystems(): IParticleSystem[];
  53821. /**
  53822. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53823. * @returns an array of IParticleSystem
  53824. */
  53825. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53826. }
  53827. }
  53828. /**
  53829. * @hidden
  53830. */
  53831. export var _IDoNeedToBeInTheBuild: number;
  53832. }
  53833. declare module "babylonjs/Particles/index" {
  53834. export * from "babylonjs/Particles/baseParticleSystem";
  53835. export * from "babylonjs/Particles/EmitterTypes/index";
  53836. export * from "babylonjs/Particles/gpuParticleSystem";
  53837. export * from "babylonjs/Particles/IParticleSystem";
  53838. export * from "babylonjs/Particles/particle";
  53839. export * from "babylonjs/Particles/particleHelper";
  53840. export * from "babylonjs/Particles/particleSystem";
  53841. export * from "babylonjs/Particles/particleSystemComponent";
  53842. export * from "babylonjs/Particles/particleSystemSet";
  53843. export * from "babylonjs/Particles/solidParticle";
  53844. export * from "babylonjs/Particles/solidParticleSystem";
  53845. export * from "babylonjs/Particles/subEmitter";
  53846. }
  53847. declare module "babylonjs/Physics/physicsEngineComponent" {
  53848. import { Nullable } from "babylonjs/types";
  53849. import { Observable, Observer } from "babylonjs/Misc/observable";
  53850. import { Vector3 } from "babylonjs/Maths/math";
  53851. import { Mesh } from "babylonjs/Meshes/mesh";
  53852. import { ISceneComponent } from "babylonjs/sceneComponent";
  53853. import { Scene } from "babylonjs/scene";
  53854. import { Node } from "babylonjs/node";
  53855. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53856. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53857. module "babylonjs/scene" {
  53858. interface Scene {
  53859. /** @hidden (Backing field) */
  53860. _physicsEngine: Nullable<IPhysicsEngine>;
  53861. /**
  53862. * Gets the current physics engine
  53863. * @returns a IPhysicsEngine or null if none attached
  53864. */
  53865. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53866. /**
  53867. * Enables physics to the current scene
  53868. * @param gravity defines the scene's gravity for the physics engine
  53869. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53870. * @return a boolean indicating if the physics engine was initialized
  53871. */
  53872. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53873. /**
  53874. * Disables and disposes the physics engine associated with the scene
  53875. */
  53876. disablePhysicsEngine(): void;
  53877. /**
  53878. * Gets a boolean indicating if there is an active physics engine
  53879. * @returns a boolean indicating if there is an active physics engine
  53880. */
  53881. isPhysicsEnabled(): boolean;
  53882. /**
  53883. * Deletes a physics compound impostor
  53884. * @param compound defines the compound to delete
  53885. */
  53886. deleteCompoundImpostor(compound: any): void;
  53887. /**
  53888. * An event triggered when physic simulation is about to be run
  53889. */
  53890. onBeforePhysicsObservable: Observable<Scene>;
  53891. /**
  53892. * An event triggered when physic simulation has been done
  53893. */
  53894. onAfterPhysicsObservable: Observable<Scene>;
  53895. }
  53896. }
  53897. module "babylonjs/Meshes/abstractMesh" {
  53898. interface AbstractMesh {
  53899. /** @hidden */
  53900. _physicsImpostor: Nullable<PhysicsImpostor>;
  53901. /**
  53902. * Gets or sets impostor used for physic simulation
  53903. * @see http://doc.babylonjs.com/features/physics_engine
  53904. */
  53905. physicsImpostor: Nullable<PhysicsImpostor>;
  53906. /**
  53907. * Gets the current physics impostor
  53908. * @see http://doc.babylonjs.com/features/physics_engine
  53909. * @returns a physics impostor or null
  53910. */
  53911. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53912. /** Apply a physic impulse to the mesh
  53913. * @param force defines the force to apply
  53914. * @param contactPoint defines where to apply the force
  53915. * @returns the current mesh
  53916. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53917. */
  53918. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53919. /**
  53920. * Creates a physic joint between two meshes
  53921. * @param otherMesh defines the other mesh to use
  53922. * @param pivot1 defines the pivot to use on this mesh
  53923. * @param pivot2 defines the pivot to use on the other mesh
  53924. * @param options defines additional options (can be plugin dependent)
  53925. * @returns the current mesh
  53926. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53927. */
  53928. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53929. /** @hidden */
  53930. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53931. }
  53932. }
  53933. /**
  53934. * Defines the physics engine scene component responsible to manage a physics engine
  53935. */
  53936. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53937. /**
  53938. * The component name helpful to identify the component in the list of scene components.
  53939. */
  53940. readonly name: string;
  53941. /**
  53942. * The scene the component belongs to.
  53943. */
  53944. scene: Scene;
  53945. /**
  53946. * Creates a new instance of the component for the given scene
  53947. * @param scene Defines the scene to register the component in
  53948. */
  53949. constructor(scene: Scene);
  53950. /**
  53951. * Registers the component in a given scene
  53952. */
  53953. register(): void;
  53954. /**
  53955. * Rebuilds the elements related to this component in case of
  53956. * context lost for instance.
  53957. */
  53958. rebuild(): void;
  53959. /**
  53960. * Disposes the component and the associated ressources
  53961. */
  53962. dispose(): void;
  53963. }
  53964. }
  53965. declare module "babylonjs/Physics/physicsHelper" {
  53966. import { Nullable } from "babylonjs/types";
  53967. import { Vector3 } from "babylonjs/Maths/math";
  53968. import { Mesh } from "babylonjs/Meshes/mesh";
  53969. import { Scene } from "babylonjs/scene";
  53970. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53971. /**
  53972. * A helper for physics simulations
  53973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53974. */
  53975. export class PhysicsHelper {
  53976. private _scene;
  53977. private _physicsEngine;
  53978. /**
  53979. * Initializes the Physics helper
  53980. * @param scene Babylon.js scene
  53981. */
  53982. constructor(scene: Scene);
  53983. /**
  53984. * Applies a radial explosion impulse
  53985. * @param origin the origin of the explosion
  53986. * @param radiusOrEventOptions the radius or the options of radial explosion
  53987. * @param strength the explosion strength
  53988. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53989. * @returns A physics radial explosion event, or null
  53990. */
  53991. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53992. /**
  53993. * Applies a radial explosion force
  53994. * @param origin the origin of the explosion
  53995. * @param radiusOrEventOptions the radius or the options of radial explosion
  53996. * @param strength the explosion strength
  53997. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53998. * @returns A physics radial explosion event, or null
  53999. */
  54000. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54001. /**
  54002. * Creates a gravitational field
  54003. * @param origin the origin of the explosion
  54004. * @param radiusOrEventOptions the radius or the options of radial explosion
  54005. * @param strength the explosion strength
  54006. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54007. * @returns A physics gravitational field event, or null
  54008. */
  54009. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54010. /**
  54011. * Creates a physics updraft event
  54012. * @param origin the origin of the updraft
  54013. * @param radiusOrEventOptions the radius or the options of the updraft
  54014. * @param strength the strength of the updraft
  54015. * @param height the height of the updraft
  54016. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54017. * @returns A physics updraft event, or null
  54018. */
  54019. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54020. /**
  54021. * Creates a physics vortex event
  54022. * @param origin the of the vortex
  54023. * @param radiusOrEventOptions the radius or the options of the vortex
  54024. * @param strength the strength of the vortex
  54025. * @param height the height of the vortex
  54026. * @returns a Physics vortex event, or null
  54027. * A physics vortex event or null
  54028. */
  54029. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54030. }
  54031. /**
  54032. * Represents a physics radial explosion event
  54033. */
  54034. class PhysicsRadialExplosionEvent {
  54035. private _scene;
  54036. private _options;
  54037. private _sphere;
  54038. private _dataFetched;
  54039. /**
  54040. * Initializes a radial explosioin event
  54041. * @param _scene BabylonJS scene
  54042. * @param _options The options for the vortex event
  54043. */
  54044. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54045. /**
  54046. * Returns the data related to the radial explosion event (sphere).
  54047. * @returns The radial explosion event data
  54048. */
  54049. getData(): PhysicsRadialExplosionEventData;
  54050. /**
  54051. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54052. * @param impostor A physics imposter
  54053. * @param origin the origin of the explosion
  54054. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54055. */
  54056. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54057. /**
  54058. * Triggers affecterd impostors callbacks
  54059. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54060. */
  54061. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54062. /**
  54063. * Disposes the sphere.
  54064. * @param force Specifies if the sphere should be disposed by force
  54065. */
  54066. dispose(force?: boolean): void;
  54067. /*** Helpers ***/
  54068. private _prepareSphere;
  54069. private _intersectsWithSphere;
  54070. }
  54071. /**
  54072. * Represents a gravitational field event
  54073. */
  54074. class PhysicsGravitationalFieldEvent {
  54075. private _physicsHelper;
  54076. private _scene;
  54077. private _origin;
  54078. private _options;
  54079. private _tickCallback;
  54080. private _sphere;
  54081. private _dataFetched;
  54082. /**
  54083. * Initializes the physics gravitational field event
  54084. * @param _physicsHelper A physics helper
  54085. * @param _scene BabylonJS scene
  54086. * @param _origin The origin position of the gravitational field event
  54087. * @param _options The options for the vortex event
  54088. */
  54089. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54090. /**
  54091. * Returns the data related to the gravitational field event (sphere).
  54092. * @returns A gravitational field event
  54093. */
  54094. getData(): PhysicsGravitationalFieldEventData;
  54095. /**
  54096. * Enables the gravitational field.
  54097. */
  54098. enable(): void;
  54099. /**
  54100. * Disables the gravitational field.
  54101. */
  54102. disable(): void;
  54103. /**
  54104. * Disposes the sphere.
  54105. * @param force The force to dispose from the gravitational field event
  54106. */
  54107. dispose(force?: boolean): void;
  54108. private _tick;
  54109. }
  54110. /**
  54111. * Represents a physics updraft event
  54112. */
  54113. class PhysicsUpdraftEvent {
  54114. private _scene;
  54115. private _origin;
  54116. private _options;
  54117. private _physicsEngine;
  54118. private _originTop;
  54119. private _originDirection;
  54120. private _tickCallback;
  54121. private _cylinder;
  54122. private _cylinderPosition;
  54123. private _dataFetched;
  54124. /**
  54125. * Initializes the physics updraft event
  54126. * @param _scene BabylonJS scene
  54127. * @param _origin The origin position of the updraft
  54128. * @param _options The options for the updraft event
  54129. */
  54130. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54131. /**
  54132. * Returns the data related to the updraft event (cylinder).
  54133. * @returns A physics updraft event
  54134. */
  54135. getData(): PhysicsUpdraftEventData;
  54136. /**
  54137. * Enables the updraft.
  54138. */
  54139. enable(): void;
  54140. /**
  54141. * Disables the updraft.
  54142. */
  54143. disable(): void;
  54144. /**
  54145. * Disposes the cylinder.
  54146. * @param force Specifies if the updraft should be disposed by force
  54147. */
  54148. dispose(force?: boolean): void;
  54149. private getImpostorHitData;
  54150. private _tick;
  54151. /*** Helpers ***/
  54152. private _prepareCylinder;
  54153. private _intersectsWithCylinder;
  54154. }
  54155. /**
  54156. * Represents a physics vortex event
  54157. */
  54158. class PhysicsVortexEvent {
  54159. private _scene;
  54160. private _origin;
  54161. private _options;
  54162. private _physicsEngine;
  54163. private _originTop;
  54164. private _tickCallback;
  54165. private _cylinder;
  54166. private _cylinderPosition;
  54167. private _dataFetched;
  54168. /**
  54169. * Initializes the physics vortex event
  54170. * @param _scene The BabylonJS scene
  54171. * @param _origin The origin position of the vortex
  54172. * @param _options The options for the vortex event
  54173. */
  54174. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54175. /**
  54176. * Returns the data related to the vortex event (cylinder).
  54177. * @returns The physics vortex event data
  54178. */
  54179. getData(): PhysicsVortexEventData;
  54180. /**
  54181. * Enables the vortex.
  54182. */
  54183. enable(): void;
  54184. /**
  54185. * Disables the cortex.
  54186. */
  54187. disable(): void;
  54188. /**
  54189. * Disposes the sphere.
  54190. * @param force
  54191. */
  54192. dispose(force?: boolean): void;
  54193. private getImpostorHitData;
  54194. private _tick;
  54195. /*** Helpers ***/
  54196. private _prepareCylinder;
  54197. private _intersectsWithCylinder;
  54198. }
  54199. /**
  54200. * Options fot the radial explosion event
  54201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54202. */
  54203. export class PhysicsRadialExplosionEventOptions {
  54204. /**
  54205. * The radius of the sphere for the radial explosion.
  54206. */
  54207. radius: number;
  54208. /**
  54209. * The strenth of the explosion.
  54210. */
  54211. strength: number;
  54212. /**
  54213. * The strenght of the force in correspondence to the distance of the affected object
  54214. */
  54215. falloff: PhysicsRadialImpulseFalloff;
  54216. /**
  54217. * Sphere options for the radial explosion.
  54218. */
  54219. sphere: {
  54220. segments: number;
  54221. diameter: number;
  54222. };
  54223. /**
  54224. * Sphere options for the radial explosion.
  54225. */
  54226. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54227. }
  54228. /**
  54229. * Options fot the updraft event
  54230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54231. */
  54232. export class PhysicsUpdraftEventOptions {
  54233. /**
  54234. * The radius of the cylinder for the vortex
  54235. */
  54236. radius: number;
  54237. /**
  54238. * The strenth of the updraft.
  54239. */
  54240. strength: number;
  54241. /**
  54242. * The height of the cylinder for the updraft.
  54243. */
  54244. height: number;
  54245. /**
  54246. * The mode for the the updraft.
  54247. */
  54248. updraftMode: PhysicsUpdraftMode;
  54249. }
  54250. /**
  54251. * Options fot the vortex event
  54252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54253. */
  54254. export class PhysicsVortexEventOptions {
  54255. /**
  54256. * The radius of the cylinder for the vortex
  54257. */
  54258. radius: number;
  54259. /**
  54260. * The strenth of the vortex.
  54261. */
  54262. strength: number;
  54263. /**
  54264. * The height of the cylinder for the vortex.
  54265. */
  54266. height: number;
  54267. /**
  54268. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54269. */
  54270. centripetalForceThreshold: number;
  54271. /**
  54272. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54273. */
  54274. centripetalForceMultiplier: number;
  54275. /**
  54276. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54277. */
  54278. centrifugalForceMultiplier: number;
  54279. /**
  54280. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54281. */
  54282. updraftForceMultiplier: number;
  54283. }
  54284. /**
  54285. * The strenght of the force in correspondence to the distance of the affected object
  54286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54287. */
  54288. export enum PhysicsRadialImpulseFalloff {
  54289. /** Defines that impulse is constant in strength across it's whole radius */
  54290. Constant = 0,
  54291. /** Defines that impulse gets weaker if it's further from the origin */
  54292. Linear = 1
  54293. }
  54294. /**
  54295. * The strength of the force in correspondence to the distance of the affected object
  54296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54297. */
  54298. export enum PhysicsUpdraftMode {
  54299. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54300. Center = 0,
  54301. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54302. Perpendicular = 1
  54303. }
  54304. /**
  54305. * Interface for a physics hit data
  54306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54307. */
  54308. export interface PhysicsHitData {
  54309. /**
  54310. * The force applied at the contact point
  54311. */
  54312. force: Vector3;
  54313. /**
  54314. * The contact point
  54315. */
  54316. contactPoint: Vector3;
  54317. /**
  54318. * The distance from the origin to the contact point
  54319. */
  54320. distanceFromOrigin: number;
  54321. }
  54322. /**
  54323. * Interface for radial explosion event data
  54324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54325. */
  54326. export interface PhysicsRadialExplosionEventData {
  54327. /**
  54328. * A sphere used for the radial explosion event
  54329. */
  54330. sphere: Mesh;
  54331. }
  54332. /**
  54333. * Interface for gravitational field event data
  54334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54335. */
  54336. export interface PhysicsGravitationalFieldEventData {
  54337. /**
  54338. * A sphere mesh used for the gravitational field event
  54339. */
  54340. sphere: Mesh;
  54341. }
  54342. /**
  54343. * Interface for updraft event data
  54344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54345. */
  54346. export interface PhysicsUpdraftEventData {
  54347. /**
  54348. * A cylinder used for the updraft event
  54349. */
  54350. cylinder: Mesh;
  54351. }
  54352. /**
  54353. * Interface for vortex event data
  54354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54355. */
  54356. export interface PhysicsVortexEventData {
  54357. /**
  54358. * A cylinder used for the vortex event
  54359. */
  54360. cylinder: Mesh;
  54361. }
  54362. /**
  54363. * Interface for an affected physics impostor
  54364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54365. */
  54366. export interface PhysicsAffectedImpostorWithData {
  54367. /**
  54368. * The impostor affected by the effect
  54369. */
  54370. impostor: PhysicsImpostor;
  54371. /**
  54372. * The data about the hit/horce from the explosion
  54373. */
  54374. hitData: PhysicsHitData;
  54375. }
  54376. }
  54377. declare module "babylonjs/Physics/Plugins/index" {
  54378. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54379. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54380. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54381. }
  54382. declare module "babylonjs/Physics/index" {
  54383. export * from "babylonjs/Physics/IPhysicsEngine";
  54384. export * from "babylonjs/Physics/physicsEngine";
  54385. export * from "babylonjs/Physics/physicsEngineComponent";
  54386. export * from "babylonjs/Physics/physicsHelper";
  54387. export * from "babylonjs/Physics/physicsImpostor";
  54388. export * from "babylonjs/Physics/physicsJoint";
  54389. export * from "babylonjs/Physics/Plugins/index";
  54390. }
  54391. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54392. /** @hidden */
  54393. export var blackAndWhitePixelShader: {
  54394. name: string;
  54395. shader: string;
  54396. };
  54397. }
  54398. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54399. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54400. import { Camera } from "babylonjs/Cameras/camera";
  54401. import { Engine } from "babylonjs/Engines/engine";
  54402. import "babylonjs/Shaders/blackAndWhite.fragment";
  54403. /**
  54404. * Post process used to render in black and white
  54405. */
  54406. export class BlackAndWhitePostProcess extends PostProcess {
  54407. /**
  54408. * Linear about to convert he result to black and white (default: 1)
  54409. */
  54410. degree: number;
  54411. /**
  54412. * Creates a black and white post process
  54413. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54414. * @param name The name of the effect.
  54415. * @param options The required width/height ratio to downsize to before computing the render pass.
  54416. * @param camera The camera to apply the render pass to.
  54417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54418. * @param engine The engine which the post process will be applied. (default: current engine)
  54419. * @param reusable If the post process can be reused on the same frame. (default: false)
  54420. */
  54421. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54422. }
  54423. }
  54424. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54425. import { Nullable } from "babylonjs/types";
  54426. import { Camera } from "babylonjs/Cameras/camera";
  54427. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54428. import { Engine } from "babylonjs/Engines/engine";
  54429. /**
  54430. * This represents a set of one or more post processes in Babylon.
  54431. * A post process can be used to apply a shader to a texture after it is rendered.
  54432. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54433. */
  54434. export class PostProcessRenderEffect {
  54435. private _postProcesses;
  54436. private _getPostProcesses;
  54437. private _singleInstance;
  54438. private _cameras;
  54439. private _indicesForCamera;
  54440. /**
  54441. * Name of the effect
  54442. * @hidden
  54443. */
  54444. _name: string;
  54445. /**
  54446. * Instantiates a post process render effect.
  54447. * A post process can be used to apply a shader to a texture after it is rendered.
  54448. * @param engine The engine the effect is tied to
  54449. * @param name The name of the effect
  54450. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54451. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54452. */
  54453. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54454. /**
  54455. * Checks if all the post processes in the effect are supported.
  54456. */
  54457. readonly isSupported: boolean;
  54458. /**
  54459. * Updates the current state of the effect
  54460. * @hidden
  54461. */
  54462. _update(): void;
  54463. /**
  54464. * Attaches the effect on cameras
  54465. * @param cameras The camera to attach to.
  54466. * @hidden
  54467. */
  54468. _attachCameras(cameras: Camera): void;
  54469. /**
  54470. * Attaches the effect on cameras
  54471. * @param cameras The camera to attach to.
  54472. * @hidden
  54473. */
  54474. _attachCameras(cameras: Camera[]): void;
  54475. /**
  54476. * Detatches the effect on cameras
  54477. * @param cameras The camera to detatch from.
  54478. * @hidden
  54479. */
  54480. _detachCameras(cameras: Camera): void;
  54481. /**
  54482. * Detatches the effect on cameras
  54483. * @param cameras The camera to detatch from.
  54484. * @hidden
  54485. */
  54486. _detachCameras(cameras: Camera[]): void;
  54487. /**
  54488. * Enables the effect on given cameras
  54489. * @param cameras The camera to enable.
  54490. * @hidden
  54491. */
  54492. _enable(cameras: Camera): void;
  54493. /**
  54494. * Enables the effect on given cameras
  54495. * @param cameras The camera to enable.
  54496. * @hidden
  54497. */
  54498. _enable(cameras: Nullable<Camera[]>): void;
  54499. /**
  54500. * Disables the effect on the given cameras
  54501. * @param cameras The camera to disable.
  54502. * @hidden
  54503. */
  54504. _disable(cameras: Camera): void;
  54505. /**
  54506. * Disables the effect on the given cameras
  54507. * @param cameras The camera to disable.
  54508. * @hidden
  54509. */
  54510. _disable(cameras: Nullable<Camera[]>): void;
  54511. /**
  54512. * Gets a list of the post processes contained in the effect.
  54513. * @param camera The camera to get the post processes on.
  54514. * @returns The list of the post processes in the effect.
  54515. */
  54516. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54517. }
  54518. }
  54519. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54520. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54521. /** @hidden */
  54522. export var extractHighlightsPixelShader: {
  54523. name: string;
  54524. shader: string;
  54525. };
  54526. }
  54527. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54528. import { Nullable } from "babylonjs/types";
  54529. import { Camera } from "babylonjs/Cameras/camera";
  54530. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54531. import { Engine } from "babylonjs/Engines/engine";
  54532. import "babylonjs/Shaders/extractHighlights.fragment";
  54533. /**
  54534. * 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.
  54535. */
  54536. export class ExtractHighlightsPostProcess extends PostProcess {
  54537. /**
  54538. * The luminance threshold, pixels below this value will be set to black.
  54539. */
  54540. threshold: number;
  54541. /** @hidden */
  54542. _exposure: number;
  54543. /**
  54544. * Post process which has the input texture to be used when performing highlight extraction
  54545. * @hidden
  54546. */
  54547. _inputPostProcess: Nullable<PostProcess>;
  54548. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54549. }
  54550. }
  54551. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54552. /** @hidden */
  54553. export var bloomMergePixelShader: {
  54554. name: string;
  54555. shader: string;
  54556. };
  54557. }
  54558. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54559. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54560. import { Nullable } from "babylonjs/types";
  54561. import { Engine } from "babylonjs/Engines/engine";
  54562. import { Camera } from "babylonjs/Cameras/camera";
  54563. import "babylonjs/Shaders/bloomMerge.fragment";
  54564. /**
  54565. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54566. */
  54567. export class BloomMergePostProcess extends PostProcess {
  54568. /** Weight of the bloom to be added to the original input. */
  54569. weight: number;
  54570. /**
  54571. * Creates a new instance of @see BloomMergePostProcess
  54572. * @param name The name of the effect.
  54573. * @param originalFromInput Post process which's input will be used for the merge.
  54574. * @param blurred Blurred highlights post process which's output will be used.
  54575. * @param weight Weight of the bloom to be added to the original input.
  54576. * @param options The required width/height ratio to downsize to before computing the render pass.
  54577. * @param camera The camera to apply the render pass to.
  54578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54579. * @param engine The engine which the post process will be applied. (default: current engine)
  54580. * @param reusable If the post process can be reused on the same frame. (default: false)
  54581. * @param textureType Type of textures used when performing the post process. (default: 0)
  54582. * @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)
  54583. */
  54584. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54585. /** Weight of the bloom to be added to the original input. */
  54586. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54587. }
  54588. }
  54589. declare module "babylonjs/PostProcesses/bloomEffect" {
  54590. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54591. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54592. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54593. import { Camera } from "babylonjs/Cameras/camera";
  54594. import { Scene } from "babylonjs/scene";
  54595. /**
  54596. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54597. */
  54598. export class BloomEffect extends PostProcessRenderEffect {
  54599. private bloomScale;
  54600. /**
  54601. * @hidden Internal
  54602. */
  54603. _effects: Array<PostProcess>;
  54604. /**
  54605. * @hidden Internal
  54606. */
  54607. _downscale: ExtractHighlightsPostProcess;
  54608. private _blurX;
  54609. private _blurY;
  54610. private _merge;
  54611. /**
  54612. * The luminance threshold to find bright areas of the image to bloom.
  54613. */
  54614. threshold: number;
  54615. /**
  54616. * The strength of the bloom.
  54617. */
  54618. weight: number;
  54619. /**
  54620. * Specifies the size of the bloom blur kernel, relative to the final output size
  54621. */
  54622. kernel: number;
  54623. /**
  54624. * Creates a new instance of @see BloomEffect
  54625. * @param scene The scene the effect belongs to.
  54626. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54627. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54628. * @param bloomWeight The the strength of bloom.
  54629. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54630. * @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)
  54631. */
  54632. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54633. /**
  54634. * Disposes each of the internal effects for a given camera.
  54635. * @param camera The camera to dispose the effect on.
  54636. */
  54637. disposeEffects(camera: Camera): void;
  54638. /**
  54639. * @hidden Internal
  54640. */
  54641. _updateEffects(): void;
  54642. /**
  54643. * Internal
  54644. * @returns if all the contained post processes are ready.
  54645. * @hidden
  54646. */
  54647. _isReady(): boolean;
  54648. }
  54649. }
  54650. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54651. /** @hidden */
  54652. export var chromaticAberrationPixelShader: {
  54653. name: string;
  54654. shader: string;
  54655. };
  54656. }
  54657. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54658. import { Vector2 } from "babylonjs/Maths/math";
  54659. import { Nullable } from "babylonjs/types";
  54660. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54661. import { Camera } from "babylonjs/Cameras/camera";
  54662. import { Engine } from "babylonjs/Engines/engine";
  54663. import "babylonjs/Shaders/chromaticAberration.fragment";
  54664. /**
  54665. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54666. */
  54667. export class ChromaticAberrationPostProcess extends PostProcess {
  54668. /**
  54669. * The amount of seperation of rgb channels (default: 30)
  54670. */
  54671. aberrationAmount: number;
  54672. /**
  54673. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54674. */
  54675. radialIntensity: number;
  54676. /**
  54677. * 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))
  54678. */
  54679. direction: Vector2;
  54680. /**
  54681. * 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))
  54682. */
  54683. centerPosition: Vector2;
  54684. /**
  54685. * Creates a new instance ChromaticAberrationPostProcess
  54686. * @param name The name of the effect.
  54687. * @param screenWidth The width of the screen to apply the effect on.
  54688. * @param screenHeight The height of the screen to apply the effect on.
  54689. * @param options The required width/height ratio to downsize to before computing the render pass.
  54690. * @param camera The camera to apply the render pass to.
  54691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54692. * @param engine The engine which the post process will be applied. (default: current engine)
  54693. * @param reusable If the post process can be reused on the same frame. (default: false)
  54694. * @param textureType Type of textures used when performing the post process. (default: 0)
  54695. * @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)
  54696. */
  54697. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54698. }
  54699. }
  54700. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54701. /** @hidden */
  54702. export var circleOfConfusionPixelShader: {
  54703. name: string;
  54704. shader: string;
  54705. };
  54706. }
  54707. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54708. import { Nullable } from "babylonjs/types";
  54709. import { Engine } from "babylonjs/Engines/engine";
  54710. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54711. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54712. import { Camera } from "babylonjs/Cameras/camera";
  54713. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54714. /**
  54715. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54716. */
  54717. export class CircleOfConfusionPostProcess extends PostProcess {
  54718. /**
  54719. * 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.
  54720. */
  54721. lensSize: number;
  54722. /**
  54723. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54724. */
  54725. fStop: number;
  54726. /**
  54727. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54728. */
  54729. focusDistance: number;
  54730. /**
  54731. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54732. */
  54733. focalLength: number;
  54734. private _depthTexture;
  54735. /**
  54736. * Creates a new instance CircleOfConfusionPostProcess
  54737. * @param name The name of the effect.
  54738. * @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.
  54739. * @param options The required width/height ratio to downsize to before computing the render pass.
  54740. * @param camera The camera to apply the render pass to.
  54741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54742. * @param engine The engine which the post process will be applied. (default: current engine)
  54743. * @param reusable If the post process can be reused on the same frame. (default: false)
  54744. * @param textureType Type of textures used when performing the post process. (default: 0)
  54745. * @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)
  54746. */
  54747. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54748. /**
  54749. * 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.
  54750. */
  54751. depthTexture: RenderTargetTexture;
  54752. }
  54753. }
  54754. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54755. /** @hidden */
  54756. export var colorCorrectionPixelShader: {
  54757. name: string;
  54758. shader: string;
  54759. };
  54760. }
  54761. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54762. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54763. import { Engine } from "babylonjs/Engines/engine";
  54764. import { Camera } from "babylonjs/Cameras/camera";
  54765. import "babylonjs/Shaders/colorCorrection.fragment";
  54766. /**
  54767. *
  54768. * This post-process allows the modification of rendered colors by using
  54769. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54770. *
  54771. * The object needs to be provided an url to a texture containing the color
  54772. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54773. * Use an image editing software to tweak the LUT to match your needs.
  54774. *
  54775. * For an example of a color LUT, see here:
  54776. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54777. * For explanations on color grading, see here:
  54778. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54779. *
  54780. */
  54781. export class ColorCorrectionPostProcess extends PostProcess {
  54782. private _colorTableTexture;
  54783. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54784. }
  54785. }
  54786. declare module "babylonjs/Shaders/convolution.fragment" {
  54787. /** @hidden */
  54788. export var convolutionPixelShader: {
  54789. name: string;
  54790. shader: string;
  54791. };
  54792. }
  54793. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54794. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54795. import { Nullable } from "babylonjs/types";
  54796. import { Camera } from "babylonjs/Cameras/camera";
  54797. import { Engine } from "babylonjs/Engines/engine";
  54798. import "babylonjs/Shaders/convolution.fragment";
  54799. /**
  54800. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54801. * input texture to perform effects such as edge detection or sharpening
  54802. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54803. */
  54804. export class ConvolutionPostProcess extends PostProcess {
  54805. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54806. kernel: number[];
  54807. /**
  54808. * Creates a new instance ConvolutionPostProcess
  54809. * @param name The name of the effect.
  54810. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54811. * @param options The required width/height ratio to downsize to before computing the render pass.
  54812. * @param camera The camera to apply the render pass to.
  54813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54814. * @param engine The engine which the post process will be applied. (default: current engine)
  54815. * @param reusable If the post process can be reused on the same frame. (default: false)
  54816. * @param textureType Type of textures used when performing the post process. (default: 0)
  54817. */
  54818. constructor(name: string,
  54819. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54820. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54821. /**
  54822. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54823. */
  54824. static EdgeDetect0Kernel: number[];
  54825. /**
  54826. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54827. */
  54828. static EdgeDetect1Kernel: number[];
  54829. /**
  54830. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54831. */
  54832. static EdgeDetect2Kernel: number[];
  54833. /**
  54834. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54835. */
  54836. static SharpenKernel: number[];
  54837. /**
  54838. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54839. */
  54840. static EmbossKernel: number[];
  54841. /**
  54842. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54843. */
  54844. static GaussianKernel: number[];
  54845. }
  54846. }
  54847. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54848. import { Nullable } from "babylonjs/types";
  54849. import { Vector2 } from "babylonjs/Maths/math";
  54850. import { Camera } from "babylonjs/Cameras/camera";
  54851. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54852. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54853. import { Engine } from "babylonjs/Engines/engine";
  54854. import { Scene } from "babylonjs/scene";
  54855. /**
  54856. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54857. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54858. * based on samples that have a large difference in distance than the center pixel.
  54859. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54860. */
  54861. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54862. direction: Vector2;
  54863. /**
  54864. * Creates a new instance CircleOfConfusionPostProcess
  54865. * @param name The name of the effect.
  54866. * @param scene The scene the effect belongs to.
  54867. * @param direction The direction the blur should be applied.
  54868. * @param kernel The size of the kernel used to blur.
  54869. * @param options The required width/height ratio to downsize to before computing the render pass.
  54870. * @param camera The camera to apply the render pass to.
  54871. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54872. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54874. * @param engine The engine which the post process will be applied. (default: current engine)
  54875. * @param reusable If the post process can be reused on the same frame. (default: false)
  54876. * @param textureType Type of textures used when performing the post process. (default: 0)
  54877. * @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)
  54878. */
  54879. 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);
  54880. }
  54881. }
  54882. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54883. /** @hidden */
  54884. export var depthOfFieldMergePixelShader: {
  54885. name: string;
  54886. shader: string;
  54887. };
  54888. }
  54889. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54890. import { Nullable } from "babylonjs/types";
  54891. import { Camera } from "babylonjs/Cameras/camera";
  54892. import { Effect } from "babylonjs/Materials/effect";
  54893. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54894. import { Engine } from "babylonjs/Engines/engine";
  54895. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54896. /**
  54897. * Options to be set when merging outputs from the default pipeline.
  54898. */
  54899. export class DepthOfFieldMergePostProcessOptions {
  54900. /**
  54901. * The original image to merge on top of
  54902. */
  54903. originalFromInput: PostProcess;
  54904. /**
  54905. * Parameters to perform the merge of the depth of field effect
  54906. */
  54907. depthOfField?: {
  54908. circleOfConfusion: PostProcess;
  54909. blurSteps: Array<PostProcess>;
  54910. };
  54911. /**
  54912. * Parameters to perform the merge of bloom effect
  54913. */
  54914. bloom?: {
  54915. blurred: PostProcess;
  54916. weight: number;
  54917. };
  54918. }
  54919. /**
  54920. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54921. */
  54922. export class DepthOfFieldMergePostProcess extends PostProcess {
  54923. private blurSteps;
  54924. /**
  54925. * Creates a new instance of DepthOfFieldMergePostProcess
  54926. * @param name The name of the effect.
  54927. * @param originalFromInput Post process which's input will be used for the merge.
  54928. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54929. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54930. * @param options The required width/height ratio to downsize to before computing the render pass.
  54931. * @param camera The camera to apply the render pass to.
  54932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54933. * @param engine The engine which the post process will be applied. (default: current engine)
  54934. * @param reusable If the post process can be reused on the same frame. (default: false)
  54935. * @param textureType Type of textures used when performing the post process. (default: 0)
  54936. * @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)
  54937. */
  54938. 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);
  54939. /**
  54940. * Updates the effect with the current post process compile time values and recompiles the shader.
  54941. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54942. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54943. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54944. * @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
  54945. * @param onCompiled Called when the shader has been compiled.
  54946. * @param onError Called if there is an error when compiling a shader.
  54947. */
  54948. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54949. }
  54950. }
  54951. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54952. import { Nullable } from "babylonjs/types";
  54953. import { Camera } from "babylonjs/Cameras/camera";
  54954. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54955. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54956. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54957. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54958. import { Scene } from "babylonjs/scene";
  54959. /**
  54960. * Specifies the level of max blur that should be applied when using the depth of field effect
  54961. */
  54962. export enum DepthOfFieldEffectBlurLevel {
  54963. /**
  54964. * Subtle blur
  54965. */
  54966. Low = 0,
  54967. /**
  54968. * Medium blur
  54969. */
  54970. Medium = 1,
  54971. /**
  54972. * Large blur
  54973. */
  54974. High = 2
  54975. }
  54976. /**
  54977. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54978. */
  54979. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54980. private _circleOfConfusion;
  54981. /**
  54982. * @hidden Internal, blurs from high to low
  54983. */
  54984. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54985. private _depthOfFieldBlurY;
  54986. private _dofMerge;
  54987. /**
  54988. * @hidden Internal post processes in depth of field effect
  54989. */
  54990. _effects: Array<PostProcess>;
  54991. /**
  54992. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54993. */
  54994. focalLength: number;
  54995. /**
  54996. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54997. */
  54998. fStop: number;
  54999. /**
  55000. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55001. */
  55002. focusDistance: number;
  55003. /**
  55004. * 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.
  55005. */
  55006. lensSize: number;
  55007. /**
  55008. * Creates a new instance DepthOfFieldEffect
  55009. * @param scene The scene the effect belongs to.
  55010. * @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.
  55011. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55012. * @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)
  55013. */
  55014. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55015. /**
  55016. * 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.
  55017. */
  55018. depthTexture: RenderTargetTexture;
  55019. /**
  55020. * Disposes each of the internal effects for a given camera.
  55021. * @param camera The camera to dispose the effect on.
  55022. */
  55023. disposeEffects(camera: Camera): void;
  55024. /**
  55025. * @hidden Internal
  55026. */
  55027. _updateEffects(): void;
  55028. /**
  55029. * Internal
  55030. * @returns if all the contained post processes are ready.
  55031. * @hidden
  55032. */
  55033. _isReady(): boolean;
  55034. }
  55035. }
  55036. declare module "babylonjs/Shaders/displayPass.fragment" {
  55037. /** @hidden */
  55038. export var displayPassPixelShader: {
  55039. name: string;
  55040. shader: string;
  55041. };
  55042. }
  55043. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55044. import { Nullable } from "babylonjs/types";
  55045. import { Camera } from "babylonjs/Cameras/camera";
  55046. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55047. import { Engine } from "babylonjs/Engines/engine";
  55048. import "babylonjs/Shaders/displayPass.fragment";
  55049. /**
  55050. * DisplayPassPostProcess which produces an output the same as it's input
  55051. */
  55052. export class DisplayPassPostProcess extends PostProcess {
  55053. /**
  55054. * Creates the DisplayPassPostProcess
  55055. * @param name The name of the effect.
  55056. * @param options The required width/height ratio to downsize to before computing the render pass.
  55057. * @param camera The camera to apply the render pass to.
  55058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55059. * @param engine The engine which the post process will be applied. (default: current engine)
  55060. * @param reusable If the post process can be reused on the same frame. (default: false)
  55061. */
  55062. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55063. }
  55064. }
  55065. declare module "babylonjs/Shaders/filter.fragment" {
  55066. /** @hidden */
  55067. export var filterPixelShader: {
  55068. name: string;
  55069. shader: string;
  55070. };
  55071. }
  55072. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55073. import { Nullable } from "babylonjs/types";
  55074. import { Matrix } from "babylonjs/Maths/math";
  55075. import { Camera } from "babylonjs/Cameras/camera";
  55076. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55077. import { Engine } from "babylonjs/Engines/engine";
  55078. import "babylonjs/Shaders/filter.fragment";
  55079. /**
  55080. * Applies a kernel filter to the image
  55081. */
  55082. export class FilterPostProcess extends PostProcess {
  55083. /** The matrix to be applied to the image */
  55084. kernelMatrix: Matrix;
  55085. /**
  55086. *
  55087. * @param name The name of the effect.
  55088. * @param kernelMatrix The matrix to be applied to the image
  55089. * @param options The required width/height ratio to downsize to before computing the render pass.
  55090. * @param camera The camera to apply the render pass to.
  55091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55092. * @param engine The engine which the post process will be applied. (default: current engine)
  55093. * @param reusable If the post process can be reused on the same frame. (default: false)
  55094. */
  55095. constructor(name: string,
  55096. /** The matrix to be applied to the image */
  55097. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55098. }
  55099. }
  55100. declare module "babylonjs/Shaders/fxaa.fragment" {
  55101. /** @hidden */
  55102. export var fxaaPixelShader: {
  55103. name: string;
  55104. shader: string;
  55105. };
  55106. }
  55107. declare module "babylonjs/Shaders/fxaa.vertex" {
  55108. /** @hidden */
  55109. export var fxaaVertexShader: {
  55110. name: string;
  55111. shader: string;
  55112. };
  55113. }
  55114. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55115. import { Nullable } from "babylonjs/types";
  55116. import { Camera } from "babylonjs/Cameras/camera";
  55117. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55118. import { Engine } from "babylonjs/Engines/engine";
  55119. import "babylonjs/Shaders/fxaa.fragment";
  55120. import "babylonjs/Shaders/fxaa.vertex";
  55121. /**
  55122. * Fxaa post process
  55123. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55124. */
  55125. export class FxaaPostProcess extends PostProcess {
  55126. /** @hidden */
  55127. texelWidth: number;
  55128. /** @hidden */
  55129. texelHeight: number;
  55130. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55131. private _getDefines;
  55132. }
  55133. }
  55134. declare module "babylonjs/Shaders/grain.fragment" {
  55135. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55136. /** @hidden */
  55137. export var grainPixelShader: {
  55138. name: string;
  55139. shader: string;
  55140. };
  55141. }
  55142. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55143. import { Nullable } from "babylonjs/types";
  55144. import { Camera } from "babylonjs/Cameras/camera";
  55145. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55146. import { Engine } from "babylonjs/Engines/engine";
  55147. import "babylonjs/Shaders/grain.fragment";
  55148. /**
  55149. * The GrainPostProcess adds noise to the image at mid luminance levels
  55150. */
  55151. export class GrainPostProcess extends PostProcess {
  55152. /**
  55153. * The intensity of the grain added (default: 30)
  55154. */
  55155. intensity: number;
  55156. /**
  55157. * If the grain should be randomized on every frame
  55158. */
  55159. animated: boolean;
  55160. /**
  55161. * Creates a new instance of @see GrainPostProcess
  55162. * @param name The name of the effect.
  55163. * @param options The required width/height ratio to downsize to before computing the render pass.
  55164. * @param camera The camera to apply the render pass to.
  55165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55166. * @param engine The engine which the post process will be applied. (default: current engine)
  55167. * @param reusable If the post process can be reused on the same frame. (default: false)
  55168. * @param textureType Type of textures used when performing the post process. (default: 0)
  55169. * @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)
  55170. */
  55171. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55172. }
  55173. }
  55174. declare module "babylonjs/Shaders/highlights.fragment" {
  55175. /** @hidden */
  55176. export var highlightsPixelShader: {
  55177. name: string;
  55178. shader: string;
  55179. };
  55180. }
  55181. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55182. import { Nullable } from "babylonjs/types";
  55183. import { Camera } from "babylonjs/Cameras/camera";
  55184. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55185. import { Engine } from "babylonjs/Engines/engine";
  55186. import "babylonjs/Shaders/highlights.fragment";
  55187. /**
  55188. * Extracts highlights from the image
  55189. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55190. */
  55191. export class HighlightsPostProcess extends PostProcess {
  55192. /**
  55193. * Extracts highlights from the image
  55194. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55195. * @param name The name of the effect.
  55196. * @param options The required width/height ratio to downsize to before computing the render pass.
  55197. * @param camera The camera to apply the render pass to.
  55198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55199. * @param engine The engine which the post process will be applied. (default: current engine)
  55200. * @param reusable If the post process can be reused on the same frame. (default: false)
  55201. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55202. */
  55203. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55204. }
  55205. }
  55206. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55207. /** @hidden */
  55208. export var mrtFragmentDeclaration: {
  55209. name: string;
  55210. shader: string;
  55211. };
  55212. }
  55213. declare module "babylonjs/Shaders/geometry.fragment" {
  55214. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55215. /** @hidden */
  55216. export var geometryPixelShader: {
  55217. name: string;
  55218. shader: string;
  55219. };
  55220. }
  55221. declare module "babylonjs/Shaders/geometry.vertex" {
  55222. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55223. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55224. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55225. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55226. /** @hidden */
  55227. export var geometryVertexShader: {
  55228. name: string;
  55229. shader: string;
  55230. };
  55231. }
  55232. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55233. import { Matrix } from "babylonjs/Maths/math";
  55234. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55235. import { Mesh } from "babylonjs/Meshes/mesh";
  55236. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55237. import { Effect } from "babylonjs/Materials/effect";
  55238. import { Scene } from "babylonjs/scene";
  55239. import "babylonjs/Shaders/geometry.fragment";
  55240. import "babylonjs/Shaders/geometry.vertex";
  55241. /**
  55242. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55243. */
  55244. export class GeometryBufferRenderer {
  55245. /**
  55246. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55247. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55248. */
  55249. static readonly POSITION_TEXTURE_TYPE: number;
  55250. /**
  55251. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55252. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55253. */
  55254. static readonly VELOCITY_TEXTURE_TYPE: number;
  55255. /**
  55256. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55257. * in order to compute objects velocities when enableVelocity is set to "true"
  55258. * @hidden
  55259. */
  55260. _previousTransformationMatrices: {
  55261. [index: number]: Matrix;
  55262. };
  55263. private _scene;
  55264. private _multiRenderTarget;
  55265. private _ratio;
  55266. private _enablePosition;
  55267. private _enableVelocity;
  55268. private _positionIndex;
  55269. private _velocityIndex;
  55270. protected _effect: Effect;
  55271. protected _cachedDefines: string;
  55272. /**
  55273. * Set the render list (meshes to be rendered) used in the G buffer.
  55274. */
  55275. renderList: Mesh[];
  55276. /**
  55277. * Gets wether or not G buffer are supported by the running hardware.
  55278. * This requires draw buffer supports
  55279. */
  55280. readonly isSupported: boolean;
  55281. /**
  55282. * Returns the index of the given texture type in the G-Buffer textures array
  55283. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55284. * @returns the index of the given texture type in the G-Buffer textures array
  55285. */
  55286. getTextureIndex(textureType: number): number;
  55287. /**
  55288. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55289. */
  55290. /**
  55291. * Sets whether or not objects positions are enabled for the G buffer.
  55292. */
  55293. enablePosition: boolean;
  55294. /**
  55295. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55296. */
  55297. /**
  55298. * Sets wether or not objects velocities are enabled for the G buffer.
  55299. */
  55300. enableVelocity: boolean;
  55301. /**
  55302. * Gets the scene associated with the buffer.
  55303. */
  55304. readonly scene: Scene;
  55305. /**
  55306. * Gets the ratio used by the buffer during its creation.
  55307. * How big is the buffer related to the main canvas.
  55308. */
  55309. readonly ratio: number;
  55310. /** @hidden */
  55311. static _SceneComponentInitialization: (scene: Scene) => void;
  55312. /**
  55313. * Creates a new G Buffer for the scene
  55314. * @param scene The scene the buffer belongs to
  55315. * @param ratio How big is the buffer related to the main canvas.
  55316. */
  55317. constructor(scene: Scene, ratio?: number);
  55318. /**
  55319. * Checks wether everything is ready to render a submesh to the G buffer.
  55320. * @param subMesh the submesh to check readiness for
  55321. * @param useInstances is the mesh drawn using instance or not
  55322. * @returns true if ready otherwise false
  55323. */
  55324. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55325. /**
  55326. * Gets the current underlying G Buffer.
  55327. * @returns the buffer
  55328. */
  55329. getGBuffer(): MultiRenderTarget;
  55330. /**
  55331. * Gets the number of samples used to render the buffer (anti aliasing).
  55332. */
  55333. /**
  55334. * Sets the number of samples used to render the buffer (anti aliasing).
  55335. */
  55336. samples: number;
  55337. /**
  55338. * Disposes the renderer and frees up associated resources.
  55339. */
  55340. dispose(): void;
  55341. protected _createRenderTargets(): void;
  55342. }
  55343. }
  55344. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55345. import { Nullable } from "babylonjs/types";
  55346. import { Scene } from "babylonjs/scene";
  55347. import { ISceneComponent } from "babylonjs/sceneComponent";
  55348. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55349. module "babylonjs/scene" {
  55350. interface Scene {
  55351. /** @hidden (Backing field) */
  55352. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55353. /**
  55354. * Gets or Sets the current geometry buffer associated to the scene.
  55355. */
  55356. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55357. /**
  55358. * Enables a GeometryBufferRender and associates it with the scene
  55359. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55360. * @returns the GeometryBufferRenderer
  55361. */
  55362. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55363. /**
  55364. * Disables the GeometryBufferRender associated with the scene
  55365. */
  55366. disableGeometryBufferRenderer(): void;
  55367. }
  55368. }
  55369. /**
  55370. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55371. * in several rendering techniques.
  55372. */
  55373. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55374. /**
  55375. * The component name helpful to identify the component in the list of scene components.
  55376. */
  55377. readonly name: string;
  55378. /**
  55379. * The scene the component belongs to.
  55380. */
  55381. scene: Scene;
  55382. /**
  55383. * Creates a new instance of the component for the given scene
  55384. * @param scene Defines the scene to register the component in
  55385. */
  55386. constructor(scene: Scene);
  55387. /**
  55388. * Registers the component in a given scene
  55389. */
  55390. register(): void;
  55391. /**
  55392. * Rebuilds the elements related to this component in case of
  55393. * context lost for instance.
  55394. */
  55395. rebuild(): void;
  55396. /**
  55397. * Disposes the component and the associated ressources
  55398. */
  55399. dispose(): void;
  55400. private _gatherRenderTargets;
  55401. }
  55402. }
  55403. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55404. /** @hidden */
  55405. export var motionBlurPixelShader: {
  55406. name: string;
  55407. shader: string;
  55408. };
  55409. }
  55410. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55411. import { Nullable } from "babylonjs/types";
  55412. import { Camera } from "babylonjs/Cameras/camera";
  55413. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55414. import { Scene } from "babylonjs/scene";
  55415. import "babylonjs/Animations/animatable";
  55416. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55417. import "babylonjs/Shaders/motionBlur.fragment";
  55418. import { Engine } from "babylonjs/Engines/engine";
  55419. /**
  55420. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55421. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55422. * As an example, all you have to do is to create the post-process:
  55423. * var mb = new BABYLON.MotionBlurPostProcess(
  55424. * 'mb', // The name of the effect.
  55425. * scene, // The scene containing the objects to blur according to their velocity.
  55426. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55427. * camera // The camera to apply the render pass to.
  55428. * );
  55429. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55430. */
  55431. export class MotionBlurPostProcess extends PostProcess {
  55432. /**
  55433. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55434. */
  55435. motionStrength: number;
  55436. /**
  55437. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55438. */
  55439. /**
  55440. * Sets the number of iterations to be used for motion blur quality
  55441. */
  55442. motionBlurSamples: number;
  55443. private _motionBlurSamples;
  55444. private _geometryBufferRenderer;
  55445. /**
  55446. * Creates a new instance MotionBlurPostProcess
  55447. * @param name The name of the effect.
  55448. * @param scene The scene containing the objects to blur according to their velocity.
  55449. * @param options The required width/height ratio to downsize to before computing the render pass.
  55450. * @param camera The camera to apply the render pass to.
  55451. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55452. * @param engine The engine which the post process will be applied. (default: current engine)
  55453. * @param reusable If the post process can be reused on the same frame. (default: false)
  55454. * @param textureType Type of textures used when performing the post process. (default: 0)
  55455. * @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)
  55456. */
  55457. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55458. /**
  55459. * Disposes the post process.
  55460. * @param camera The camera to dispose the post process on.
  55461. */
  55462. dispose(camera?: Camera): void;
  55463. }
  55464. }
  55465. declare module "babylonjs/Shaders/refraction.fragment" {
  55466. /** @hidden */
  55467. export var refractionPixelShader: {
  55468. name: string;
  55469. shader: string;
  55470. };
  55471. }
  55472. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55473. import { Color3 } from "babylonjs/Maths/math";
  55474. import { Camera } from "babylonjs/Cameras/camera";
  55475. import { Texture } from "babylonjs/Materials/Textures/texture";
  55476. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55477. import { Engine } from "babylonjs/Engines/engine";
  55478. import "babylonjs/Shaders/refraction.fragment";
  55479. /**
  55480. * Post process which applies a refractin texture
  55481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55482. */
  55483. export class RefractionPostProcess extends PostProcess {
  55484. /** the base color of the refraction (used to taint the rendering) */
  55485. color: Color3;
  55486. /** simulated refraction depth */
  55487. depth: number;
  55488. /** the coefficient of the base color (0 to remove base color tainting) */
  55489. colorLevel: number;
  55490. private _refTexture;
  55491. private _ownRefractionTexture;
  55492. /**
  55493. * Gets or sets the refraction texture
  55494. * Please note that you are responsible for disposing the texture if you set it manually
  55495. */
  55496. refractionTexture: Texture;
  55497. /**
  55498. * Initializes the RefractionPostProcess
  55499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55500. * @param name The name of the effect.
  55501. * @param refractionTextureUrl Url of the refraction texture to use
  55502. * @param color the base color of the refraction (used to taint the rendering)
  55503. * @param depth simulated refraction depth
  55504. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55505. * @param camera The camera to apply the render pass to.
  55506. * @param options The required width/height ratio to downsize to before computing the render pass.
  55507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55508. * @param engine The engine which the post process will be applied. (default: current engine)
  55509. * @param reusable If the post process can be reused on the same frame. (default: false)
  55510. */
  55511. constructor(name: string, refractionTextureUrl: string,
  55512. /** the base color of the refraction (used to taint the rendering) */
  55513. color: Color3,
  55514. /** simulated refraction depth */
  55515. depth: number,
  55516. /** the coefficient of the base color (0 to remove base color tainting) */
  55517. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55518. /**
  55519. * Disposes of the post process
  55520. * @param camera Camera to dispose post process on
  55521. */
  55522. dispose(camera: Camera): void;
  55523. }
  55524. }
  55525. declare module "babylonjs/Shaders/sharpen.fragment" {
  55526. /** @hidden */
  55527. export var sharpenPixelShader: {
  55528. name: string;
  55529. shader: string;
  55530. };
  55531. }
  55532. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55533. import { Nullable } from "babylonjs/types";
  55534. import { Camera } from "babylonjs/Cameras/camera";
  55535. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55536. import "babylonjs/Shaders/sharpen.fragment";
  55537. import { Engine } from "babylonjs/Engines/engine";
  55538. /**
  55539. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55540. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55541. */
  55542. export class SharpenPostProcess extends PostProcess {
  55543. /**
  55544. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55545. */
  55546. colorAmount: number;
  55547. /**
  55548. * How much sharpness should be applied (default: 0.3)
  55549. */
  55550. edgeAmount: number;
  55551. /**
  55552. * Creates a new instance ConvolutionPostProcess
  55553. * @param name The name of the effect.
  55554. * @param options The required width/height ratio to downsize to before computing the render pass.
  55555. * @param camera The camera to apply the render pass to.
  55556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55557. * @param engine The engine which the post process will be applied. (default: current engine)
  55558. * @param reusable If the post process can be reused on the same frame. (default: false)
  55559. * @param textureType Type of textures used when performing the post process. (default: 0)
  55560. * @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)
  55561. */
  55562. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55563. }
  55564. }
  55565. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55566. import { Nullable } from "babylonjs/types";
  55567. import { Camera } from "babylonjs/Cameras/camera";
  55568. import { Engine } from "babylonjs/Engines/engine";
  55569. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55570. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55571. /**
  55572. * PostProcessRenderPipeline
  55573. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55574. */
  55575. export class PostProcessRenderPipeline {
  55576. private engine;
  55577. private _renderEffects;
  55578. private _renderEffectsForIsolatedPass;
  55579. /**
  55580. * List of inspectable custom properties (used by the Inspector)
  55581. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55582. */
  55583. inspectableCustomProperties: IInspectable[];
  55584. /**
  55585. * @hidden
  55586. */
  55587. protected _cameras: Camera[];
  55588. /** @hidden */
  55589. _name: string;
  55590. /**
  55591. * Gets pipeline name
  55592. */
  55593. readonly name: string;
  55594. /**
  55595. * Initializes a PostProcessRenderPipeline
  55596. * @param engine engine to add the pipeline to
  55597. * @param name name of the pipeline
  55598. */
  55599. constructor(engine: Engine, name: string);
  55600. /**
  55601. * Gets the class name
  55602. * @returns "PostProcessRenderPipeline"
  55603. */
  55604. getClassName(): string;
  55605. /**
  55606. * If all the render effects in the pipeline are supported
  55607. */
  55608. readonly isSupported: boolean;
  55609. /**
  55610. * Adds an effect to the pipeline
  55611. * @param renderEffect the effect to add
  55612. */
  55613. addEffect(renderEffect: PostProcessRenderEffect): void;
  55614. /** @hidden */
  55615. _rebuild(): void;
  55616. /** @hidden */
  55617. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55618. /** @hidden */
  55619. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55620. /** @hidden */
  55621. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55622. /** @hidden */
  55623. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55624. /** @hidden */
  55625. _attachCameras(cameras: Camera, unique: boolean): void;
  55626. /** @hidden */
  55627. _attachCameras(cameras: Camera[], unique: boolean): void;
  55628. /** @hidden */
  55629. _detachCameras(cameras: Camera): void;
  55630. /** @hidden */
  55631. _detachCameras(cameras: Nullable<Camera[]>): void;
  55632. /** @hidden */
  55633. _update(): void;
  55634. /** @hidden */
  55635. _reset(): void;
  55636. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55637. /**
  55638. * Disposes of the pipeline
  55639. */
  55640. dispose(): void;
  55641. }
  55642. }
  55643. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55644. import { Camera } from "babylonjs/Cameras/camera";
  55645. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55646. /**
  55647. * PostProcessRenderPipelineManager class
  55648. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55649. */
  55650. export class PostProcessRenderPipelineManager {
  55651. private _renderPipelines;
  55652. /**
  55653. * Initializes a PostProcessRenderPipelineManager
  55654. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55655. */
  55656. constructor();
  55657. /**
  55658. * Gets the list of supported render pipelines
  55659. */
  55660. readonly supportedPipelines: PostProcessRenderPipeline[];
  55661. /**
  55662. * Adds a pipeline to the manager
  55663. * @param renderPipeline The pipeline to add
  55664. */
  55665. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55666. /**
  55667. * Attaches a camera to the pipeline
  55668. * @param renderPipelineName The name of the pipeline to attach to
  55669. * @param cameras the camera to attach
  55670. * @param unique if the camera can be attached multiple times to the pipeline
  55671. */
  55672. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55673. /**
  55674. * Detaches a camera from the pipeline
  55675. * @param renderPipelineName The name of the pipeline to detach from
  55676. * @param cameras the camera to detach
  55677. */
  55678. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55679. /**
  55680. * Enables an effect by name on a pipeline
  55681. * @param renderPipelineName the name of the pipeline to enable the effect in
  55682. * @param renderEffectName the name of the effect to enable
  55683. * @param cameras the cameras that the effect should be enabled on
  55684. */
  55685. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55686. /**
  55687. * Disables an effect by name on a pipeline
  55688. * @param renderPipelineName the name of the pipeline to disable the effect in
  55689. * @param renderEffectName the name of the effect to disable
  55690. * @param cameras the cameras that the effect should be disabled on
  55691. */
  55692. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55693. /**
  55694. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55695. */
  55696. update(): void;
  55697. /** @hidden */
  55698. _rebuild(): void;
  55699. /**
  55700. * Disposes of the manager and pipelines
  55701. */
  55702. dispose(): void;
  55703. }
  55704. }
  55705. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55706. import { ISceneComponent } from "babylonjs/sceneComponent";
  55707. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55708. import { Scene } from "babylonjs/scene";
  55709. module "babylonjs/scene" {
  55710. interface Scene {
  55711. /** @hidden (Backing field) */
  55712. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55713. /**
  55714. * Gets the postprocess render pipeline manager
  55715. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55716. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55717. */
  55718. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55719. }
  55720. }
  55721. /**
  55722. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55723. */
  55724. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55725. /**
  55726. * The component name helpfull to identify the component in the list of scene components.
  55727. */
  55728. readonly name: string;
  55729. /**
  55730. * The scene the component belongs to.
  55731. */
  55732. scene: Scene;
  55733. /**
  55734. * Creates a new instance of the component for the given scene
  55735. * @param scene Defines the scene to register the component in
  55736. */
  55737. constructor(scene: Scene);
  55738. /**
  55739. * Registers the component in a given scene
  55740. */
  55741. register(): void;
  55742. /**
  55743. * Rebuilds the elements related to this component in case of
  55744. * context lost for instance.
  55745. */
  55746. rebuild(): void;
  55747. /**
  55748. * Disposes the component and the associated ressources
  55749. */
  55750. dispose(): void;
  55751. private _gatherRenderTargets;
  55752. }
  55753. }
  55754. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55755. import { IAnimatable } from "babylonjs/Misc/tools";
  55756. import { Camera } from "babylonjs/Cameras/camera";
  55757. import { IDisposable } from "babylonjs/scene";
  55758. import { Scene } from "babylonjs/scene";
  55759. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55760. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55761. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55762. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55763. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55764. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55765. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55766. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55767. import { Animation } from "babylonjs/Animations/animation";
  55768. /**
  55769. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55770. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55771. */
  55772. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55773. private _scene;
  55774. private _camerasToBeAttached;
  55775. /**
  55776. * ID of the sharpen post process,
  55777. */
  55778. private readonly SharpenPostProcessId;
  55779. /**
  55780. * @ignore
  55781. * ID of the image processing post process;
  55782. */
  55783. readonly ImageProcessingPostProcessId: string;
  55784. /**
  55785. * @ignore
  55786. * ID of the Fast Approximate Anti-Aliasing post process;
  55787. */
  55788. readonly FxaaPostProcessId: string;
  55789. /**
  55790. * ID of the chromatic aberration post process,
  55791. */
  55792. private readonly ChromaticAberrationPostProcessId;
  55793. /**
  55794. * ID of the grain post process
  55795. */
  55796. private readonly GrainPostProcessId;
  55797. /**
  55798. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55799. */
  55800. sharpen: SharpenPostProcess;
  55801. private _sharpenEffect;
  55802. private bloom;
  55803. /**
  55804. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55805. */
  55806. depthOfField: DepthOfFieldEffect;
  55807. /**
  55808. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55809. */
  55810. fxaa: FxaaPostProcess;
  55811. /**
  55812. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55813. */
  55814. imageProcessing: ImageProcessingPostProcess;
  55815. /**
  55816. * Chromatic aberration post process which will shift rgb colors in the image
  55817. */
  55818. chromaticAberration: ChromaticAberrationPostProcess;
  55819. private _chromaticAberrationEffect;
  55820. /**
  55821. * Grain post process which add noise to the image
  55822. */
  55823. grain: GrainPostProcess;
  55824. private _grainEffect;
  55825. /**
  55826. * Glow post process which adds a glow to emissive areas of the image
  55827. */
  55828. private _glowLayer;
  55829. /**
  55830. * Animations which can be used to tweak settings over a period of time
  55831. */
  55832. animations: Animation[];
  55833. private _imageProcessingConfigurationObserver;
  55834. private _sharpenEnabled;
  55835. private _bloomEnabled;
  55836. private _depthOfFieldEnabled;
  55837. private _depthOfFieldBlurLevel;
  55838. private _fxaaEnabled;
  55839. private _imageProcessingEnabled;
  55840. private _defaultPipelineTextureType;
  55841. private _bloomScale;
  55842. private _chromaticAberrationEnabled;
  55843. private _grainEnabled;
  55844. private _buildAllowed;
  55845. /**
  55846. * Gets active scene
  55847. */
  55848. readonly scene: Scene;
  55849. /**
  55850. * Enable or disable the sharpen process from the pipeline
  55851. */
  55852. sharpenEnabled: boolean;
  55853. private _resizeObserver;
  55854. private _hardwareScaleLevel;
  55855. private _bloomKernel;
  55856. /**
  55857. * Specifies the size of the bloom blur kernel, relative to the final output size
  55858. */
  55859. bloomKernel: number;
  55860. /**
  55861. * Specifies the weight of the bloom in the final rendering
  55862. */
  55863. private _bloomWeight;
  55864. /**
  55865. * Specifies the luma threshold for the area that will be blurred by the bloom
  55866. */
  55867. private _bloomThreshold;
  55868. private _hdr;
  55869. /**
  55870. * The strength of the bloom.
  55871. */
  55872. bloomWeight: number;
  55873. /**
  55874. * The strength of the bloom.
  55875. */
  55876. bloomThreshold: number;
  55877. /**
  55878. * The scale of the bloom, lower value will provide better performance.
  55879. */
  55880. bloomScale: number;
  55881. /**
  55882. * Enable or disable the bloom from the pipeline
  55883. */
  55884. bloomEnabled: boolean;
  55885. private _rebuildBloom;
  55886. /**
  55887. * If the depth of field is enabled.
  55888. */
  55889. depthOfFieldEnabled: boolean;
  55890. /**
  55891. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55892. */
  55893. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55894. /**
  55895. * If the anti aliasing is enabled.
  55896. */
  55897. fxaaEnabled: boolean;
  55898. private _samples;
  55899. /**
  55900. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55901. */
  55902. samples: number;
  55903. /**
  55904. * If image processing is enabled.
  55905. */
  55906. imageProcessingEnabled: boolean;
  55907. /**
  55908. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55909. */
  55910. glowLayerEnabled: boolean;
  55911. /**
  55912. * Enable or disable the chromaticAberration process from the pipeline
  55913. */
  55914. chromaticAberrationEnabled: boolean;
  55915. /**
  55916. * Enable or disable the grain process from the pipeline
  55917. */
  55918. grainEnabled: boolean;
  55919. /**
  55920. * @constructor
  55921. * @param name - The rendering pipeline name (default: "")
  55922. * @param hdr - If high dynamic range textures should be used (default: true)
  55923. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55924. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55925. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55926. */
  55927. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55928. /**
  55929. * Get the class name
  55930. * @returns "DefaultRenderingPipeline"
  55931. */
  55932. getClassName(): string;
  55933. /**
  55934. * Force the compilation of the entire pipeline.
  55935. */
  55936. prepare(): void;
  55937. private _hasCleared;
  55938. private _prevPostProcess;
  55939. private _prevPrevPostProcess;
  55940. private _setAutoClearAndTextureSharing;
  55941. private _depthOfFieldSceneObserver;
  55942. private _buildPipeline;
  55943. private _disposePostProcesses;
  55944. /**
  55945. * Adds a camera to the pipeline
  55946. * @param camera the camera to be added
  55947. */
  55948. addCamera(camera: Camera): void;
  55949. /**
  55950. * Removes a camera from the pipeline
  55951. * @param camera the camera to remove
  55952. */
  55953. removeCamera(camera: Camera): void;
  55954. /**
  55955. * Dispose of the pipeline and stop all post processes
  55956. */
  55957. dispose(): void;
  55958. /**
  55959. * Serialize the rendering pipeline (Used when exporting)
  55960. * @returns the serialized object
  55961. */
  55962. serialize(): any;
  55963. /**
  55964. * Parse the serialized pipeline
  55965. * @param source Source pipeline.
  55966. * @param scene The scene to load the pipeline to.
  55967. * @param rootUrl The URL of the serialized pipeline.
  55968. * @returns An instantiated pipeline from the serialized object.
  55969. */
  55970. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55971. }
  55972. }
  55973. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55974. /** @hidden */
  55975. export var lensHighlightsPixelShader: {
  55976. name: string;
  55977. shader: string;
  55978. };
  55979. }
  55980. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55981. /** @hidden */
  55982. export var depthOfFieldPixelShader: {
  55983. name: string;
  55984. shader: string;
  55985. };
  55986. }
  55987. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55988. import { Camera } from "babylonjs/Cameras/camera";
  55989. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55990. import { Scene } from "babylonjs/scene";
  55991. import "babylonjs/Shaders/chromaticAberration.fragment";
  55992. import "babylonjs/Shaders/lensHighlights.fragment";
  55993. import "babylonjs/Shaders/depthOfField.fragment";
  55994. /**
  55995. * BABYLON.JS Chromatic Aberration GLSL Shader
  55996. * Author: Olivier Guyot
  55997. * Separates very slightly R, G and B colors on the edges of the screen
  55998. * Inspired by Francois Tarlier & Martins Upitis
  55999. */
  56000. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56001. /**
  56002. * @ignore
  56003. * The chromatic aberration PostProcess id in the pipeline
  56004. */
  56005. LensChromaticAberrationEffect: string;
  56006. /**
  56007. * @ignore
  56008. * The highlights enhancing PostProcess id in the pipeline
  56009. */
  56010. HighlightsEnhancingEffect: string;
  56011. /**
  56012. * @ignore
  56013. * The depth-of-field PostProcess id in the pipeline
  56014. */
  56015. LensDepthOfFieldEffect: string;
  56016. private _scene;
  56017. private _depthTexture;
  56018. private _grainTexture;
  56019. private _chromaticAberrationPostProcess;
  56020. private _highlightsPostProcess;
  56021. private _depthOfFieldPostProcess;
  56022. private _edgeBlur;
  56023. private _grainAmount;
  56024. private _chromaticAberration;
  56025. private _distortion;
  56026. private _highlightsGain;
  56027. private _highlightsThreshold;
  56028. private _dofDistance;
  56029. private _dofAperture;
  56030. private _dofDarken;
  56031. private _dofPentagon;
  56032. private _blurNoise;
  56033. /**
  56034. * @constructor
  56035. *
  56036. * Effect parameters are as follow:
  56037. * {
  56038. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56039. * edge_blur: number; // from 0 to x (1 for realism)
  56040. * distortion: number; // from 0 to x (1 for realism)
  56041. * grain_amount: number; // from 0 to 1
  56042. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56043. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56044. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56045. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56046. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56047. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56048. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56049. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56050. * }
  56051. * Note: if an effect parameter is unset, effect is disabled
  56052. *
  56053. * @param name The rendering pipeline name
  56054. * @param parameters - An object containing all parameters (see above)
  56055. * @param scene The scene linked to this pipeline
  56056. * @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)
  56057. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56058. */
  56059. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56060. /**
  56061. * Get the class name
  56062. * @returns "LensRenderingPipeline"
  56063. */
  56064. getClassName(): string;
  56065. /**
  56066. * Gets associated scene
  56067. */
  56068. readonly scene: Scene;
  56069. /**
  56070. * Gets or sets the edge blur
  56071. */
  56072. edgeBlur: number;
  56073. /**
  56074. * Gets or sets the grain amount
  56075. */
  56076. grainAmount: number;
  56077. /**
  56078. * Gets or sets the chromatic aberration amount
  56079. */
  56080. chromaticAberration: number;
  56081. /**
  56082. * Gets or sets the depth of field aperture
  56083. */
  56084. dofAperture: number;
  56085. /**
  56086. * Gets or sets the edge distortion
  56087. */
  56088. edgeDistortion: number;
  56089. /**
  56090. * Gets or sets the depth of field distortion
  56091. */
  56092. dofDistortion: number;
  56093. /**
  56094. * Gets or sets the darken out of focus amount
  56095. */
  56096. darkenOutOfFocus: number;
  56097. /**
  56098. * Gets or sets a boolean indicating if blur noise is enabled
  56099. */
  56100. blurNoise: boolean;
  56101. /**
  56102. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56103. */
  56104. pentagonBokeh: boolean;
  56105. /**
  56106. * Gets or sets the highlight grain amount
  56107. */
  56108. highlightsGain: number;
  56109. /**
  56110. * Gets or sets the highlight threshold
  56111. */
  56112. highlightsThreshold: number;
  56113. /**
  56114. * Sets the amount of blur at the edges
  56115. * @param amount blur amount
  56116. */
  56117. setEdgeBlur(amount: number): void;
  56118. /**
  56119. * Sets edge blur to 0
  56120. */
  56121. disableEdgeBlur(): void;
  56122. /**
  56123. * Sets the amout of grain
  56124. * @param amount Amount of grain
  56125. */
  56126. setGrainAmount(amount: number): void;
  56127. /**
  56128. * Set grain amount to 0
  56129. */
  56130. disableGrain(): void;
  56131. /**
  56132. * Sets the chromatic aberration amount
  56133. * @param amount amount of chromatic aberration
  56134. */
  56135. setChromaticAberration(amount: number): void;
  56136. /**
  56137. * Sets chromatic aberration amount to 0
  56138. */
  56139. disableChromaticAberration(): void;
  56140. /**
  56141. * Sets the EdgeDistortion amount
  56142. * @param amount amount of EdgeDistortion
  56143. */
  56144. setEdgeDistortion(amount: number): void;
  56145. /**
  56146. * Sets edge distortion to 0
  56147. */
  56148. disableEdgeDistortion(): void;
  56149. /**
  56150. * Sets the FocusDistance amount
  56151. * @param amount amount of FocusDistance
  56152. */
  56153. setFocusDistance(amount: number): void;
  56154. /**
  56155. * Disables depth of field
  56156. */
  56157. disableDepthOfField(): void;
  56158. /**
  56159. * Sets the Aperture amount
  56160. * @param amount amount of Aperture
  56161. */
  56162. setAperture(amount: number): void;
  56163. /**
  56164. * Sets the DarkenOutOfFocus amount
  56165. * @param amount amount of DarkenOutOfFocus
  56166. */
  56167. setDarkenOutOfFocus(amount: number): void;
  56168. private _pentagonBokehIsEnabled;
  56169. /**
  56170. * Creates a pentagon bokeh effect
  56171. */
  56172. enablePentagonBokeh(): void;
  56173. /**
  56174. * Disables the pentagon bokeh effect
  56175. */
  56176. disablePentagonBokeh(): void;
  56177. /**
  56178. * Enables noise blur
  56179. */
  56180. enableNoiseBlur(): void;
  56181. /**
  56182. * Disables noise blur
  56183. */
  56184. disableNoiseBlur(): void;
  56185. /**
  56186. * Sets the HighlightsGain amount
  56187. * @param amount amount of HighlightsGain
  56188. */
  56189. setHighlightsGain(amount: number): void;
  56190. /**
  56191. * Sets the HighlightsThreshold amount
  56192. * @param amount amount of HighlightsThreshold
  56193. */
  56194. setHighlightsThreshold(amount: number): void;
  56195. /**
  56196. * Disables highlights
  56197. */
  56198. disableHighlights(): void;
  56199. /**
  56200. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56201. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56202. */
  56203. dispose(disableDepthRender?: boolean): void;
  56204. private _createChromaticAberrationPostProcess;
  56205. private _createHighlightsPostProcess;
  56206. private _createDepthOfFieldPostProcess;
  56207. private _createGrainTexture;
  56208. }
  56209. }
  56210. declare module "babylonjs/Shaders/ssao2.fragment" {
  56211. /** @hidden */
  56212. export var ssao2PixelShader: {
  56213. name: string;
  56214. shader: string;
  56215. };
  56216. }
  56217. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56218. /** @hidden */
  56219. export var ssaoCombinePixelShader: {
  56220. name: string;
  56221. shader: string;
  56222. };
  56223. }
  56224. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56225. import { Camera } from "babylonjs/Cameras/camera";
  56226. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56227. import { Scene } from "babylonjs/scene";
  56228. import "babylonjs/Shaders/ssao2.fragment";
  56229. import "babylonjs/Shaders/ssaoCombine.fragment";
  56230. /**
  56231. * Render pipeline to produce ssao effect
  56232. */
  56233. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56234. /**
  56235. * @ignore
  56236. * The PassPostProcess id in the pipeline that contains the original scene color
  56237. */
  56238. SSAOOriginalSceneColorEffect: string;
  56239. /**
  56240. * @ignore
  56241. * The SSAO PostProcess id in the pipeline
  56242. */
  56243. SSAORenderEffect: string;
  56244. /**
  56245. * @ignore
  56246. * The horizontal blur PostProcess id in the pipeline
  56247. */
  56248. SSAOBlurHRenderEffect: string;
  56249. /**
  56250. * @ignore
  56251. * The vertical blur PostProcess id in the pipeline
  56252. */
  56253. SSAOBlurVRenderEffect: string;
  56254. /**
  56255. * @ignore
  56256. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56257. */
  56258. SSAOCombineRenderEffect: string;
  56259. /**
  56260. * The output strength of the SSAO post-process. Default value is 1.0.
  56261. */
  56262. totalStrength: number;
  56263. /**
  56264. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56265. */
  56266. maxZ: number;
  56267. /**
  56268. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56269. */
  56270. minZAspect: number;
  56271. private _samples;
  56272. /**
  56273. * Number of samples used for the SSAO calculations. Default value is 8
  56274. */
  56275. samples: number;
  56276. private _textureSamples;
  56277. /**
  56278. * Number of samples to use for antialiasing
  56279. */
  56280. textureSamples: number;
  56281. /**
  56282. * Ratio object used for SSAO ratio and blur ratio
  56283. */
  56284. private _ratio;
  56285. /**
  56286. * Dynamically generated sphere sampler.
  56287. */
  56288. private _sampleSphere;
  56289. /**
  56290. * Blur filter offsets
  56291. */
  56292. private _samplerOffsets;
  56293. private _expensiveBlur;
  56294. /**
  56295. * If bilateral blur should be used
  56296. */
  56297. expensiveBlur: boolean;
  56298. /**
  56299. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56300. */
  56301. radius: number;
  56302. /**
  56303. * The base color of the SSAO post-process
  56304. * The final result is "base + ssao" between [0, 1]
  56305. */
  56306. base: number;
  56307. /**
  56308. * Support test.
  56309. */
  56310. static readonly IsSupported: boolean;
  56311. private _scene;
  56312. private _depthTexture;
  56313. private _normalTexture;
  56314. private _randomTexture;
  56315. private _originalColorPostProcess;
  56316. private _ssaoPostProcess;
  56317. private _blurHPostProcess;
  56318. private _blurVPostProcess;
  56319. private _ssaoCombinePostProcess;
  56320. private _firstUpdate;
  56321. /**
  56322. * Gets active scene
  56323. */
  56324. readonly scene: Scene;
  56325. /**
  56326. * @constructor
  56327. * @param name The rendering pipeline name
  56328. * @param scene The scene linked to this pipeline
  56329. * @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 }
  56330. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56331. */
  56332. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56333. /**
  56334. * Get the class name
  56335. * @returns "SSAO2RenderingPipeline"
  56336. */
  56337. getClassName(): string;
  56338. /**
  56339. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56340. */
  56341. dispose(disableGeometryBufferRenderer?: boolean): void;
  56342. private _createBlurPostProcess;
  56343. /** @hidden */
  56344. _rebuild(): void;
  56345. private _bits;
  56346. private _radicalInverse_VdC;
  56347. private _hammersley;
  56348. private _hemisphereSample_uniform;
  56349. private _generateHemisphere;
  56350. private _createSSAOPostProcess;
  56351. private _createSSAOCombinePostProcess;
  56352. private _createRandomTexture;
  56353. /**
  56354. * Serialize the rendering pipeline (Used when exporting)
  56355. * @returns the serialized object
  56356. */
  56357. serialize(): any;
  56358. /**
  56359. * Parse the serialized pipeline
  56360. * @param source Source pipeline.
  56361. * @param scene The scene to load the pipeline to.
  56362. * @param rootUrl The URL of the serialized pipeline.
  56363. * @returns An instantiated pipeline from the serialized object.
  56364. */
  56365. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56366. }
  56367. }
  56368. declare module "babylonjs/Shaders/ssao.fragment" {
  56369. /** @hidden */
  56370. export var ssaoPixelShader: {
  56371. name: string;
  56372. shader: string;
  56373. };
  56374. }
  56375. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56376. import { Camera } from "babylonjs/Cameras/camera";
  56377. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56378. import { Scene } from "babylonjs/scene";
  56379. import "babylonjs/Shaders/ssao.fragment";
  56380. import "babylonjs/Shaders/ssaoCombine.fragment";
  56381. /**
  56382. * Render pipeline to produce ssao effect
  56383. */
  56384. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56385. /**
  56386. * @ignore
  56387. * The PassPostProcess id in the pipeline that contains the original scene color
  56388. */
  56389. SSAOOriginalSceneColorEffect: string;
  56390. /**
  56391. * @ignore
  56392. * The SSAO PostProcess id in the pipeline
  56393. */
  56394. SSAORenderEffect: string;
  56395. /**
  56396. * @ignore
  56397. * The horizontal blur PostProcess id in the pipeline
  56398. */
  56399. SSAOBlurHRenderEffect: string;
  56400. /**
  56401. * @ignore
  56402. * The vertical blur PostProcess id in the pipeline
  56403. */
  56404. SSAOBlurVRenderEffect: string;
  56405. /**
  56406. * @ignore
  56407. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56408. */
  56409. SSAOCombineRenderEffect: string;
  56410. /**
  56411. * The output strength of the SSAO post-process. Default value is 1.0.
  56412. */
  56413. totalStrength: number;
  56414. /**
  56415. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56416. */
  56417. radius: number;
  56418. /**
  56419. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56420. * Must not be equal to fallOff and superior to fallOff.
  56421. * Default value is 0.0075
  56422. */
  56423. area: number;
  56424. /**
  56425. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56426. * Must not be equal to area and inferior to area.
  56427. * Default value is 0.000001
  56428. */
  56429. fallOff: number;
  56430. /**
  56431. * The base color of the SSAO post-process
  56432. * The final result is "base + ssao" between [0, 1]
  56433. */
  56434. base: number;
  56435. private _scene;
  56436. private _depthTexture;
  56437. private _randomTexture;
  56438. private _originalColorPostProcess;
  56439. private _ssaoPostProcess;
  56440. private _blurHPostProcess;
  56441. private _blurVPostProcess;
  56442. private _ssaoCombinePostProcess;
  56443. private _firstUpdate;
  56444. /**
  56445. * Gets active scene
  56446. */
  56447. readonly scene: Scene;
  56448. /**
  56449. * @constructor
  56450. * @param name - The rendering pipeline name
  56451. * @param scene - The scene linked to this pipeline
  56452. * @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 }
  56453. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56454. */
  56455. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56456. /**
  56457. * Get the class name
  56458. * @returns "SSAORenderingPipeline"
  56459. */
  56460. getClassName(): string;
  56461. /**
  56462. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56463. */
  56464. dispose(disableDepthRender?: boolean): void;
  56465. private _createBlurPostProcess;
  56466. /** @hidden */
  56467. _rebuild(): void;
  56468. private _createSSAOPostProcess;
  56469. private _createSSAOCombinePostProcess;
  56470. private _createRandomTexture;
  56471. }
  56472. }
  56473. declare module "babylonjs/Shaders/standard.fragment" {
  56474. /** @hidden */
  56475. export var standardPixelShader: {
  56476. name: string;
  56477. shader: string;
  56478. };
  56479. }
  56480. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56481. import { Nullable } from "babylonjs/types";
  56482. import { IAnimatable } from "babylonjs/Misc/tools";
  56483. import { Camera } from "babylonjs/Cameras/camera";
  56484. import { Texture } from "babylonjs/Materials/Textures/texture";
  56485. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56486. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56487. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56488. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56489. import { IDisposable } from "babylonjs/scene";
  56490. import { SpotLight } from "babylonjs/Lights/spotLight";
  56491. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56492. import { Scene } from "babylonjs/scene";
  56493. import { Animation } from "babylonjs/Animations/animation";
  56494. import "babylonjs/Shaders/standard.fragment";
  56495. /**
  56496. * Standard rendering pipeline
  56497. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56498. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56499. */
  56500. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56501. /**
  56502. * Public members
  56503. */
  56504. /**
  56505. * Post-process which contains the original scene color before the pipeline applies all the effects
  56506. */
  56507. originalPostProcess: Nullable<PostProcess>;
  56508. /**
  56509. * Post-process used to down scale an image x4
  56510. */
  56511. downSampleX4PostProcess: Nullable<PostProcess>;
  56512. /**
  56513. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56514. */
  56515. brightPassPostProcess: Nullable<PostProcess>;
  56516. /**
  56517. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56518. */
  56519. blurHPostProcesses: PostProcess[];
  56520. /**
  56521. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56522. */
  56523. blurVPostProcesses: PostProcess[];
  56524. /**
  56525. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56526. */
  56527. textureAdderPostProcess: Nullable<PostProcess>;
  56528. /**
  56529. * Post-process used to create volumetric lighting effect
  56530. */
  56531. volumetricLightPostProcess: Nullable<PostProcess>;
  56532. /**
  56533. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56534. */
  56535. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56536. /**
  56537. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56538. */
  56539. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56540. /**
  56541. * Post-process used to merge the volumetric light effect and the real scene color
  56542. */
  56543. volumetricLightMergePostProces: Nullable<PostProcess>;
  56544. /**
  56545. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56546. */
  56547. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56548. /**
  56549. * Base post-process used to calculate the average luminance of the final image for HDR
  56550. */
  56551. luminancePostProcess: Nullable<PostProcess>;
  56552. /**
  56553. * Post-processes used to create down sample post-processes in order to get
  56554. * the average luminance of the final image for HDR
  56555. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56556. */
  56557. luminanceDownSamplePostProcesses: PostProcess[];
  56558. /**
  56559. * Post-process used to create a HDR effect (light adaptation)
  56560. */
  56561. hdrPostProcess: Nullable<PostProcess>;
  56562. /**
  56563. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56564. */
  56565. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56566. /**
  56567. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56568. */
  56569. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56570. /**
  56571. * Post-process used to merge the final HDR post-process and the real scene color
  56572. */
  56573. hdrFinalPostProcess: Nullable<PostProcess>;
  56574. /**
  56575. * Post-process used to create a lens flare effect
  56576. */
  56577. lensFlarePostProcess: Nullable<PostProcess>;
  56578. /**
  56579. * Post-process that merges the result of the lens flare post-process and the real scene color
  56580. */
  56581. lensFlareComposePostProcess: Nullable<PostProcess>;
  56582. /**
  56583. * Post-process used to create a motion blur effect
  56584. */
  56585. motionBlurPostProcess: Nullable<PostProcess>;
  56586. /**
  56587. * Post-process used to create a depth of field effect
  56588. */
  56589. depthOfFieldPostProcess: Nullable<PostProcess>;
  56590. /**
  56591. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56592. */
  56593. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56594. /**
  56595. * Represents the brightness threshold in order to configure the illuminated surfaces
  56596. */
  56597. brightThreshold: number;
  56598. /**
  56599. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56600. */
  56601. blurWidth: number;
  56602. /**
  56603. * Sets if the blur for highlighted surfaces must be only horizontal
  56604. */
  56605. horizontalBlur: boolean;
  56606. /**
  56607. * Gets the overall exposure used by the pipeline
  56608. */
  56609. /**
  56610. * Sets the overall exposure used by the pipeline
  56611. */
  56612. exposure: number;
  56613. /**
  56614. * Texture used typically to simulate "dirty" on camera lens
  56615. */
  56616. lensTexture: Nullable<Texture>;
  56617. /**
  56618. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56619. */
  56620. volumetricLightCoefficient: number;
  56621. /**
  56622. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56623. */
  56624. volumetricLightPower: number;
  56625. /**
  56626. * Used the set the blur intensity to smooth the volumetric lights
  56627. */
  56628. volumetricLightBlurScale: number;
  56629. /**
  56630. * Light (spot or directional) used to generate the volumetric lights rays
  56631. * The source light must have a shadow generate so the pipeline can get its
  56632. * depth map
  56633. */
  56634. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56635. /**
  56636. * For eye adaptation, represents the minimum luminance the eye can see
  56637. */
  56638. hdrMinimumLuminance: number;
  56639. /**
  56640. * For eye adaptation, represents the decrease luminance speed
  56641. */
  56642. hdrDecreaseRate: number;
  56643. /**
  56644. * For eye adaptation, represents the increase luminance speed
  56645. */
  56646. hdrIncreaseRate: number;
  56647. /**
  56648. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56649. */
  56650. /**
  56651. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56652. */
  56653. hdrAutoExposure: boolean;
  56654. /**
  56655. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56656. */
  56657. lensColorTexture: Nullable<Texture>;
  56658. /**
  56659. * The overall strengh for the lens flare effect
  56660. */
  56661. lensFlareStrength: number;
  56662. /**
  56663. * Dispersion coefficient for lens flare ghosts
  56664. */
  56665. lensFlareGhostDispersal: number;
  56666. /**
  56667. * Main lens flare halo width
  56668. */
  56669. lensFlareHaloWidth: number;
  56670. /**
  56671. * Based on the lens distortion effect, defines how much the lens flare result
  56672. * is distorted
  56673. */
  56674. lensFlareDistortionStrength: number;
  56675. /**
  56676. * Lens star texture must be used to simulate rays on the flares and is available
  56677. * in the documentation
  56678. */
  56679. lensStarTexture: Nullable<Texture>;
  56680. /**
  56681. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56682. * flare effect by taking account of the dirt texture
  56683. */
  56684. lensFlareDirtTexture: Nullable<Texture>;
  56685. /**
  56686. * Represents the focal length for the depth of field effect
  56687. */
  56688. depthOfFieldDistance: number;
  56689. /**
  56690. * Represents the blur intensity for the blurred part of the depth of field effect
  56691. */
  56692. depthOfFieldBlurWidth: number;
  56693. /**
  56694. * For motion blur, defines how much the image is blurred by the movement
  56695. */
  56696. motionStrength: number;
  56697. /**
  56698. * List of animations for the pipeline (IAnimatable implementation)
  56699. */
  56700. animations: Animation[];
  56701. /**
  56702. * Private members
  56703. */
  56704. private _scene;
  56705. private _currentDepthOfFieldSource;
  56706. private _basePostProcess;
  56707. private _fixedExposure;
  56708. private _currentExposure;
  56709. private _hdrAutoExposure;
  56710. private _hdrCurrentLuminance;
  56711. private _floatTextureType;
  56712. private _ratio;
  56713. private _bloomEnabled;
  56714. private _depthOfFieldEnabled;
  56715. private _vlsEnabled;
  56716. private _lensFlareEnabled;
  56717. private _hdrEnabled;
  56718. private _motionBlurEnabled;
  56719. private _fxaaEnabled;
  56720. private _motionBlurSamples;
  56721. private _volumetricLightStepsCount;
  56722. private _samples;
  56723. /**
  56724. * @ignore
  56725. * Specifies if the bloom pipeline is enabled
  56726. */
  56727. BloomEnabled: boolean;
  56728. /**
  56729. * @ignore
  56730. * Specifies if the depth of field pipeline is enabed
  56731. */
  56732. DepthOfFieldEnabled: boolean;
  56733. /**
  56734. * @ignore
  56735. * Specifies if the lens flare pipeline is enabed
  56736. */
  56737. LensFlareEnabled: boolean;
  56738. /**
  56739. * @ignore
  56740. * Specifies if the HDR pipeline is enabled
  56741. */
  56742. HDREnabled: boolean;
  56743. /**
  56744. * @ignore
  56745. * Specifies if the volumetric lights scattering effect is enabled
  56746. */
  56747. VLSEnabled: boolean;
  56748. /**
  56749. * @ignore
  56750. * Specifies if the motion blur effect is enabled
  56751. */
  56752. MotionBlurEnabled: boolean;
  56753. /**
  56754. * Specifies if anti-aliasing is enabled
  56755. */
  56756. fxaaEnabled: boolean;
  56757. /**
  56758. * Specifies the number of steps used to calculate the volumetric lights
  56759. * Typically in interval [50, 200]
  56760. */
  56761. volumetricLightStepsCount: number;
  56762. /**
  56763. * Specifies the number of samples used for the motion blur effect
  56764. * Typically in interval [16, 64]
  56765. */
  56766. motionBlurSamples: number;
  56767. /**
  56768. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56769. */
  56770. samples: number;
  56771. /**
  56772. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56773. * @constructor
  56774. * @param name The rendering pipeline name
  56775. * @param scene The scene linked to this pipeline
  56776. * @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)
  56777. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56778. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56779. */
  56780. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56781. private _buildPipeline;
  56782. private _createDownSampleX4PostProcess;
  56783. private _createBrightPassPostProcess;
  56784. private _createBlurPostProcesses;
  56785. private _createTextureAdderPostProcess;
  56786. private _createVolumetricLightPostProcess;
  56787. private _createLuminancePostProcesses;
  56788. private _createHdrPostProcess;
  56789. private _createLensFlarePostProcess;
  56790. private _createDepthOfFieldPostProcess;
  56791. private _createMotionBlurPostProcess;
  56792. private _getDepthTexture;
  56793. private _disposePostProcesses;
  56794. /**
  56795. * Dispose of the pipeline and stop all post processes
  56796. */
  56797. dispose(): void;
  56798. /**
  56799. * Serialize the rendering pipeline (Used when exporting)
  56800. * @returns the serialized object
  56801. */
  56802. serialize(): any;
  56803. /**
  56804. * Parse the serialized pipeline
  56805. * @param source Source pipeline.
  56806. * @param scene The scene to load the pipeline to.
  56807. * @param rootUrl The URL of the serialized pipeline.
  56808. * @returns An instantiated pipeline from the serialized object.
  56809. */
  56810. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56811. /**
  56812. * Luminance steps
  56813. */
  56814. static LuminanceSteps: number;
  56815. }
  56816. }
  56817. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56818. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56819. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56820. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56821. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56822. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56823. }
  56824. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56825. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56826. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56827. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56828. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56829. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56830. }
  56831. declare module "babylonjs/Shaders/tonemap.fragment" {
  56832. /** @hidden */
  56833. export var tonemapPixelShader: {
  56834. name: string;
  56835. shader: string;
  56836. };
  56837. }
  56838. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56839. import { Camera } from "babylonjs/Cameras/camera";
  56840. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56841. import "babylonjs/Shaders/tonemap.fragment";
  56842. import { Engine } from "babylonjs/Engines/engine";
  56843. /** Defines operator used for tonemapping */
  56844. export enum TonemappingOperator {
  56845. /** Hable */
  56846. Hable = 0,
  56847. /** Reinhard */
  56848. Reinhard = 1,
  56849. /** HejiDawson */
  56850. HejiDawson = 2,
  56851. /** Photographic */
  56852. Photographic = 3
  56853. }
  56854. /**
  56855. * Defines a post process to apply tone mapping
  56856. */
  56857. export class TonemapPostProcess extends PostProcess {
  56858. private _operator;
  56859. /** Defines the required exposure adjustement */
  56860. exposureAdjustment: number;
  56861. /**
  56862. * Creates a new TonemapPostProcess
  56863. * @param name defines the name of the postprocess
  56864. * @param _operator defines the operator to use
  56865. * @param exposureAdjustment defines the required exposure adjustement
  56866. * @param camera defines the camera to use (can be null)
  56867. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56868. * @param engine defines the hosting engine (can be ignore if camera is set)
  56869. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56870. */
  56871. constructor(name: string, _operator: TonemappingOperator,
  56872. /** Defines the required exposure adjustement */
  56873. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56874. }
  56875. }
  56876. declare module "babylonjs/Shaders/depth.vertex" {
  56877. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56878. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56879. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56880. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56881. /** @hidden */
  56882. export var depthVertexShader: {
  56883. name: string;
  56884. shader: string;
  56885. };
  56886. }
  56887. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56888. /** @hidden */
  56889. export var volumetricLightScatteringPixelShader: {
  56890. name: string;
  56891. shader: string;
  56892. };
  56893. }
  56894. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56895. /** @hidden */
  56896. export var volumetricLightScatteringPassPixelShader: {
  56897. name: string;
  56898. shader: string;
  56899. };
  56900. }
  56901. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56902. import { Vector3 } from "babylonjs/Maths/math";
  56903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56904. import { Mesh } from "babylonjs/Meshes/mesh";
  56905. import { Camera } from "babylonjs/Cameras/camera";
  56906. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56907. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56908. import { Scene } from "babylonjs/scene";
  56909. import "babylonjs/Meshes/Builders/planeBuilder";
  56910. import "babylonjs/Shaders/depth.vertex";
  56911. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  56912. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  56913. import { Engine } from "babylonjs/Engines/engine";
  56914. /**
  56915. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56916. */
  56917. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56918. private _volumetricLightScatteringPass;
  56919. private _volumetricLightScatteringRTT;
  56920. private _viewPort;
  56921. private _screenCoordinates;
  56922. private _cachedDefines;
  56923. /**
  56924. * If not undefined, the mesh position is computed from the attached node position
  56925. */
  56926. attachedNode: {
  56927. position: Vector3;
  56928. };
  56929. /**
  56930. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56931. */
  56932. customMeshPosition: Vector3;
  56933. /**
  56934. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56935. */
  56936. useCustomMeshPosition: boolean;
  56937. /**
  56938. * If the post-process should inverse the light scattering direction
  56939. */
  56940. invert: boolean;
  56941. /**
  56942. * The internal mesh used by the post-process
  56943. */
  56944. mesh: Mesh;
  56945. /**
  56946. * @hidden
  56947. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56948. */
  56949. useDiffuseColor: boolean;
  56950. /**
  56951. * Array containing the excluded meshes not rendered in the internal pass
  56952. */
  56953. excludedMeshes: AbstractMesh[];
  56954. /**
  56955. * Controls the overall intensity of the post-process
  56956. */
  56957. exposure: number;
  56958. /**
  56959. * Dissipates each sample's contribution in range [0, 1]
  56960. */
  56961. decay: number;
  56962. /**
  56963. * Controls the overall intensity of each sample
  56964. */
  56965. weight: number;
  56966. /**
  56967. * Controls the density of each sample
  56968. */
  56969. density: number;
  56970. /**
  56971. * @constructor
  56972. * @param name The post-process name
  56973. * @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)
  56974. * @param camera The camera that the post-process will be attached to
  56975. * @param mesh The mesh used to create the light scattering
  56976. * @param samples The post-process quality, default 100
  56977. * @param samplingModeThe post-process filtering mode
  56978. * @param engine The babylon engine
  56979. * @param reusable If the post-process is reusable
  56980. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56981. */
  56982. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56983. /**
  56984. * Returns the string "VolumetricLightScatteringPostProcess"
  56985. * @returns "VolumetricLightScatteringPostProcess"
  56986. */
  56987. getClassName(): string;
  56988. private _isReady;
  56989. /**
  56990. * Sets the new light position for light scattering effect
  56991. * @param position The new custom light position
  56992. */
  56993. setCustomMeshPosition(position: Vector3): void;
  56994. /**
  56995. * Returns the light position for light scattering effect
  56996. * @return Vector3 The custom light position
  56997. */
  56998. getCustomMeshPosition(): Vector3;
  56999. /**
  57000. * Disposes the internal assets and detaches the post-process from the camera
  57001. */
  57002. dispose(camera: Camera): void;
  57003. /**
  57004. * Returns the render target texture used by the post-process
  57005. * @return the render target texture used by the post-process
  57006. */
  57007. getPass(): RenderTargetTexture;
  57008. private _meshExcluded;
  57009. private _createPass;
  57010. private _updateMeshScreenCoordinates;
  57011. /**
  57012. * Creates a default mesh for the Volumeric Light Scattering post-process
  57013. * @param name The mesh name
  57014. * @param scene The scene where to create the mesh
  57015. * @return the default mesh
  57016. */
  57017. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57018. }
  57019. }
  57020. declare module "babylonjs/PostProcesses/index" {
  57021. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57022. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57023. export * from "babylonjs/PostProcesses/bloomEffect";
  57024. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57025. export * from "babylonjs/PostProcesses/blurPostProcess";
  57026. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57027. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57028. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57029. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57030. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57031. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57032. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57033. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57034. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57035. export * from "babylonjs/PostProcesses/filterPostProcess";
  57036. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57037. export * from "babylonjs/PostProcesses/grainPostProcess";
  57038. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57039. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57040. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57041. export * from "babylonjs/PostProcesses/passPostProcess";
  57042. export * from "babylonjs/PostProcesses/postProcess";
  57043. export * from "babylonjs/PostProcesses/postProcessManager";
  57044. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57045. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57046. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57047. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57048. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57049. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57050. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57051. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57052. }
  57053. declare module "babylonjs/Probes/index" {
  57054. export * from "babylonjs/Probes/reflectionProbe";
  57055. }
  57056. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57057. import { Scene } from "babylonjs/scene";
  57058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57059. import { Color3 } from "babylonjs/Maths/math";
  57060. import { SmartArray } from "babylonjs/Misc/smartArray";
  57061. import { ISceneComponent } from "babylonjs/sceneComponent";
  57062. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57063. import "babylonjs/Meshes/Builders/boxBuilder";
  57064. import "babylonjs/Shaders/color.fragment";
  57065. import "babylonjs/Shaders/color.vertex";
  57066. module "babylonjs/scene" {
  57067. interface Scene {
  57068. /** @hidden (Backing field) */
  57069. _boundingBoxRenderer: BoundingBoxRenderer;
  57070. /** @hidden (Backing field) */
  57071. _forceShowBoundingBoxes: boolean;
  57072. /**
  57073. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57074. */
  57075. forceShowBoundingBoxes: boolean;
  57076. /**
  57077. * Gets the bounding box renderer associated with the scene
  57078. * @returns a BoundingBoxRenderer
  57079. */
  57080. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57081. }
  57082. }
  57083. module "babylonjs/Meshes/abstractMesh" {
  57084. interface AbstractMesh {
  57085. /** @hidden (Backing field) */
  57086. _showBoundingBox: boolean;
  57087. /**
  57088. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57089. */
  57090. showBoundingBox: boolean;
  57091. }
  57092. }
  57093. /**
  57094. * Component responsible of rendering the bounding box of the meshes in a scene.
  57095. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57096. */
  57097. export class BoundingBoxRenderer implements ISceneComponent {
  57098. /**
  57099. * The component name helpfull to identify the component in the list of scene components.
  57100. */
  57101. readonly name: string;
  57102. /**
  57103. * The scene the component belongs to.
  57104. */
  57105. scene: Scene;
  57106. /**
  57107. * Color of the bounding box lines placed in front of an object
  57108. */
  57109. frontColor: Color3;
  57110. /**
  57111. * Color of the bounding box lines placed behind an object
  57112. */
  57113. backColor: Color3;
  57114. /**
  57115. * Defines if the renderer should show the back lines or not
  57116. */
  57117. showBackLines: boolean;
  57118. /**
  57119. * @hidden
  57120. */
  57121. renderList: SmartArray<BoundingBox>;
  57122. private _colorShader;
  57123. private _vertexBuffers;
  57124. private _indexBuffer;
  57125. /**
  57126. * Instantiates a new bounding box renderer in a scene.
  57127. * @param scene the scene the renderer renders in
  57128. */
  57129. constructor(scene: Scene);
  57130. /**
  57131. * Registers the component in a given scene
  57132. */
  57133. register(): void;
  57134. private _evaluateSubMesh;
  57135. private _activeMesh;
  57136. private _prepareRessources;
  57137. private _createIndexBuffer;
  57138. /**
  57139. * Rebuilds the elements related to this component in case of
  57140. * context lost for instance.
  57141. */
  57142. rebuild(): void;
  57143. /**
  57144. * @hidden
  57145. */
  57146. reset(): void;
  57147. /**
  57148. * Render the bounding boxes of a specific rendering group
  57149. * @param renderingGroupId defines the rendering group to render
  57150. */
  57151. render(renderingGroupId: number): void;
  57152. /**
  57153. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57154. * @param mesh Define the mesh to render the occlusion bounding box for
  57155. */
  57156. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57157. /**
  57158. * Dispose and release the resources attached to this renderer.
  57159. */
  57160. dispose(): void;
  57161. }
  57162. }
  57163. declare module "babylonjs/Shaders/depth.fragment" {
  57164. /** @hidden */
  57165. export var depthPixelShader: {
  57166. name: string;
  57167. shader: string;
  57168. };
  57169. }
  57170. declare module "babylonjs/Rendering/depthRenderer" {
  57171. import { Nullable } from "babylonjs/types";
  57172. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57173. import { Scene } from "babylonjs/scene";
  57174. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57175. import { Camera } from "babylonjs/Cameras/camera";
  57176. import "babylonjs/Shaders/depth.fragment";
  57177. import "babylonjs/Shaders/depth.vertex";
  57178. /**
  57179. * This represents a depth renderer in Babylon.
  57180. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57181. */
  57182. export class DepthRenderer {
  57183. private _scene;
  57184. private _depthMap;
  57185. private _effect;
  57186. private _cachedDefines;
  57187. private _camera;
  57188. /**
  57189. * Specifiess that the depth renderer will only be used within
  57190. * the camera it is created for.
  57191. * This can help forcing its rendering during the camera processing.
  57192. */
  57193. useOnlyInActiveCamera: boolean;
  57194. /** @hidden */
  57195. static _SceneComponentInitialization: (scene: Scene) => void;
  57196. /**
  57197. * Instantiates a depth renderer
  57198. * @param scene The scene the renderer belongs to
  57199. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57200. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57201. */
  57202. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57203. /**
  57204. * Creates the depth rendering effect and checks if the effect is ready.
  57205. * @param subMesh The submesh to be used to render the depth map of
  57206. * @param useInstances If multiple world instances should be used
  57207. * @returns if the depth renderer is ready to render the depth map
  57208. */
  57209. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57210. /**
  57211. * Gets the texture which the depth map will be written to.
  57212. * @returns The depth map texture
  57213. */
  57214. getDepthMap(): RenderTargetTexture;
  57215. /**
  57216. * Disposes of the depth renderer.
  57217. */
  57218. dispose(): void;
  57219. }
  57220. }
  57221. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57222. import { Nullable } from "babylonjs/types";
  57223. import { Scene } from "babylonjs/scene";
  57224. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57225. import { Camera } from "babylonjs/Cameras/camera";
  57226. import { ISceneComponent } from "babylonjs/sceneComponent";
  57227. module "babylonjs/scene" {
  57228. interface Scene {
  57229. /** @hidden (Backing field) */
  57230. _depthRenderer: {
  57231. [id: string]: DepthRenderer;
  57232. };
  57233. /**
  57234. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57235. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57236. * @returns the created depth renderer
  57237. */
  57238. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57239. /**
  57240. * Disables a depth renderer for a given camera
  57241. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57242. */
  57243. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57244. }
  57245. }
  57246. /**
  57247. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57248. * in several rendering techniques.
  57249. */
  57250. export class DepthRendererSceneComponent implements ISceneComponent {
  57251. /**
  57252. * The component name helpfull to identify the component in the list of scene components.
  57253. */
  57254. readonly name: string;
  57255. /**
  57256. * The scene the component belongs to.
  57257. */
  57258. scene: Scene;
  57259. /**
  57260. * Creates a new instance of the component for the given scene
  57261. * @param scene Defines the scene to register the component in
  57262. */
  57263. constructor(scene: Scene);
  57264. /**
  57265. * Registers the component in a given scene
  57266. */
  57267. register(): void;
  57268. /**
  57269. * Rebuilds the elements related to this component in case of
  57270. * context lost for instance.
  57271. */
  57272. rebuild(): void;
  57273. /**
  57274. * Disposes the component and the associated ressources
  57275. */
  57276. dispose(): void;
  57277. private _gatherRenderTargets;
  57278. private _gatherActiveCameraRenderTargets;
  57279. }
  57280. }
  57281. declare module "babylonjs/Shaders/outline.fragment" {
  57282. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57283. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57284. /** @hidden */
  57285. export var outlinePixelShader: {
  57286. name: string;
  57287. shader: string;
  57288. };
  57289. }
  57290. declare module "babylonjs/Shaders/outline.vertex" {
  57291. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57292. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57293. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57294. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57295. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57296. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57297. /** @hidden */
  57298. export var outlineVertexShader: {
  57299. name: string;
  57300. shader: string;
  57301. };
  57302. }
  57303. declare module "babylonjs/Rendering/outlineRenderer" {
  57304. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57305. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57306. import { Scene } from "babylonjs/scene";
  57307. import { ISceneComponent } from "babylonjs/sceneComponent";
  57308. import "babylonjs/Shaders/outline.fragment";
  57309. import "babylonjs/Shaders/outline.vertex";
  57310. module "babylonjs/scene" {
  57311. interface Scene {
  57312. /** @hidden */
  57313. _outlineRenderer: OutlineRenderer;
  57314. /**
  57315. * Gets the outline renderer associated with the scene
  57316. * @returns a OutlineRenderer
  57317. */
  57318. getOutlineRenderer(): OutlineRenderer;
  57319. }
  57320. }
  57321. module "babylonjs/Meshes/abstractMesh" {
  57322. interface AbstractMesh {
  57323. /** @hidden (Backing field) */
  57324. _renderOutline: boolean;
  57325. /**
  57326. * Gets or sets a boolean indicating if the outline must be rendered as well
  57327. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57328. */
  57329. renderOutline: boolean;
  57330. /** @hidden (Backing field) */
  57331. _renderOverlay: boolean;
  57332. /**
  57333. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57334. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57335. */
  57336. renderOverlay: boolean;
  57337. }
  57338. }
  57339. /**
  57340. * This class is responsible to draw bothe outline/overlay of meshes.
  57341. * It should not be used directly but through the available method on mesh.
  57342. */
  57343. export class OutlineRenderer implements ISceneComponent {
  57344. /**
  57345. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57346. */
  57347. private static _StencilReference;
  57348. /**
  57349. * The name of the component. Each component must have a unique name.
  57350. */
  57351. name: string;
  57352. /**
  57353. * The scene the component belongs to.
  57354. */
  57355. scene: Scene;
  57356. /**
  57357. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57358. */
  57359. zOffset: number;
  57360. private _engine;
  57361. private _effect;
  57362. private _cachedDefines;
  57363. private _savedDepthWrite;
  57364. /**
  57365. * Instantiates a new outline renderer. (There could be only one per scene).
  57366. * @param scene Defines the scene it belongs to
  57367. */
  57368. constructor(scene: Scene);
  57369. /**
  57370. * Register the component to one instance of a scene.
  57371. */
  57372. register(): void;
  57373. /**
  57374. * Rebuilds the elements related to this component in case of
  57375. * context lost for instance.
  57376. */
  57377. rebuild(): void;
  57378. /**
  57379. * Disposes the component and the associated ressources.
  57380. */
  57381. dispose(): void;
  57382. /**
  57383. * Renders the outline in the canvas.
  57384. * @param subMesh Defines the sumesh to render
  57385. * @param batch Defines the batch of meshes in case of instances
  57386. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57387. */
  57388. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57389. /**
  57390. * Returns whether or not the outline renderer is ready for a given submesh.
  57391. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57392. * @param subMesh Defines the submesh to check readyness for
  57393. * @param useInstances Defines wheter wee are trying to render instances or not
  57394. * @returns true if ready otherwise false
  57395. */
  57396. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57397. private _beforeRenderingMesh;
  57398. private _afterRenderingMesh;
  57399. }
  57400. }
  57401. declare module "babylonjs/Rendering/index" {
  57402. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57403. export * from "babylonjs/Rendering/depthRenderer";
  57404. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57405. export * from "babylonjs/Rendering/edgesRenderer";
  57406. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57407. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57408. export * from "babylonjs/Rendering/outlineRenderer";
  57409. export * from "babylonjs/Rendering/renderingGroup";
  57410. export * from "babylonjs/Rendering/renderingManager";
  57411. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57412. }
  57413. declare module "babylonjs/Sprites/index" {
  57414. export * from "babylonjs/Sprites/sprite";
  57415. export * from "babylonjs/Sprites/spriteManager";
  57416. export * from "babylonjs/Sprites/spriteSceneComponent";
  57417. }
  57418. declare module "babylonjs/Misc/assetsManager" {
  57419. import { Scene } from "babylonjs/scene";
  57420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57421. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57422. import { Skeleton } from "babylonjs/Bones/skeleton";
  57423. import { Observable } from "babylonjs/Misc/observable";
  57424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57425. import { Texture } from "babylonjs/Materials/Textures/texture";
  57426. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57427. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57428. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57429. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57430. /**
  57431. * Defines the list of states available for a task inside a AssetsManager
  57432. */
  57433. export enum AssetTaskState {
  57434. /**
  57435. * Initialization
  57436. */
  57437. INIT = 0,
  57438. /**
  57439. * Running
  57440. */
  57441. RUNNING = 1,
  57442. /**
  57443. * Done
  57444. */
  57445. DONE = 2,
  57446. /**
  57447. * Error
  57448. */
  57449. ERROR = 3
  57450. }
  57451. /**
  57452. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57453. */
  57454. export abstract class AbstractAssetTask {
  57455. /**
  57456. * Task name
  57457. */ name: string;
  57458. /**
  57459. * Callback called when the task is successful
  57460. */
  57461. onSuccess: (task: any) => void;
  57462. /**
  57463. * Callback called when the task is not successful
  57464. */
  57465. onError: (task: any, message?: string, exception?: any) => void;
  57466. /**
  57467. * Creates a new AssetsManager
  57468. * @param name defines the name of the task
  57469. */
  57470. constructor(
  57471. /**
  57472. * Task name
  57473. */ name: string);
  57474. private _isCompleted;
  57475. private _taskState;
  57476. private _errorObject;
  57477. /**
  57478. * Get if the task is completed
  57479. */
  57480. readonly isCompleted: boolean;
  57481. /**
  57482. * Gets the current state of the task
  57483. */
  57484. readonly taskState: AssetTaskState;
  57485. /**
  57486. * Gets the current error object (if task is in error)
  57487. */
  57488. readonly errorObject: {
  57489. message?: string;
  57490. exception?: any;
  57491. };
  57492. /**
  57493. * Internal only
  57494. * @hidden
  57495. */
  57496. _setErrorObject(message?: string, exception?: any): void;
  57497. /**
  57498. * Execute the current task
  57499. * @param scene defines the scene where you want your assets to be loaded
  57500. * @param onSuccess is a callback called when the task is successfully executed
  57501. * @param onError is a callback called if an error occurs
  57502. */
  57503. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57504. /**
  57505. * Execute the current task
  57506. * @param scene defines the scene where you want your assets to be loaded
  57507. * @param onSuccess is a callback called when the task is successfully executed
  57508. * @param onError is a callback called if an error occurs
  57509. */
  57510. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57511. /**
  57512. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57513. * This can be used with failed tasks that have the reason for failure fixed.
  57514. */
  57515. reset(): void;
  57516. private onErrorCallback;
  57517. private onDoneCallback;
  57518. }
  57519. /**
  57520. * Define the interface used by progress events raised during assets loading
  57521. */
  57522. export interface IAssetsProgressEvent {
  57523. /**
  57524. * Defines the number of remaining tasks to process
  57525. */
  57526. remainingCount: number;
  57527. /**
  57528. * Defines the total number of tasks
  57529. */
  57530. totalCount: number;
  57531. /**
  57532. * Defines the task that was just processed
  57533. */
  57534. task: AbstractAssetTask;
  57535. }
  57536. /**
  57537. * Class used to share progress information about assets loading
  57538. */
  57539. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57540. /**
  57541. * Defines the number of remaining tasks to process
  57542. */
  57543. remainingCount: number;
  57544. /**
  57545. * Defines the total number of tasks
  57546. */
  57547. totalCount: number;
  57548. /**
  57549. * Defines the task that was just processed
  57550. */
  57551. task: AbstractAssetTask;
  57552. /**
  57553. * Creates a AssetsProgressEvent
  57554. * @param remainingCount defines the number of remaining tasks to process
  57555. * @param totalCount defines the total number of tasks
  57556. * @param task defines the task that was just processed
  57557. */
  57558. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57559. }
  57560. /**
  57561. * Define a task used by AssetsManager to load meshes
  57562. */
  57563. export class MeshAssetTask extends AbstractAssetTask {
  57564. /**
  57565. * Defines the name of the task
  57566. */
  57567. name: string;
  57568. /**
  57569. * Defines the list of mesh's names you want to load
  57570. */
  57571. meshesNames: any;
  57572. /**
  57573. * Defines the root url to use as a base to load your meshes and associated resources
  57574. */
  57575. rootUrl: string;
  57576. /**
  57577. * Defines the filename of the scene to load from
  57578. */
  57579. sceneFilename: string;
  57580. /**
  57581. * Gets the list of loaded meshes
  57582. */
  57583. loadedMeshes: Array<AbstractMesh>;
  57584. /**
  57585. * Gets the list of loaded particle systems
  57586. */
  57587. loadedParticleSystems: Array<IParticleSystem>;
  57588. /**
  57589. * Gets the list of loaded skeletons
  57590. */
  57591. loadedSkeletons: Array<Skeleton>;
  57592. /**
  57593. * Gets the list of loaded animation groups
  57594. */
  57595. loadedAnimationGroups: Array<AnimationGroup>;
  57596. /**
  57597. * Callback called when the task is successful
  57598. */
  57599. onSuccess: (task: MeshAssetTask) => void;
  57600. /**
  57601. * Callback called when the task is successful
  57602. */
  57603. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57604. /**
  57605. * Creates a new MeshAssetTask
  57606. * @param name defines the name of the task
  57607. * @param meshesNames defines the list of mesh's names you want to load
  57608. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57609. * @param sceneFilename defines the filename of the scene to load from
  57610. */
  57611. constructor(
  57612. /**
  57613. * Defines the name of the task
  57614. */
  57615. name: string,
  57616. /**
  57617. * Defines the list of mesh's names you want to load
  57618. */
  57619. meshesNames: any,
  57620. /**
  57621. * Defines the root url to use as a base to load your meshes and associated resources
  57622. */
  57623. rootUrl: string,
  57624. /**
  57625. * Defines the filename of the scene to load from
  57626. */
  57627. sceneFilename: string);
  57628. /**
  57629. * Execute the current task
  57630. * @param scene defines the scene where you want your assets to be loaded
  57631. * @param onSuccess is a callback called when the task is successfully executed
  57632. * @param onError is a callback called if an error occurs
  57633. */
  57634. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57635. }
  57636. /**
  57637. * Define a task used by AssetsManager to load text content
  57638. */
  57639. export class TextFileAssetTask extends AbstractAssetTask {
  57640. /**
  57641. * Defines the name of the task
  57642. */
  57643. name: string;
  57644. /**
  57645. * Defines the location of the file to load
  57646. */
  57647. url: string;
  57648. /**
  57649. * Gets the loaded text string
  57650. */
  57651. text: string;
  57652. /**
  57653. * Callback called when the task is successful
  57654. */
  57655. onSuccess: (task: TextFileAssetTask) => void;
  57656. /**
  57657. * Callback called when the task is successful
  57658. */
  57659. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57660. /**
  57661. * Creates a new TextFileAssetTask object
  57662. * @param name defines the name of the task
  57663. * @param url defines the location of the file to load
  57664. */
  57665. constructor(
  57666. /**
  57667. * Defines the name of the task
  57668. */
  57669. name: string,
  57670. /**
  57671. * Defines the location of the file to load
  57672. */
  57673. url: string);
  57674. /**
  57675. * Execute the current task
  57676. * @param scene defines the scene where you want your assets to be loaded
  57677. * @param onSuccess is a callback called when the task is successfully executed
  57678. * @param onError is a callback called if an error occurs
  57679. */
  57680. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57681. }
  57682. /**
  57683. * Define a task used by AssetsManager to load binary data
  57684. */
  57685. export class BinaryFileAssetTask extends AbstractAssetTask {
  57686. /**
  57687. * Defines the name of the task
  57688. */
  57689. name: string;
  57690. /**
  57691. * Defines the location of the file to load
  57692. */
  57693. url: string;
  57694. /**
  57695. * Gets the lodaded data (as an array buffer)
  57696. */
  57697. data: ArrayBuffer;
  57698. /**
  57699. * Callback called when the task is successful
  57700. */
  57701. onSuccess: (task: BinaryFileAssetTask) => void;
  57702. /**
  57703. * Callback called when the task is successful
  57704. */
  57705. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57706. /**
  57707. * Creates a new BinaryFileAssetTask object
  57708. * @param name defines the name of the new task
  57709. * @param url defines the location of the file to load
  57710. */
  57711. constructor(
  57712. /**
  57713. * Defines the name of the task
  57714. */
  57715. name: string,
  57716. /**
  57717. * Defines the location of the file to load
  57718. */
  57719. url: string);
  57720. /**
  57721. * Execute the current task
  57722. * @param scene defines the scene where you want your assets to be loaded
  57723. * @param onSuccess is a callback called when the task is successfully executed
  57724. * @param onError is a callback called if an error occurs
  57725. */
  57726. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57727. }
  57728. /**
  57729. * Define a task used by AssetsManager to load images
  57730. */
  57731. export class ImageAssetTask extends AbstractAssetTask {
  57732. /**
  57733. * Defines the name of the task
  57734. */
  57735. name: string;
  57736. /**
  57737. * Defines the location of the image to load
  57738. */
  57739. url: string;
  57740. /**
  57741. * Gets the loaded images
  57742. */
  57743. image: HTMLImageElement;
  57744. /**
  57745. * Callback called when the task is successful
  57746. */
  57747. onSuccess: (task: ImageAssetTask) => void;
  57748. /**
  57749. * Callback called when the task is successful
  57750. */
  57751. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57752. /**
  57753. * Creates a new ImageAssetTask
  57754. * @param name defines the name of the task
  57755. * @param url defines the location of the image to load
  57756. */
  57757. constructor(
  57758. /**
  57759. * Defines the name of the task
  57760. */
  57761. name: string,
  57762. /**
  57763. * Defines the location of the image to load
  57764. */
  57765. url: string);
  57766. /**
  57767. * Execute the current task
  57768. * @param scene defines the scene where you want your assets to be loaded
  57769. * @param onSuccess is a callback called when the task is successfully executed
  57770. * @param onError is a callback called if an error occurs
  57771. */
  57772. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57773. }
  57774. /**
  57775. * Defines the interface used by texture loading tasks
  57776. */
  57777. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57778. /**
  57779. * Gets the loaded texture
  57780. */
  57781. texture: TEX;
  57782. }
  57783. /**
  57784. * Define a task used by AssetsManager to load 2D textures
  57785. */
  57786. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57787. /**
  57788. * Defines the name of the task
  57789. */
  57790. name: string;
  57791. /**
  57792. * Defines the location of the file to load
  57793. */
  57794. url: string;
  57795. /**
  57796. * Defines if mipmap should not be generated (default is false)
  57797. */
  57798. noMipmap?: boolean | undefined;
  57799. /**
  57800. * Defines if texture must be inverted on Y axis (default is false)
  57801. */
  57802. invertY?: boolean | undefined;
  57803. /**
  57804. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57805. */
  57806. samplingMode: number;
  57807. /**
  57808. * Gets the loaded texture
  57809. */
  57810. texture: Texture;
  57811. /**
  57812. * Callback called when the task is successful
  57813. */
  57814. onSuccess: (task: TextureAssetTask) => void;
  57815. /**
  57816. * Callback called when the task is successful
  57817. */
  57818. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57819. /**
  57820. * Creates a new TextureAssetTask object
  57821. * @param name defines the name of the task
  57822. * @param url defines the location of the file to load
  57823. * @param noMipmap defines if mipmap should not be generated (default is false)
  57824. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57825. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57826. */
  57827. constructor(
  57828. /**
  57829. * Defines the name of the task
  57830. */
  57831. name: string,
  57832. /**
  57833. * Defines the location of the file to load
  57834. */
  57835. url: string,
  57836. /**
  57837. * Defines if mipmap should not be generated (default is false)
  57838. */
  57839. noMipmap?: boolean | undefined,
  57840. /**
  57841. * Defines if texture must be inverted on Y axis (default is false)
  57842. */
  57843. invertY?: boolean | undefined,
  57844. /**
  57845. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57846. */
  57847. samplingMode?: number);
  57848. /**
  57849. * Execute the current task
  57850. * @param scene defines the scene where you want your assets to be loaded
  57851. * @param onSuccess is a callback called when the task is successfully executed
  57852. * @param onError is a callback called if an error occurs
  57853. */
  57854. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57855. }
  57856. /**
  57857. * Define a task used by AssetsManager to load cube textures
  57858. */
  57859. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57860. /**
  57861. * Defines the name of the task
  57862. */
  57863. name: string;
  57864. /**
  57865. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57866. */
  57867. url: string;
  57868. /**
  57869. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57870. */
  57871. extensions?: string[] | undefined;
  57872. /**
  57873. * Defines if mipmaps should not be generated (default is false)
  57874. */
  57875. noMipmap?: boolean | undefined;
  57876. /**
  57877. * Defines the explicit list of files (undefined by default)
  57878. */
  57879. files?: string[] | undefined;
  57880. /**
  57881. * Gets the loaded texture
  57882. */
  57883. texture: CubeTexture;
  57884. /**
  57885. * Callback called when the task is successful
  57886. */
  57887. onSuccess: (task: CubeTextureAssetTask) => void;
  57888. /**
  57889. * Callback called when the task is successful
  57890. */
  57891. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57892. /**
  57893. * Creates a new CubeTextureAssetTask
  57894. * @param name defines the name of the task
  57895. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57896. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57897. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57898. * @param files defines the explicit list of files (undefined by default)
  57899. */
  57900. constructor(
  57901. /**
  57902. * Defines the name of the task
  57903. */
  57904. name: string,
  57905. /**
  57906. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57907. */
  57908. url: string,
  57909. /**
  57910. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57911. */
  57912. extensions?: string[] | undefined,
  57913. /**
  57914. * Defines if mipmaps should not be generated (default is false)
  57915. */
  57916. noMipmap?: boolean | undefined,
  57917. /**
  57918. * Defines the explicit list of files (undefined by default)
  57919. */
  57920. files?: string[] | undefined);
  57921. /**
  57922. * Execute the current task
  57923. * @param scene defines the scene where you want your assets to be loaded
  57924. * @param onSuccess is a callback called when the task is successfully executed
  57925. * @param onError is a callback called if an error occurs
  57926. */
  57927. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57928. }
  57929. /**
  57930. * Define a task used by AssetsManager to load HDR cube textures
  57931. */
  57932. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57933. /**
  57934. * Defines the name of the task
  57935. */
  57936. name: string;
  57937. /**
  57938. * Defines the location of the file to load
  57939. */
  57940. url: string;
  57941. /**
  57942. * Defines the desired size (the more it increases the longer the generation will be)
  57943. */
  57944. size: number;
  57945. /**
  57946. * Defines if mipmaps should not be generated (default is false)
  57947. */
  57948. noMipmap: boolean;
  57949. /**
  57950. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57951. */
  57952. generateHarmonics: boolean;
  57953. /**
  57954. * 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)
  57955. */
  57956. gammaSpace: boolean;
  57957. /**
  57958. * Internal Use Only
  57959. */
  57960. reserved: boolean;
  57961. /**
  57962. * Gets the loaded texture
  57963. */
  57964. texture: HDRCubeTexture;
  57965. /**
  57966. * Callback called when the task is successful
  57967. */
  57968. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57969. /**
  57970. * Callback called when the task is successful
  57971. */
  57972. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57973. /**
  57974. * Creates a new HDRCubeTextureAssetTask object
  57975. * @param name defines the name of the task
  57976. * @param url defines the location of the file to load
  57977. * @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.
  57978. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57979. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57980. * @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)
  57981. * @param reserved Internal use only
  57982. */
  57983. constructor(
  57984. /**
  57985. * Defines the name of the task
  57986. */
  57987. name: string,
  57988. /**
  57989. * Defines the location of the file to load
  57990. */
  57991. url: string,
  57992. /**
  57993. * Defines the desired size (the more it increases the longer the generation will be)
  57994. */
  57995. size: number,
  57996. /**
  57997. * Defines if mipmaps should not be generated (default is false)
  57998. */
  57999. noMipmap?: boolean,
  58000. /**
  58001. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58002. */
  58003. generateHarmonics?: boolean,
  58004. /**
  58005. * 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)
  58006. */
  58007. gammaSpace?: boolean,
  58008. /**
  58009. * Internal Use Only
  58010. */
  58011. reserved?: 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. * Define a task used by AssetsManager to load Equirectangular cube textures
  58022. */
  58023. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58024. /**
  58025. * Defines the name of the task
  58026. */
  58027. name: string;
  58028. /**
  58029. * Defines the location of the file to load
  58030. */
  58031. url: string;
  58032. /**
  58033. * Defines the desired size (the more it increases the longer the generation will be)
  58034. */
  58035. size: number;
  58036. /**
  58037. * Defines if mipmaps should not be generated (default is false)
  58038. */
  58039. noMipmap: boolean;
  58040. /**
  58041. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58042. * but the standard material would require them in Gamma space) (default is true)
  58043. */
  58044. gammaSpace: boolean;
  58045. /**
  58046. * Gets the loaded texture
  58047. */
  58048. texture: EquiRectangularCubeTexture;
  58049. /**
  58050. * Callback called when the task is successful
  58051. */
  58052. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58053. /**
  58054. * Callback called when the task is successful
  58055. */
  58056. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58057. /**
  58058. * Creates a new EquiRectangularCubeTextureAssetTask object
  58059. * @param name defines the name of the task
  58060. * @param url defines the location of the file to load
  58061. * @param size defines the desired size (the more it increases the longer the generation will be)
  58062. * If the size is omitted this implies you are using a preprocessed cubemap.
  58063. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58064. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58065. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58066. * (default is true)
  58067. */
  58068. constructor(
  58069. /**
  58070. * Defines the name of the task
  58071. */
  58072. name: string,
  58073. /**
  58074. * Defines the location of the file to load
  58075. */
  58076. url: string,
  58077. /**
  58078. * Defines the desired size (the more it increases the longer the generation will be)
  58079. */
  58080. size: number,
  58081. /**
  58082. * Defines if mipmaps should not be generated (default is false)
  58083. */
  58084. noMipmap?: boolean,
  58085. /**
  58086. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58087. * but the standard material would require them in Gamma space) (default is true)
  58088. */
  58089. gammaSpace?: boolean);
  58090. /**
  58091. * Execute the current task
  58092. * @param scene defines the scene where you want your assets to be loaded
  58093. * @param onSuccess is a callback called when the task is successfully executed
  58094. * @param onError is a callback called if an error occurs
  58095. */
  58096. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58097. }
  58098. /**
  58099. * This class can be used to easily import assets into a scene
  58100. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58101. */
  58102. export class AssetsManager {
  58103. private _scene;
  58104. private _isLoading;
  58105. protected _tasks: AbstractAssetTask[];
  58106. protected _waitingTasksCount: number;
  58107. protected _totalTasksCount: number;
  58108. /**
  58109. * Callback called when all tasks are processed
  58110. */
  58111. onFinish: (tasks: AbstractAssetTask[]) => void;
  58112. /**
  58113. * Callback called when a task is successful
  58114. */
  58115. onTaskSuccess: (task: AbstractAssetTask) => void;
  58116. /**
  58117. * Callback called when a task had an error
  58118. */
  58119. onTaskError: (task: AbstractAssetTask) => void;
  58120. /**
  58121. * Callback called when a task is done (whatever the result is)
  58122. */
  58123. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58124. /**
  58125. * Observable called when all tasks are processed
  58126. */
  58127. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58128. /**
  58129. * Observable called when a task had an error
  58130. */
  58131. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58132. /**
  58133. * Observable called when all tasks were executed
  58134. */
  58135. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58136. /**
  58137. * Observable called when a task is done (whatever the result is)
  58138. */
  58139. onProgressObservable: Observable<IAssetsProgressEvent>;
  58140. /**
  58141. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58142. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58143. */
  58144. useDefaultLoadingScreen: boolean;
  58145. /**
  58146. * Creates a new AssetsManager
  58147. * @param scene defines the scene to work on
  58148. */
  58149. constructor(scene: Scene);
  58150. /**
  58151. * Add a MeshAssetTask to the list of active tasks
  58152. * @param taskName defines the name of the new task
  58153. * @param meshesNames defines the name of meshes to load
  58154. * @param rootUrl defines the root url to use to locate files
  58155. * @param sceneFilename defines the filename of the scene file
  58156. * @returns a new MeshAssetTask object
  58157. */
  58158. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58159. /**
  58160. * Add a TextFileAssetTask to the list of active tasks
  58161. * @param taskName defines the name of the new task
  58162. * @param url defines the url of the file to load
  58163. * @returns a new TextFileAssetTask object
  58164. */
  58165. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58166. /**
  58167. * Add a BinaryFileAssetTask to the list of active tasks
  58168. * @param taskName defines the name of the new task
  58169. * @param url defines the url of the file to load
  58170. * @returns a new BinaryFileAssetTask object
  58171. */
  58172. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58173. /**
  58174. * Add a ImageAssetTask to the list of active tasks
  58175. * @param taskName defines the name of the new task
  58176. * @param url defines the url of the file to load
  58177. * @returns a new ImageAssetTask object
  58178. */
  58179. addImageTask(taskName: string, url: string): ImageAssetTask;
  58180. /**
  58181. * Add a TextureAssetTask to the list of active tasks
  58182. * @param taskName defines the name of the new task
  58183. * @param url defines the url of the file to load
  58184. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58185. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58186. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58187. * @returns a new TextureAssetTask object
  58188. */
  58189. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58190. /**
  58191. * Add a CubeTextureAssetTask to the list of active tasks
  58192. * @param taskName defines the name of the new task
  58193. * @param url defines the url of the file to load
  58194. * @param extensions defines the extension to use to load the cube map (can be null)
  58195. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58196. * @param files defines the list of files to load (can be null)
  58197. * @returns a new CubeTextureAssetTask object
  58198. */
  58199. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58200. /**
  58201. *
  58202. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58203. * @param taskName defines the name of the new task
  58204. * @param url defines the url of the file to load
  58205. * @param size defines the size you want for the cubemap (can be null)
  58206. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58207. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58208. * @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)
  58209. * @param reserved Internal use only
  58210. * @returns a new HDRCubeTextureAssetTask object
  58211. */
  58212. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58213. /**
  58214. *
  58215. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58216. * @param taskName defines the name of the new task
  58217. * @param url defines the url of the file to load
  58218. * @param size defines the size you want for the cubemap (can be null)
  58219. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58220. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58221. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58222. * @returns a new EquiRectangularCubeTextureAssetTask object
  58223. */
  58224. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58225. /**
  58226. * Remove a task from the assets manager.
  58227. * @param task the task to remove
  58228. */
  58229. removeTask(task: AbstractAssetTask): void;
  58230. private _decreaseWaitingTasksCount;
  58231. private _runTask;
  58232. /**
  58233. * Reset the AssetsManager and remove all tasks
  58234. * @return the current instance of the AssetsManager
  58235. */
  58236. reset(): AssetsManager;
  58237. /**
  58238. * Start the loading process
  58239. * @return the current instance of the AssetsManager
  58240. */
  58241. load(): AssetsManager;
  58242. /**
  58243. * Start the loading process as an async operation
  58244. * @return a promise returning the list of failed tasks
  58245. */
  58246. loadAsync(): Promise<void>;
  58247. }
  58248. }
  58249. declare module "babylonjs/Misc/deferred" {
  58250. /**
  58251. * Wrapper class for promise with external resolve and reject.
  58252. */
  58253. export class Deferred<T> {
  58254. /**
  58255. * The promise associated with this deferred object.
  58256. */
  58257. readonly promise: Promise<T>;
  58258. private _resolve;
  58259. private _reject;
  58260. /**
  58261. * The resolve method of the promise associated with this deferred object.
  58262. */
  58263. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58264. /**
  58265. * The reject method of the promise associated with this deferred object.
  58266. */
  58267. readonly reject: (reason?: any) => void;
  58268. /**
  58269. * Constructor for this deferred object.
  58270. */
  58271. constructor();
  58272. }
  58273. }
  58274. declare module "babylonjs/Misc/meshExploder" {
  58275. import { Mesh } from "babylonjs/Meshes/mesh";
  58276. /**
  58277. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58278. */
  58279. export class MeshExploder {
  58280. private _centerMesh;
  58281. private _meshes;
  58282. private _meshesOrigins;
  58283. private _toCenterVectors;
  58284. private _scaledDirection;
  58285. private _newPosition;
  58286. private _centerPosition;
  58287. /**
  58288. * Explodes meshes from a center mesh.
  58289. * @param meshes The meshes to explode.
  58290. * @param centerMesh The mesh to be center of explosion.
  58291. */
  58292. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58293. private _setCenterMesh;
  58294. /**
  58295. * Get class name
  58296. * @returns "MeshExploder"
  58297. */
  58298. getClassName(): string;
  58299. /**
  58300. * "Exploded meshes"
  58301. * @returns Array of meshes with the centerMesh at index 0.
  58302. */
  58303. getMeshes(): Array<Mesh>;
  58304. /**
  58305. * Explodes meshes giving a specific direction
  58306. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58307. */
  58308. explode(direction?: number): void;
  58309. }
  58310. }
  58311. declare module "babylonjs/Misc/filesInput" {
  58312. import { Engine } from "babylonjs/Engines/engine";
  58313. import { Scene } from "babylonjs/scene";
  58314. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58315. /**
  58316. * Class used to help managing file picking and drag'n'drop
  58317. */
  58318. export class FilesInput {
  58319. /**
  58320. * List of files ready to be loaded
  58321. */
  58322. static readonly FilesToLoad: {
  58323. [key: string]: File;
  58324. };
  58325. /**
  58326. * Callback called when a file is processed
  58327. */
  58328. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58329. private _engine;
  58330. private _currentScene;
  58331. private _sceneLoadedCallback;
  58332. private _progressCallback;
  58333. private _additionalRenderLoopLogicCallback;
  58334. private _textureLoadingCallback;
  58335. private _startingProcessingFilesCallback;
  58336. private _onReloadCallback;
  58337. private _errorCallback;
  58338. private _elementToMonitor;
  58339. private _sceneFileToLoad;
  58340. private _filesToLoad;
  58341. /**
  58342. * Creates a new FilesInput
  58343. * @param engine defines the rendering engine
  58344. * @param scene defines the hosting scene
  58345. * @param sceneLoadedCallback callback called when scene is loaded
  58346. * @param progressCallback callback called to track progress
  58347. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58348. * @param textureLoadingCallback callback called when a texture is loading
  58349. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58350. * @param onReloadCallback callback called when a reload is requested
  58351. * @param errorCallback callback call if an error occurs
  58352. */
  58353. 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);
  58354. private _dragEnterHandler;
  58355. private _dragOverHandler;
  58356. private _dropHandler;
  58357. /**
  58358. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58359. * @param elementToMonitor defines the DOM element to track
  58360. */
  58361. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58362. /**
  58363. * Release all associated resources
  58364. */
  58365. dispose(): void;
  58366. private renderFunction;
  58367. private drag;
  58368. private drop;
  58369. private _traverseFolder;
  58370. private _processFiles;
  58371. /**
  58372. * Load files from a drop event
  58373. * @param event defines the drop event to use as source
  58374. */
  58375. loadFiles(event: any): void;
  58376. private _processReload;
  58377. /**
  58378. * Reload the current scene from the loaded files
  58379. */
  58380. reload(): void;
  58381. }
  58382. }
  58383. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58384. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58385. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58386. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58387. }
  58388. declare module "babylonjs/Misc/sceneOptimizer" {
  58389. import { Scene, IDisposable } from "babylonjs/scene";
  58390. import { Observable } from "babylonjs/Misc/observable";
  58391. /**
  58392. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58393. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58394. */
  58395. export class SceneOptimization {
  58396. /**
  58397. * Defines the priority of this optimization (0 by default which means first in the list)
  58398. */
  58399. priority: number;
  58400. /**
  58401. * Gets a string describing the action executed by the current optimization
  58402. * @returns description string
  58403. */
  58404. getDescription(): string;
  58405. /**
  58406. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58407. * @param scene defines the current scene where to apply this optimization
  58408. * @param optimizer defines the current optimizer
  58409. * @returns true if everything that can be done was applied
  58410. */
  58411. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58412. /**
  58413. * Creates the SceneOptimization object
  58414. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58415. * @param desc defines the description associated with the optimization
  58416. */
  58417. constructor(
  58418. /**
  58419. * Defines the priority of this optimization (0 by default which means first in the list)
  58420. */
  58421. priority?: number);
  58422. }
  58423. /**
  58424. * Defines an optimization used to reduce the size of render target textures
  58425. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58426. */
  58427. export class TextureOptimization extends SceneOptimization {
  58428. /**
  58429. * Defines the priority of this optimization (0 by default which means first in the list)
  58430. */
  58431. priority: number;
  58432. /**
  58433. * 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
  58434. */
  58435. maximumSize: number;
  58436. /**
  58437. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58438. */
  58439. step: number;
  58440. /**
  58441. * Gets a string describing the action executed by the current optimization
  58442. * @returns description string
  58443. */
  58444. getDescription(): string;
  58445. /**
  58446. * Creates the TextureOptimization object
  58447. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58448. * @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
  58449. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58450. */
  58451. constructor(
  58452. /**
  58453. * Defines the priority of this optimization (0 by default which means first in the list)
  58454. */
  58455. priority?: number,
  58456. /**
  58457. * 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
  58458. */
  58459. maximumSize?: number,
  58460. /**
  58461. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58462. */
  58463. step?: number);
  58464. /**
  58465. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58466. * @param scene defines the current scene where to apply this optimization
  58467. * @param optimizer defines the current optimizer
  58468. * @returns true if everything that can be done was applied
  58469. */
  58470. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58471. }
  58472. /**
  58473. * Defines an optimization used to increase or decrease the rendering resolution
  58474. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58475. */
  58476. export class HardwareScalingOptimization extends SceneOptimization {
  58477. /**
  58478. * Defines the priority of this optimization (0 by default which means first in the list)
  58479. */
  58480. priority: number;
  58481. /**
  58482. * Defines the maximum scale to use (2 by default)
  58483. */
  58484. maximumScale: number;
  58485. /**
  58486. * Defines the step to use between two passes (0.5 by default)
  58487. */
  58488. step: number;
  58489. private _currentScale;
  58490. private _directionOffset;
  58491. /**
  58492. * Gets a string describing the action executed by the current optimization
  58493. * @return description string
  58494. */
  58495. getDescription(): string;
  58496. /**
  58497. * Creates the HardwareScalingOptimization object
  58498. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58499. * @param maximumScale defines the maximum scale to use (2 by default)
  58500. * @param step defines the step to use between two passes (0.5 by default)
  58501. */
  58502. constructor(
  58503. /**
  58504. * Defines the priority of this optimization (0 by default which means first in the list)
  58505. */
  58506. priority?: number,
  58507. /**
  58508. * Defines the maximum scale to use (2 by default)
  58509. */
  58510. maximumScale?: number,
  58511. /**
  58512. * Defines the step to use between two passes (0.5 by default)
  58513. */
  58514. step?: number);
  58515. /**
  58516. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58517. * @param scene defines the current scene where to apply this optimization
  58518. * @param optimizer defines the current optimizer
  58519. * @returns true if everything that can be done was applied
  58520. */
  58521. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58522. }
  58523. /**
  58524. * Defines an optimization used to remove shadows
  58525. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58526. */
  58527. export class ShadowsOptimization extends SceneOptimization {
  58528. /**
  58529. * Gets a string describing the action executed by the current optimization
  58530. * @return description string
  58531. */
  58532. getDescription(): string;
  58533. /**
  58534. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58535. * @param scene defines the current scene where to apply this optimization
  58536. * @param optimizer defines the current optimizer
  58537. * @returns true if everything that can be done was applied
  58538. */
  58539. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58540. }
  58541. /**
  58542. * Defines an optimization used to turn post-processes off
  58543. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58544. */
  58545. export class PostProcessesOptimization extends SceneOptimization {
  58546. /**
  58547. * Gets a string describing the action executed by the current optimization
  58548. * @return description string
  58549. */
  58550. getDescription(): string;
  58551. /**
  58552. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58553. * @param scene defines the current scene where to apply this optimization
  58554. * @param optimizer defines the current optimizer
  58555. * @returns true if everything that can be done was applied
  58556. */
  58557. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58558. }
  58559. /**
  58560. * Defines an optimization used to turn lens flares off
  58561. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58562. */
  58563. export class LensFlaresOptimization extends SceneOptimization {
  58564. /**
  58565. * Gets a string describing the action executed by the current optimization
  58566. * @return description string
  58567. */
  58568. getDescription(): string;
  58569. /**
  58570. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58571. * @param scene defines the current scene where to apply this optimization
  58572. * @param optimizer defines the current optimizer
  58573. * @returns true if everything that can be done was applied
  58574. */
  58575. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58576. }
  58577. /**
  58578. * Defines an optimization based on user defined callback.
  58579. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58580. */
  58581. export class CustomOptimization extends SceneOptimization {
  58582. /**
  58583. * Callback called to apply the custom optimization.
  58584. */
  58585. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58586. /**
  58587. * Callback called to get custom description
  58588. */
  58589. onGetDescription: () => string;
  58590. /**
  58591. * Gets a string describing the action executed by the current optimization
  58592. * @returns description string
  58593. */
  58594. getDescription(): string;
  58595. /**
  58596. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58597. * @param scene defines the current scene where to apply this optimization
  58598. * @param optimizer defines the current optimizer
  58599. * @returns true if everything that can be done was applied
  58600. */
  58601. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58602. }
  58603. /**
  58604. * Defines an optimization used to turn particles off
  58605. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58606. */
  58607. export class ParticlesOptimization extends SceneOptimization {
  58608. /**
  58609. * Gets a string describing the action executed by the current optimization
  58610. * @return description string
  58611. */
  58612. getDescription(): string;
  58613. /**
  58614. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58615. * @param scene defines the current scene where to apply this optimization
  58616. * @param optimizer defines the current optimizer
  58617. * @returns true if everything that can be done was applied
  58618. */
  58619. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58620. }
  58621. /**
  58622. * Defines an optimization used to turn render targets off
  58623. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58624. */
  58625. export class RenderTargetsOptimization extends SceneOptimization {
  58626. /**
  58627. * Gets a string describing the action executed by the current optimization
  58628. * @return description string
  58629. */
  58630. getDescription(): string;
  58631. /**
  58632. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58633. * @param scene defines the current scene where to apply this optimization
  58634. * @param optimizer defines the current optimizer
  58635. * @returns true if everything that can be done was applied
  58636. */
  58637. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58638. }
  58639. /**
  58640. * Defines an optimization used to merge meshes with compatible materials
  58641. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58642. */
  58643. export class MergeMeshesOptimization extends SceneOptimization {
  58644. private static _UpdateSelectionTree;
  58645. /**
  58646. * Gets or sets a boolean which defines if optimization octree has to be updated
  58647. */
  58648. /**
  58649. * Gets or sets a boolean which defines if optimization octree has to be updated
  58650. */
  58651. static UpdateSelectionTree: boolean;
  58652. /**
  58653. * Gets a string describing the action executed by the current optimization
  58654. * @return description string
  58655. */
  58656. getDescription(): string;
  58657. private _canBeMerged;
  58658. /**
  58659. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58660. * @param scene defines the current scene where to apply this optimization
  58661. * @param optimizer defines the current optimizer
  58662. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58663. * @returns true if everything that can be done was applied
  58664. */
  58665. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58666. }
  58667. /**
  58668. * Defines a list of options used by SceneOptimizer
  58669. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58670. */
  58671. export class SceneOptimizerOptions {
  58672. /**
  58673. * Defines the target frame rate to reach (60 by default)
  58674. */
  58675. targetFrameRate: number;
  58676. /**
  58677. * Defines the interval between two checkes (2000ms by default)
  58678. */
  58679. trackerDuration: number;
  58680. /**
  58681. * Gets the list of optimizations to apply
  58682. */
  58683. optimizations: SceneOptimization[];
  58684. /**
  58685. * Creates a new list of options used by SceneOptimizer
  58686. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58687. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58688. */
  58689. constructor(
  58690. /**
  58691. * Defines the target frame rate to reach (60 by default)
  58692. */
  58693. targetFrameRate?: number,
  58694. /**
  58695. * Defines the interval between two checkes (2000ms by default)
  58696. */
  58697. trackerDuration?: number);
  58698. /**
  58699. * Add a new optimization
  58700. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58701. * @returns the current SceneOptimizerOptions
  58702. */
  58703. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58704. /**
  58705. * Add a new custom optimization
  58706. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58707. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58708. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58709. * @returns the current SceneOptimizerOptions
  58710. */
  58711. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58712. /**
  58713. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58714. * @param targetFrameRate defines the target frame rate (60 by default)
  58715. * @returns a SceneOptimizerOptions object
  58716. */
  58717. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58718. /**
  58719. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58720. * @param targetFrameRate defines the target frame rate (60 by default)
  58721. * @returns a SceneOptimizerOptions object
  58722. */
  58723. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58724. /**
  58725. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58726. * @param targetFrameRate defines the target frame rate (60 by default)
  58727. * @returns a SceneOptimizerOptions object
  58728. */
  58729. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58730. }
  58731. /**
  58732. * Class used to run optimizations in order to reach a target frame rate
  58733. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58734. */
  58735. export class SceneOptimizer implements IDisposable {
  58736. private _isRunning;
  58737. private _options;
  58738. private _scene;
  58739. private _currentPriorityLevel;
  58740. private _targetFrameRate;
  58741. private _trackerDuration;
  58742. private _currentFrameRate;
  58743. private _sceneDisposeObserver;
  58744. private _improvementMode;
  58745. /**
  58746. * Defines an observable called when the optimizer reaches the target frame rate
  58747. */
  58748. onSuccessObservable: Observable<SceneOptimizer>;
  58749. /**
  58750. * Defines an observable called when the optimizer enables an optimization
  58751. */
  58752. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58753. /**
  58754. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58755. */
  58756. onFailureObservable: Observable<SceneOptimizer>;
  58757. /**
  58758. * Gets a boolean indicating if the optimizer is in improvement mode
  58759. */
  58760. readonly isInImprovementMode: boolean;
  58761. /**
  58762. * Gets the current priority level (0 at start)
  58763. */
  58764. readonly currentPriorityLevel: number;
  58765. /**
  58766. * Gets the current frame rate checked by the SceneOptimizer
  58767. */
  58768. readonly currentFrameRate: number;
  58769. /**
  58770. * Gets or sets the current target frame rate (60 by default)
  58771. */
  58772. /**
  58773. * Gets or sets the current target frame rate (60 by default)
  58774. */
  58775. targetFrameRate: number;
  58776. /**
  58777. * Gets or sets the current interval between two checks (every 2000ms by default)
  58778. */
  58779. /**
  58780. * Gets or sets the current interval between two checks (every 2000ms by default)
  58781. */
  58782. trackerDuration: number;
  58783. /**
  58784. * Gets the list of active optimizations
  58785. */
  58786. readonly optimizations: SceneOptimization[];
  58787. /**
  58788. * Creates a new SceneOptimizer
  58789. * @param scene defines the scene to work on
  58790. * @param options defines the options to use with the SceneOptimizer
  58791. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58792. * @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)
  58793. */
  58794. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58795. /**
  58796. * Stops the current optimizer
  58797. */
  58798. stop(): void;
  58799. /**
  58800. * Reset the optimizer to initial step (current priority level = 0)
  58801. */
  58802. reset(): void;
  58803. /**
  58804. * Start the optimizer. By default it will try to reach a specific framerate
  58805. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58806. */
  58807. start(): void;
  58808. private _checkCurrentState;
  58809. /**
  58810. * Release all resources
  58811. */
  58812. dispose(): void;
  58813. /**
  58814. * Helper function to create a SceneOptimizer with one single line of code
  58815. * @param scene defines the scene to work on
  58816. * @param options defines the options to use with the SceneOptimizer
  58817. * @param onSuccess defines a callback to call on success
  58818. * @param onFailure defines a callback to call on failure
  58819. * @returns the new SceneOptimizer object
  58820. */
  58821. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58822. }
  58823. }
  58824. declare module "babylonjs/Misc/sceneSerializer" {
  58825. import { Scene } from "babylonjs/scene";
  58826. /**
  58827. * Class used to serialize a scene into a string
  58828. */
  58829. export class SceneSerializer {
  58830. /**
  58831. * Clear cache used by a previous serialization
  58832. */
  58833. static ClearCache(): void;
  58834. /**
  58835. * Serialize a scene into a JSON compatible object
  58836. * @param scene defines the scene to serialize
  58837. * @returns a JSON compatible object
  58838. */
  58839. static Serialize(scene: Scene): any;
  58840. /**
  58841. * Serialize a mesh into a JSON compatible object
  58842. * @param toSerialize defines the mesh to serialize
  58843. * @param withParents defines if parents must be serialized as well
  58844. * @param withChildren defines if children must be serialized as well
  58845. * @returns a JSON compatible object
  58846. */
  58847. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58848. }
  58849. }
  58850. declare module "babylonjs/Misc/textureTools" {
  58851. import { Texture } from "babylonjs/Materials/Textures/texture";
  58852. /**
  58853. * Class used to host texture specific utilities
  58854. */
  58855. export class TextureTools {
  58856. /**
  58857. * Uses the GPU to create a copy texture rescaled at a given size
  58858. * @param texture Texture to copy from
  58859. * @param width defines the desired width
  58860. * @param height defines the desired height
  58861. * @param useBilinearMode defines if bilinear mode has to be used
  58862. * @return the generated texture
  58863. */
  58864. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58865. }
  58866. }
  58867. declare module "babylonjs/Misc/videoRecorder" {
  58868. import { Nullable } from "babylonjs/types";
  58869. import { Engine } from "babylonjs/Engines/engine";
  58870. /**
  58871. * This represents the different options avilable for the video capture.
  58872. */
  58873. export interface VideoRecorderOptions {
  58874. /** Defines the mime type of the video */
  58875. mimeType: string;
  58876. /** Defines the video the video should be recorded at */
  58877. fps: number;
  58878. /** Defines the chunk size for the recording data */
  58879. recordChunckSize: number;
  58880. /** The audio tracks to attach to the record */
  58881. audioTracks?: MediaStreamTrack[];
  58882. }
  58883. /**
  58884. * This can helps recording videos from BabylonJS.
  58885. * This is based on the available WebRTC functionalities of the browser.
  58886. *
  58887. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58888. */
  58889. export class VideoRecorder {
  58890. private static readonly _defaultOptions;
  58891. /**
  58892. * Returns wehther or not the VideoRecorder is available in your browser.
  58893. * @param engine Defines the Babylon Engine to check the support for
  58894. * @returns true if supported otherwise false
  58895. */
  58896. static IsSupported(engine: Engine): boolean;
  58897. private readonly _options;
  58898. private _canvas;
  58899. private _mediaRecorder;
  58900. private _recordedChunks;
  58901. private _fileName;
  58902. private _resolve;
  58903. private _reject;
  58904. /**
  58905. * True wether a recording is already in progress.
  58906. */
  58907. readonly isRecording: boolean;
  58908. /**
  58909. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58910. * a video file.
  58911. * @param engine Defines the BabylonJS Engine you wish to record
  58912. * @param options Defines options that can be used to customized the capture
  58913. */
  58914. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58915. /**
  58916. * Stops the current recording before the default capture timeout passed in the startRecording
  58917. * functions.
  58918. */
  58919. stopRecording(): void;
  58920. /**
  58921. * Starts recording the canvas for a max duration specified in parameters.
  58922. * @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.
  58923. * @param maxDuration Defines the maximum recording time in seconds.
  58924. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58925. * @return a promise callback at the end of the recording with the video data in Blob.
  58926. */
  58927. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58928. /**
  58929. * Releases internal resources used during the recording.
  58930. */
  58931. dispose(): void;
  58932. private _handleDataAvailable;
  58933. private _handleError;
  58934. private _handleStop;
  58935. }
  58936. }
  58937. declare module "babylonjs/Misc/screenshotTools" {
  58938. import { Camera } from "babylonjs/Cameras/camera";
  58939. import { Engine } from "babylonjs/Engines/engine";
  58940. /**
  58941. * Class containing a set of static utilities functions for screenshots
  58942. */
  58943. export class ScreenshotTools {
  58944. /**
  58945. * Captures a screenshot of the current rendering
  58946. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58947. * @param engine defines the rendering engine
  58948. * @param camera defines the source camera
  58949. * @param size This parameter can be set to a single number or to an object with the
  58950. * following (optional) properties: precision, width, height. If a single number is passed,
  58951. * it will be used for both width and height. If an object is passed, the screenshot size
  58952. * will be derived from the parameters. The precision property is a multiplier allowing
  58953. * rendering at a higher or lower resolution
  58954. * @param successCallback defines the callback receives a single parameter which contains the
  58955. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58956. * src parameter of an <img> to display it
  58957. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58958. * Check your browser for supported MIME types
  58959. */
  58960. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58961. /**
  58962. * Generates an image screenshot from the specified camera.
  58963. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58964. * @param engine The engine to use for rendering
  58965. * @param camera The camera to use for rendering
  58966. * @param size This parameter can be set to a single number or to an object with the
  58967. * following (optional) properties: precision, width, height. If a single number is passed,
  58968. * it will be used for both width and height. If an object is passed, the screenshot size
  58969. * will be derived from the parameters. The precision property is a multiplier allowing
  58970. * rendering at a higher or lower resolution
  58971. * @param successCallback The callback receives a single parameter which contains the
  58972. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58973. * src parameter of an <img> to display it
  58974. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58975. * Check your browser for supported MIME types
  58976. * @param samples Texture samples (default: 1)
  58977. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58978. * @param fileName A name for for the downloaded file.
  58979. */
  58980. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58981. }
  58982. }
  58983. declare module "babylonjs/Misc/index" {
  58984. export * from "babylonjs/Misc/andOrNotEvaluator";
  58985. export * from "babylonjs/Misc/assetsManager";
  58986. export * from "babylonjs/Misc/dds";
  58987. export * from "babylonjs/Misc/decorators";
  58988. export * from "babylonjs/Misc/deferred";
  58989. export * from "babylonjs/Misc/environmentTextureTools";
  58990. export * from "babylonjs/Misc/meshExploder";
  58991. export * from "babylonjs/Misc/filesInput";
  58992. export * from "babylonjs/Misc/HighDynamicRange/index";
  58993. export * from "babylonjs/Misc/khronosTextureContainer";
  58994. export * from "babylonjs/Misc/observable";
  58995. export * from "babylonjs/Misc/performanceMonitor";
  58996. export * from "babylonjs/Misc/promise";
  58997. export * from "babylonjs/Misc/sceneOptimizer";
  58998. export * from "babylonjs/Misc/sceneSerializer";
  58999. export * from "babylonjs/Misc/smartArray";
  59000. export * from "babylonjs/Misc/stringDictionary";
  59001. export * from "babylonjs/Misc/tags";
  59002. export * from "babylonjs/Misc/textureTools";
  59003. export * from "babylonjs/Misc/tga";
  59004. export * from "babylonjs/Misc/tools";
  59005. export * from "babylonjs/Misc/videoRecorder";
  59006. export * from "babylonjs/Misc/virtualJoystick";
  59007. export * from "babylonjs/Misc/workerPool";
  59008. export * from "babylonjs/Misc/logger";
  59009. export * from "babylonjs/Misc/typeStore";
  59010. export * from "babylonjs/Misc/filesInputStore";
  59011. export * from "babylonjs/Misc/deepCopier";
  59012. export * from "babylonjs/Misc/pivotTools";
  59013. export * from "babylonjs/Misc/precisionDate";
  59014. export * from "babylonjs/Misc/screenshotTools";
  59015. export * from "babylonjs/Misc/typeStore";
  59016. export * from "babylonjs/Misc/webRequest";
  59017. export * from "babylonjs/Misc/iInspectable";
  59018. }
  59019. declare module "babylonjs/index" {
  59020. export * from "babylonjs/abstractScene";
  59021. export * from "babylonjs/Actions/index";
  59022. export * from "babylonjs/Animations/index";
  59023. export * from "babylonjs/assetContainer";
  59024. export * from "babylonjs/Audio/index";
  59025. export * from "babylonjs/Behaviors/index";
  59026. export * from "babylonjs/Bones/index";
  59027. export * from "babylonjs/Cameras/index";
  59028. export * from "babylonjs/Collisions/index";
  59029. export * from "babylonjs/Culling/index";
  59030. export * from "babylonjs/Debug/index";
  59031. export * from "babylonjs/Engines/index";
  59032. export * from "babylonjs/Events/index";
  59033. export * from "babylonjs/Gamepads/index";
  59034. export * from "babylonjs/Gizmos/index";
  59035. export * from "babylonjs/Helpers/index";
  59036. export * from "babylonjs/Instrumentation/index";
  59037. export * from "babylonjs/Layers/index";
  59038. export * from "babylonjs/LensFlares/index";
  59039. export * from "babylonjs/Lights/index";
  59040. export * from "babylonjs/Loading/index";
  59041. export * from "babylonjs/Materials/index";
  59042. export * from "babylonjs/Maths/index";
  59043. export * from "babylonjs/Meshes/index";
  59044. export * from "babylonjs/Morph/index";
  59045. export * from "babylonjs/node";
  59046. export * from "babylonjs/Offline/index";
  59047. export * from "babylonjs/Particles/index";
  59048. export * from "babylonjs/Physics/index";
  59049. export * from "babylonjs/PostProcesses/index";
  59050. export * from "babylonjs/Probes/index";
  59051. export * from "babylonjs/Rendering/index";
  59052. export * from "babylonjs/scene";
  59053. export * from "babylonjs/sceneComponent";
  59054. export * from "babylonjs/Sprites/index";
  59055. export * from "babylonjs/States/index";
  59056. export * from "babylonjs/Misc/index";
  59057. export * from "babylonjs/types";
  59058. }
  59059. declare module "babylonjs/Animations/pathCursor" {
  59060. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59061. /**
  59062. * A cursor which tracks a point on a path
  59063. */
  59064. export class PathCursor {
  59065. private path;
  59066. /**
  59067. * Stores path cursor callbacks for when an onchange event is triggered
  59068. */
  59069. private _onchange;
  59070. /**
  59071. * The value of the path cursor
  59072. */
  59073. value: number;
  59074. /**
  59075. * The animation array of the path cursor
  59076. */
  59077. animations: Animation[];
  59078. /**
  59079. * Initializes the path cursor
  59080. * @param path The path to track
  59081. */
  59082. constructor(path: Path2);
  59083. /**
  59084. * Gets the cursor point on the path
  59085. * @returns A point on the path cursor at the cursor location
  59086. */
  59087. getPoint(): Vector3;
  59088. /**
  59089. * Moves the cursor ahead by the step amount
  59090. * @param step The amount to move the cursor forward
  59091. * @returns This path cursor
  59092. */
  59093. moveAhead(step?: number): PathCursor;
  59094. /**
  59095. * Moves the cursor behind by the step amount
  59096. * @param step The amount to move the cursor back
  59097. * @returns This path cursor
  59098. */
  59099. moveBack(step?: number): PathCursor;
  59100. /**
  59101. * Moves the cursor by the step amount
  59102. * If the step amount is greater than one, an exception is thrown
  59103. * @param step The amount to move the cursor
  59104. * @returns This path cursor
  59105. */
  59106. move(step: number): PathCursor;
  59107. /**
  59108. * Ensures that the value is limited between zero and one
  59109. * @returns This path cursor
  59110. */
  59111. private ensureLimits;
  59112. /**
  59113. * Runs onchange callbacks on change (used by the animation engine)
  59114. * @returns This path cursor
  59115. */
  59116. private raiseOnChange;
  59117. /**
  59118. * Executes a function on change
  59119. * @param f A path cursor onchange callback
  59120. * @returns This path cursor
  59121. */
  59122. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59123. }
  59124. }
  59125. declare module "babylonjs/Legacy/legacy" {
  59126. import * as Babylon from "babylonjs/index";
  59127. export * from "babylonjs/index";
  59128. }
  59129. declare module "babylonjs/Shaders/blur.fragment" {
  59130. /** @hidden */
  59131. export var blurPixelShader: {
  59132. name: string;
  59133. shader: string;
  59134. };
  59135. }
  59136. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59137. /** @hidden */
  59138. export var bones300Declaration: {
  59139. name: string;
  59140. shader: string;
  59141. };
  59142. }
  59143. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59144. /** @hidden */
  59145. export var instances300Declaration: {
  59146. name: string;
  59147. shader: string;
  59148. };
  59149. }
  59150. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59151. /** @hidden */
  59152. export var pointCloudVertexDeclaration: {
  59153. name: string;
  59154. shader: string;
  59155. };
  59156. }
  59157. // Mixins
  59158. interface Window {
  59159. mozIndexedDB: IDBFactory;
  59160. webkitIndexedDB: IDBFactory;
  59161. msIndexedDB: IDBFactory;
  59162. webkitURL: typeof URL;
  59163. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59164. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59165. WebGLRenderingContext: WebGLRenderingContext;
  59166. MSGesture: MSGesture;
  59167. CANNON: any;
  59168. AudioContext: AudioContext;
  59169. webkitAudioContext: AudioContext;
  59170. PointerEvent: any;
  59171. Math: Math;
  59172. Uint8Array: Uint8ArrayConstructor;
  59173. Float32Array: Float32ArrayConstructor;
  59174. mozURL: typeof URL;
  59175. msURL: typeof URL;
  59176. VRFrameData: any; // WebVR, from specs 1.1
  59177. DracoDecoderModule: any;
  59178. setImmediate(handler: (...args: any[]) => void): number;
  59179. }
  59180. interface HTMLCanvasElement {
  59181. requestPointerLock(): void;
  59182. msRequestPointerLock?(): void;
  59183. mozRequestPointerLock?(): void;
  59184. webkitRequestPointerLock?(): void;
  59185. /** Track wether a record is in progress */
  59186. isRecording: boolean;
  59187. /** Capture Stream method defined by some browsers */
  59188. captureStream(fps?: number): MediaStream;
  59189. }
  59190. interface CanvasRenderingContext2D {
  59191. msImageSmoothingEnabled: boolean;
  59192. }
  59193. interface MouseEvent {
  59194. mozMovementX: number;
  59195. mozMovementY: number;
  59196. webkitMovementX: number;
  59197. webkitMovementY: number;
  59198. msMovementX: number;
  59199. msMovementY: number;
  59200. }
  59201. interface Navigator {
  59202. mozGetVRDevices: (any: any) => any;
  59203. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59204. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59205. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59206. webkitGetGamepads(): Gamepad[];
  59207. msGetGamepads(): Gamepad[];
  59208. webkitGamepads(): Gamepad[];
  59209. }
  59210. interface HTMLVideoElement {
  59211. mozSrcObject: any;
  59212. }
  59213. interface Math {
  59214. fround(x: number): number;
  59215. imul(a: number, b: number): number;
  59216. }
  59217. interface WebGLProgram {
  59218. context?: WebGLRenderingContext;
  59219. vertexShader?: WebGLShader;
  59220. fragmentShader?: WebGLShader;
  59221. isParallelCompiled: boolean;
  59222. onCompiled?: () => void;
  59223. }
  59224. interface WebGLRenderingContext {
  59225. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59226. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59227. vertexAttribDivisor(index: number, divisor: number): void;
  59228. createVertexArray(): any;
  59229. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59230. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59231. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59232. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59233. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59234. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59235. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59236. // Queries
  59237. createQuery(): WebGLQuery;
  59238. deleteQuery(query: WebGLQuery): void;
  59239. beginQuery(target: number, query: WebGLQuery): void;
  59240. endQuery(target: number): void;
  59241. getQueryParameter(query: WebGLQuery, pname: number): any;
  59242. getQuery(target: number, pname: number): any;
  59243. MAX_SAMPLES: number;
  59244. RGBA8: number;
  59245. READ_FRAMEBUFFER: number;
  59246. DRAW_FRAMEBUFFER: number;
  59247. UNIFORM_BUFFER: number;
  59248. HALF_FLOAT_OES: number;
  59249. RGBA16F: number;
  59250. RGBA32F: number;
  59251. R32F: number;
  59252. RG32F: number;
  59253. RGB32F: number;
  59254. R16F: number;
  59255. RG16F: number;
  59256. RGB16F: number;
  59257. RED: number;
  59258. RG: number;
  59259. R8: number;
  59260. RG8: number;
  59261. UNSIGNED_INT_24_8: number;
  59262. DEPTH24_STENCIL8: number;
  59263. /* Multiple Render Targets */
  59264. drawBuffers(buffers: number[]): void;
  59265. readBuffer(src: number): void;
  59266. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59267. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59268. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59269. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59270. // Occlusion Query
  59271. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59272. ANY_SAMPLES_PASSED: number;
  59273. QUERY_RESULT_AVAILABLE: number;
  59274. QUERY_RESULT: number;
  59275. }
  59276. interface WebGLBuffer {
  59277. references: number;
  59278. capacity: number;
  59279. is32Bits: boolean;
  59280. }
  59281. interface WebGLProgram {
  59282. transformFeedback?: WebGLTransformFeedback | null;
  59283. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59284. }
  59285. interface EXT_disjoint_timer_query {
  59286. QUERY_COUNTER_BITS_EXT: number;
  59287. TIME_ELAPSED_EXT: number;
  59288. TIMESTAMP_EXT: number;
  59289. GPU_DISJOINT_EXT: number;
  59290. QUERY_RESULT_EXT: number;
  59291. QUERY_RESULT_AVAILABLE_EXT: number;
  59292. queryCounterEXT(query: WebGLQuery, target: number): void;
  59293. createQueryEXT(): WebGLQuery;
  59294. beginQueryEXT(target: number, query: WebGLQuery): void;
  59295. endQueryEXT(target: number): void;
  59296. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59297. deleteQueryEXT(query: WebGLQuery): void;
  59298. }
  59299. interface WebGLUniformLocation {
  59300. _currentState: any;
  59301. }
  59302. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59303. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59304. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59305. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59306. interface WebGLRenderingContext {
  59307. readonly RASTERIZER_DISCARD: number;
  59308. readonly DEPTH_COMPONENT24: number;
  59309. readonly TEXTURE_3D: number;
  59310. readonly TEXTURE_2D_ARRAY: number;
  59311. readonly TEXTURE_COMPARE_FUNC: number;
  59312. readonly TEXTURE_COMPARE_MODE: number;
  59313. readonly COMPARE_REF_TO_TEXTURE: number;
  59314. readonly TEXTURE_WRAP_R: number;
  59315. readonly HALF_FLOAT: number;
  59316. readonly RGB8: number;
  59317. readonly RED_INTEGER: number;
  59318. readonly RG_INTEGER: number;
  59319. readonly RGB_INTEGER: number;
  59320. readonly RGBA_INTEGER: number;
  59321. readonly R8_SNORM: number;
  59322. readonly RG8_SNORM: number;
  59323. readonly RGB8_SNORM: number;
  59324. readonly RGBA8_SNORM: number;
  59325. readonly R8I: number;
  59326. readonly RG8I: number;
  59327. readonly RGB8I: number;
  59328. readonly RGBA8I: number;
  59329. readonly R8UI: number;
  59330. readonly RG8UI: number;
  59331. readonly RGB8UI: number;
  59332. readonly RGBA8UI: number;
  59333. readonly R16I: number;
  59334. readonly RG16I: number;
  59335. readonly RGB16I: number;
  59336. readonly RGBA16I: number;
  59337. readonly R16UI: number;
  59338. readonly RG16UI: number;
  59339. readonly RGB16UI: number;
  59340. readonly RGBA16UI: number;
  59341. readonly R32I: number;
  59342. readonly RG32I: number;
  59343. readonly RGB32I: number;
  59344. readonly RGBA32I: number;
  59345. readonly R32UI: number;
  59346. readonly RG32UI: number;
  59347. readonly RGB32UI: number;
  59348. readonly RGBA32UI: number;
  59349. readonly RGB10_A2UI: number;
  59350. readonly R11F_G11F_B10F: number;
  59351. readonly RGB9_E5: number;
  59352. readonly RGB10_A2: number;
  59353. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59354. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59355. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59356. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59357. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59358. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59359. 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;
  59360. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59361. readonly TRANSFORM_FEEDBACK: number;
  59362. readonly INTERLEAVED_ATTRIBS: number;
  59363. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59364. createTransformFeedback(): WebGLTransformFeedback;
  59365. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59366. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59367. beginTransformFeedback(primitiveMode: number): void;
  59368. endTransformFeedback(): void;
  59369. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59370. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59371. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59372. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59373. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59374. }
  59375. interface ImageBitmap {
  59376. readonly width: number;
  59377. readonly height: number;
  59378. close(): void;
  59379. }
  59380. interface WebGLQuery extends WebGLObject {
  59381. }
  59382. declare var WebGLQuery: {
  59383. prototype: WebGLQuery;
  59384. new(): WebGLQuery;
  59385. };
  59386. interface WebGLSampler extends WebGLObject {
  59387. }
  59388. declare var WebGLSampler: {
  59389. prototype: WebGLSampler;
  59390. new(): WebGLSampler;
  59391. };
  59392. interface WebGLSync extends WebGLObject {
  59393. }
  59394. declare var WebGLSync: {
  59395. prototype: WebGLSync;
  59396. new(): WebGLSync;
  59397. };
  59398. interface WebGLTransformFeedback extends WebGLObject {
  59399. }
  59400. declare var WebGLTransformFeedback: {
  59401. prototype: WebGLTransformFeedback;
  59402. new(): WebGLTransformFeedback;
  59403. };
  59404. interface WebGLVertexArrayObject extends WebGLObject {
  59405. }
  59406. declare var WebGLVertexArrayObject: {
  59407. prototype: WebGLVertexArrayObject;
  59408. new(): WebGLVertexArrayObject;
  59409. };
  59410. // Type definitions for WebVR API
  59411. // Project: https://w3c.github.io/webvr/
  59412. // Definitions by: six a <https://github.com/lostfictions>
  59413. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59414. interface VRDisplay extends EventTarget {
  59415. /**
  59416. * Dictionary of capabilities describing the VRDisplay.
  59417. */
  59418. readonly capabilities: VRDisplayCapabilities;
  59419. /**
  59420. * z-depth defining the far plane of the eye view frustum
  59421. * enables mapping of values in the render target depth
  59422. * attachment to scene coordinates. Initially set to 10000.0.
  59423. */
  59424. depthFar: number;
  59425. /**
  59426. * z-depth defining the near plane of the eye view frustum
  59427. * enables mapping of values in the render target depth
  59428. * attachment to scene coordinates. Initially set to 0.01.
  59429. */
  59430. depthNear: number;
  59431. /**
  59432. * An identifier for this distinct VRDisplay. Used as an
  59433. * association point in the Gamepad API.
  59434. */
  59435. readonly displayId: number;
  59436. /**
  59437. * A display name, a user-readable name identifying it.
  59438. */
  59439. readonly displayName: string;
  59440. readonly isConnected: boolean;
  59441. readonly isPresenting: boolean;
  59442. /**
  59443. * If this VRDisplay supports room-scale experiences, the optional
  59444. * stage attribute contains details on the room-scale parameters.
  59445. */
  59446. readonly stageParameters: VRStageParameters | null;
  59447. /**
  59448. * Passing the value returned by `requestAnimationFrame` to
  59449. * `cancelAnimationFrame` will unregister the callback.
  59450. * @param handle Define the hanle of the request to cancel
  59451. */
  59452. cancelAnimationFrame(handle: number): void;
  59453. /**
  59454. * Stops presenting to the VRDisplay.
  59455. * @returns a promise to know when it stopped
  59456. */
  59457. exitPresent(): Promise<void>;
  59458. /**
  59459. * Return the current VREyeParameters for the given eye.
  59460. * @param whichEye Define the eye we want the parameter for
  59461. * @returns the eye parameters
  59462. */
  59463. getEyeParameters(whichEye: string): VREyeParameters;
  59464. /**
  59465. * Populates the passed VRFrameData with the information required to render
  59466. * the current frame.
  59467. * @param frameData Define the data structure to populate
  59468. * @returns true if ok otherwise false
  59469. */
  59470. getFrameData(frameData: VRFrameData): boolean;
  59471. /**
  59472. * Get the layers currently being presented.
  59473. * @returns the list of VR layers
  59474. */
  59475. getLayers(): VRLayer[];
  59476. /**
  59477. * Return a VRPose containing the future predicted pose of the VRDisplay
  59478. * when the current frame will be presented. The value returned will not
  59479. * change until JavaScript has returned control to the browser.
  59480. *
  59481. * The VRPose will contain the position, orientation, velocity,
  59482. * and acceleration of each of these properties.
  59483. * @returns the pose object
  59484. */
  59485. getPose(): VRPose;
  59486. /**
  59487. * Return the current instantaneous pose of the VRDisplay, with no
  59488. * prediction applied.
  59489. * @returns the current instantaneous pose
  59490. */
  59491. getImmediatePose(): VRPose;
  59492. /**
  59493. * The callback passed to `requestAnimationFrame` will be called
  59494. * any time a new frame should be rendered. When the VRDisplay is
  59495. * presenting the callback will be called at the native refresh
  59496. * rate of the HMD. When not presenting this function acts
  59497. * identically to how window.requestAnimationFrame acts. Content should
  59498. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59499. * asynchronously from other displays and at differing refresh rates.
  59500. * @param callback Define the eaction to run next frame
  59501. * @returns the request handle it
  59502. */
  59503. requestAnimationFrame(callback: FrameRequestCallback): number;
  59504. /**
  59505. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59506. * Repeat calls while already presenting will update the VRLayers being displayed.
  59507. * @param layers Define the list of layer to present
  59508. * @returns a promise to know when the request has been fulfilled
  59509. */
  59510. requestPresent(layers: VRLayer[]): Promise<void>;
  59511. /**
  59512. * Reset the pose for this display, treating its current position and
  59513. * orientation as the "origin/zero" values. VRPose.position,
  59514. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59515. * updated when calling resetPose(). This should be called in only
  59516. * sitting-space experiences.
  59517. */
  59518. resetPose(): void;
  59519. /**
  59520. * The VRLayer provided to the VRDisplay will be captured and presented
  59521. * in the HMD. Calling this function has the same effect on the source
  59522. * canvas as any other operation that uses its source image, and canvases
  59523. * created without preserveDrawingBuffer set to true will be cleared.
  59524. * @param pose Define the pose to submit
  59525. */
  59526. submitFrame(pose?: VRPose): void;
  59527. }
  59528. declare var VRDisplay: {
  59529. prototype: VRDisplay;
  59530. new(): VRDisplay;
  59531. };
  59532. interface VRLayer {
  59533. leftBounds?: number[] | Float32Array | null;
  59534. rightBounds?: number[] | Float32Array | null;
  59535. source?: HTMLCanvasElement | null;
  59536. }
  59537. interface VRDisplayCapabilities {
  59538. readonly canPresent: boolean;
  59539. readonly hasExternalDisplay: boolean;
  59540. readonly hasOrientation: boolean;
  59541. readonly hasPosition: boolean;
  59542. readonly maxLayers: number;
  59543. }
  59544. interface VREyeParameters {
  59545. /** @deprecated */
  59546. readonly fieldOfView: VRFieldOfView;
  59547. readonly offset: Float32Array;
  59548. readonly renderHeight: number;
  59549. readonly renderWidth: number;
  59550. }
  59551. interface VRFieldOfView {
  59552. readonly downDegrees: number;
  59553. readonly leftDegrees: number;
  59554. readonly rightDegrees: number;
  59555. readonly upDegrees: number;
  59556. }
  59557. interface VRFrameData {
  59558. readonly leftProjectionMatrix: Float32Array;
  59559. readonly leftViewMatrix: Float32Array;
  59560. readonly pose: VRPose;
  59561. readonly rightProjectionMatrix: Float32Array;
  59562. readonly rightViewMatrix: Float32Array;
  59563. readonly timestamp: number;
  59564. }
  59565. interface VRPose {
  59566. readonly angularAcceleration: Float32Array | null;
  59567. readonly angularVelocity: Float32Array | null;
  59568. readonly linearAcceleration: Float32Array | null;
  59569. readonly linearVelocity: Float32Array | null;
  59570. readonly orientation: Float32Array | null;
  59571. readonly position: Float32Array | null;
  59572. readonly timestamp: number;
  59573. }
  59574. interface VRStageParameters {
  59575. sittingToStandingTransform?: Float32Array;
  59576. sizeX?: number;
  59577. sizeY?: number;
  59578. }
  59579. interface Navigator {
  59580. getVRDisplays(): Promise<VRDisplay[]>;
  59581. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59582. }
  59583. interface Window {
  59584. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59585. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59586. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59587. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59588. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59589. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59590. }
  59591. interface Gamepad {
  59592. readonly displayId: number;
  59593. }
  59594. interface XRDevice {
  59595. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59596. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59597. }
  59598. interface XRSession {
  59599. getInputSources(): Array<any>;
  59600. baseLayer: XRWebGLLayer;
  59601. requestFrameOfReference(type: string): Promise<void>;
  59602. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59603. end(): Promise<void>;
  59604. requestAnimationFrame: Function;
  59605. addEventListener: Function;
  59606. }
  59607. interface XRSessionCreationOptions {
  59608. outputContext?: WebGLRenderingContext | null;
  59609. immersive?: boolean;
  59610. environmentIntegration?: boolean;
  59611. }
  59612. interface XRLayer {
  59613. getViewport: Function;
  59614. framebufferWidth: number;
  59615. framebufferHeight: number;
  59616. }
  59617. interface XRView {
  59618. projectionMatrix: Float32Array;
  59619. }
  59620. interface XRFrame {
  59621. getDevicePose: Function;
  59622. getInputPose: Function;
  59623. views: Array<XRView>;
  59624. baseLayer: XRLayer;
  59625. }
  59626. interface XRFrameOfReference {
  59627. }
  59628. interface XRWebGLLayer extends XRLayer {
  59629. framebuffer: WebGLFramebuffer;
  59630. }
  59631. declare var XRWebGLLayer: {
  59632. prototype: XRWebGLLayer;
  59633. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59634. };
  59635. declare module "babylonjs" {
  59636. export * from "babylonjs/Legacy/legacy";
  59637. }
  59638. declare module BABYLON {
  59639. /** Alias type for value that can be null */
  59640. export type Nullable<T> = T | null;
  59641. /**
  59642. * Alias type for number that are floats
  59643. * @ignorenaming
  59644. */
  59645. export type float = number;
  59646. /**
  59647. * Alias type for number that are doubles.
  59648. * @ignorenaming
  59649. */
  59650. export type double = number;
  59651. /**
  59652. * Alias type for number that are integer
  59653. * @ignorenaming
  59654. */
  59655. export type int = number;
  59656. /** Alias type for number array or Float32Array */
  59657. export type FloatArray = number[] | Float32Array;
  59658. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59659. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59660. /**
  59661. * Alias for types that can be used by a Buffer or VertexBuffer.
  59662. */
  59663. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59664. /**
  59665. * Alias type for primitive types
  59666. * @ignorenaming
  59667. */
  59668. type Primitive = undefined | null | boolean | string | number | Function;
  59669. /**
  59670. * Type modifier to make all the properties of an object Readonly
  59671. */
  59672. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59673. /**
  59674. * Type modifier to make all the properties of an object Readonly recursively
  59675. */
  59676. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59677. /** @hidden */
  59678. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59679. }
  59680. /** @hidden */
  59681. /** @hidden */
  59682. type DeepImmutableObject<T> = {
  59683. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59684. };
  59685. }
  59686. declare module BABYLON {
  59687. /**
  59688. * Class containing a set of static utilities functions for arrays.
  59689. */
  59690. export class ArrayTools {
  59691. /**
  59692. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59693. * @param size the number of element to construct and put in the array
  59694. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59695. * @returns a new array filled with new objects
  59696. */
  59697. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59698. }
  59699. }
  59700. declare module BABYLON {
  59701. /**
  59702. * Scalar computation library
  59703. */
  59704. export class Scalar {
  59705. /**
  59706. * Two pi constants convenient for computation.
  59707. */
  59708. static TwoPi: number;
  59709. /**
  59710. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59711. * @param a number
  59712. * @param b number
  59713. * @param epsilon (default = 1.401298E-45)
  59714. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59715. */
  59716. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59717. /**
  59718. * Returns a string : the upper case translation of the number i to hexadecimal.
  59719. * @param i number
  59720. * @returns the upper case translation of the number i to hexadecimal.
  59721. */
  59722. static ToHex(i: number): string;
  59723. /**
  59724. * Returns -1 if value is negative and +1 is value is positive.
  59725. * @param value the value
  59726. * @returns the value itself if it's equal to zero.
  59727. */
  59728. static Sign(value: number): number;
  59729. /**
  59730. * Returns the value itself if it's between min and max.
  59731. * Returns min if the value is lower than min.
  59732. * Returns max if the value is greater than max.
  59733. * @param value the value to clmap
  59734. * @param min the min value to clamp to (default: 0)
  59735. * @param max the max value to clamp to (default: 1)
  59736. * @returns the clamped value
  59737. */
  59738. static Clamp(value: number, min?: number, max?: number): number;
  59739. /**
  59740. * the log2 of value.
  59741. * @param value the value to compute log2 of
  59742. * @returns the log2 of value.
  59743. */
  59744. static Log2(value: number): number;
  59745. /**
  59746. * Loops the value, so that it is never larger than length and never smaller than 0.
  59747. *
  59748. * This is similar to the modulo operator but it works with floating point numbers.
  59749. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59750. * With t = 5 and length = 2.5, the result would be 0.0.
  59751. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59752. * @param value the value
  59753. * @param length the length
  59754. * @returns the looped value
  59755. */
  59756. static Repeat(value: number, length: number): number;
  59757. /**
  59758. * Normalize the value between 0.0 and 1.0 using min and max values
  59759. * @param value value to normalize
  59760. * @param min max to normalize between
  59761. * @param max min to normalize between
  59762. * @returns the normalized value
  59763. */
  59764. static Normalize(value: number, min: number, max: number): number;
  59765. /**
  59766. * Denormalize the value from 0.0 and 1.0 using min and max values
  59767. * @param normalized value to denormalize
  59768. * @param min max to denormalize between
  59769. * @param max min to denormalize between
  59770. * @returns the denormalized value
  59771. */
  59772. static Denormalize(normalized: number, min: number, max: number): number;
  59773. /**
  59774. * Calculates the shortest difference between two given angles given in degrees.
  59775. * @param current current angle in degrees
  59776. * @param target target angle in degrees
  59777. * @returns the delta
  59778. */
  59779. static DeltaAngle(current: number, target: number): number;
  59780. /**
  59781. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59782. * @param tx value
  59783. * @param length length
  59784. * @returns The returned value will move back and forth between 0 and length
  59785. */
  59786. static PingPong(tx: number, length: number): number;
  59787. /**
  59788. * Interpolates between min and max with smoothing at the limits.
  59789. *
  59790. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59791. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59792. * @param from from
  59793. * @param to to
  59794. * @param tx value
  59795. * @returns the smooth stepped value
  59796. */
  59797. static SmoothStep(from: number, to: number, tx: number): number;
  59798. /**
  59799. * Moves a value current towards target.
  59800. *
  59801. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59802. * Negative values of maxDelta pushes the value away from target.
  59803. * @param current current value
  59804. * @param target target value
  59805. * @param maxDelta max distance to move
  59806. * @returns resulting value
  59807. */
  59808. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59809. /**
  59810. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59811. *
  59812. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59813. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59814. * @param current current value
  59815. * @param target target value
  59816. * @param maxDelta max distance to move
  59817. * @returns resulting angle
  59818. */
  59819. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59820. /**
  59821. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59822. * @param start start value
  59823. * @param end target value
  59824. * @param amount amount to lerp between
  59825. * @returns the lerped value
  59826. */
  59827. static Lerp(start: number, end: number, amount: number): number;
  59828. /**
  59829. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59830. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59831. * @param start start value
  59832. * @param end target value
  59833. * @param amount amount to lerp between
  59834. * @returns the lerped value
  59835. */
  59836. static LerpAngle(start: number, end: number, amount: number): number;
  59837. /**
  59838. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59839. * @param a start value
  59840. * @param b target value
  59841. * @param value value between a and b
  59842. * @returns the inverseLerp value
  59843. */
  59844. static InverseLerp(a: number, b: number, value: number): number;
  59845. /**
  59846. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59847. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59848. * @param value1 spline value
  59849. * @param tangent1 spline value
  59850. * @param value2 spline value
  59851. * @param tangent2 spline value
  59852. * @param amount input value
  59853. * @returns hermite result
  59854. */
  59855. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59856. /**
  59857. * Returns a random float number between and min and max values
  59858. * @param min min value of random
  59859. * @param max max value of random
  59860. * @returns random value
  59861. */
  59862. static RandomRange(min: number, max: number): number;
  59863. /**
  59864. * This function returns percentage of a number in a given range.
  59865. *
  59866. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59867. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59868. * @param number to convert to percentage
  59869. * @param min min range
  59870. * @param max max range
  59871. * @returns the percentage
  59872. */
  59873. static RangeToPercent(number: number, min: number, max: number): number;
  59874. /**
  59875. * This function returns number that corresponds to the percentage in a given range.
  59876. *
  59877. * PercentToRange(0.34,0,100) will return 34.
  59878. * @param percent to convert to number
  59879. * @param min min range
  59880. * @param max max range
  59881. * @returns the number
  59882. */
  59883. static PercentToRange(percent: number, min: number, max: number): number;
  59884. /**
  59885. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59886. * @param angle The angle to normalize in radian.
  59887. * @return The converted angle.
  59888. */
  59889. static NormalizeRadians(angle: number): number;
  59890. }
  59891. }
  59892. declare module BABYLON {
  59893. /**
  59894. * Constant used to convert a value to gamma space
  59895. * @ignorenaming
  59896. */
  59897. export const ToGammaSpace: number;
  59898. /**
  59899. * Constant used to convert a value to linear space
  59900. * @ignorenaming
  59901. */
  59902. export const ToLinearSpace = 2.2;
  59903. /**
  59904. * Constant used to define the minimal number value in Babylon.js
  59905. * @ignorenaming
  59906. */
  59907. let Epsilon: number;
  59908. /**
  59909. * Class used to hold a RBG color
  59910. */
  59911. export class Color3 {
  59912. /**
  59913. * Defines the red component (between 0 and 1, default is 0)
  59914. */
  59915. r: number;
  59916. /**
  59917. * Defines the green component (between 0 and 1, default is 0)
  59918. */
  59919. g: number;
  59920. /**
  59921. * Defines the blue component (between 0 and 1, default is 0)
  59922. */
  59923. b: number;
  59924. /**
  59925. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  59926. * @param r defines the red component (between 0 and 1, default is 0)
  59927. * @param g defines the green component (between 0 and 1, default is 0)
  59928. * @param b defines the blue component (between 0 and 1, default is 0)
  59929. */
  59930. constructor(
  59931. /**
  59932. * Defines the red component (between 0 and 1, default is 0)
  59933. */
  59934. r?: number,
  59935. /**
  59936. * Defines the green component (between 0 and 1, default is 0)
  59937. */
  59938. g?: number,
  59939. /**
  59940. * Defines the blue component (between 0 and 1, default is 0)
  59941. */
  59942. b?: number);
  59943. /**
  59944. * Creates a string with the Color3 current values
  59945. * @returns the string representation of the Color3 object
  59946. */
  59947. toString(): string;
  59948. /**
  59949. * Returns the string "Color3"
  59950. * @returns "Color3"
  59951. */
  59952. getClassName(): string;
  59953. /**
  59954. * Compute the Color3 hash code
  59955. * @returns an unique number that can be used to hash Color3 objects
  59956. */
  59957. getHashCode(): number;
  59958. /**
  59959. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  59960. * @param array defines the array where to store the r,g,b components
  59961. * @param index defines an optional index in the target array to define where to start storing values
  59962. * @returns the current Color3 object
  59963. */
  59964. toArray(array: FloatArray, index?: number): Color3;
  59965. /**
  59966. * Returns a new Color4 object from the current Color3 and the given alpha
  59967. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  59968. * @returns a new Color4 object
  59969. */
  59970. toColor4(alpha?: number): Color4;
  59971. /**
  59972. * Returns a new array populated with 3 numeric elements : red, green and blue values
  59973. * @returns the new array
  59974. */
  59975. asArray(): number[];
  59976. /**
  59977. * Returns the luminance value
  59978. * @returns a float value
  59979. */
  59980. toLuminance(): number;
  59981. /**
  59982. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  59983. * @param otherColor defines the second operand
  59984. * @returns the new Color3 object
  59985. */
  59986. multiply(otherColor: DeepImmutable<Color3>): Color3;
  59987. /**
  59988. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  59989. * @param otherColor defines the second operand
  59990. * @param result defines the Color3 object where to store the result
  59991. * @returns the current Color3
  59992. */
  59993. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59994. /**
  59995. * Determines equality between Color3 objects
  59996. * @param otherColor defines the second operand
  59997. * @returns true if the rgb values are equal to the given ones
  59998. */
  59999. equals(otherColor: DeepImmutable<Color3>): boolean;
  60000. /**
  60001. * Determines equality between the current Color3 object and a set of r,b,g values
  60002. * @param r defines the red component to check
  60003. * @param g defines the green component to check
  60004. * @param b defines the blue component to check
  60005. * @returns true if the rgb values are equal to the given ones
  60006. */
  60007. equalsFloats(r: number, g: number, b: number): boolean;
  60008. /**
  60009. * Multiplies in place each rgb value by scale
  60010. * @param scale defines the scaling factor
  60011. * @returns the updated Color3
  60012. */
  60013. scale(scale: number): Color3;
  60014. /**
  60015. * Multiplies the rgb values by scale and stores the result into "result"
  60016. * @param scale defines the scaling factor
  60017. * @param result defines the Color3 object where to store the result
  60018. * @returns the unmodified current Color3
  60019. */
  60020. scaleToRef(scale: number, result: Color3): Color3;
  60021. /**
  60022. * Scale the current Color3 values by a factor and add the result to a given Color3
  60023. * @param scale defines the scale factor
  60024. * @param result defines color to store the result into
  60025. * @returns the unmodified current Color3
  60026. */
  60027. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60028. /**
  60029. * Clamps the rgb values by the min and max values and stores the result into "result"
  60030. * @param min defines minimum clamping value (default is 0)
  60031. * @param max defines maximum clamping value (default is 1)
  60032. * @param result defines color to store the result into
  60033. * @returns the original Color3
  60034. */
  60035. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60036. /**
  60037. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60038. * @param otherColor defines the second operand
  60039. * @returns the new Color3
  60040. */
  60041. add(otherColor: DeepImmutable<Color3>): Color3;
  60042. /**
  60043. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60044. * @param otherColor defines the second operand
  60045. * @param result defines Color3 object to store the result into
  60046. * @returns the unmodified current Color3
  60047. */
  60048. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60049. /**
  60050. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60051. * @param otherColor defines the second operand
  60052. * @returns the new Color3
  60053. */
  60054. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60055. /**
  60056. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60057. * @param otherColor defines the second operand
  60058. * @param result defines Color3 object to store the result into
  60059. * @returns the unmodified current Color3
  60060. */
  60061. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60062. /**
  60063. * Copy the current object
  60064. * @returns a new Color3 copied the current one
  60065. */
  60066. clone(): Color3;
  60067. /**
  60068. * Copies the rgb values from the source in the current Color3
  60069. * @param source defines the source Color3 object
  60070. * @returns the updated Color3 object
  60071. */
  60072. copyFrom(source: DeepImmutable<Color3>): Color3;
  60073. /**
  60074. * Updates the Color3 rgb values from the given floats
  60075. * @param r defines the red component to read from
  60076. * @param g defines the green component to read from
  60077. * @param b defines the blue component to read from
  60078. * @returns the current Color3 object
  60079. */
  60080. copyFromFloats(r: number, g: number, b: number): Color3;
  60081. /**
  60082. * Updates the Color3 rgb values from the given floats
  60083. * @param r defines the red component to read from
  60084. * @param g defines the green component to read from
  60085. * @param b defines the blue component to read from
  60086. * @returns the current Color3 object
  60087. */
  60088. set(r: number, g: number, b: number): Color3;
  60089. /**
  60090. * Compute the Color3 hexadecimal code as a string
  60091. * @returns a string containing the hexadecimal representation of the Color3 object
  60092. */
  60093. toHexString(): string;
  60094. /**
  60095. * Computes a new Color3 converted from the current one to linear space
  60096. * @returns a new Color3 object
  60097. */
  60098. toLinearSpace(): Color3;
  60099. /**
  60100. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60101. * @param convertedColor defines the Color3 object where to store the linear space version
  60102. * @returns the unmodified Color3
  60103. */
  60104. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60105. /**
  60106. * Computes a new Color3 converted from the current one to gamma space
  60107. * @returns a new Color3 object
  60108. */
  60109. toGammaSpace(): Color3;
  60110. /**
  60111. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60112. * @param convertedColor defines the Color3 object where to store the gamma space version
  60113. * @returns the unmodified Color3
  60114. */
  60115. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60116. private static _BlackReadOnly;
  60117. /**
  60118. * Creates a new Color3 from the string containing valid hexadecimal values
  60119. * @param hex defines a string containing valid hexadecimal values
  60120. * @returns a new Color3 object
  60121. */
  60122. static FromHexString(hex: string): Color3;
  60123. /**
  60124. * Creates a new Color3 from the starting index of the given array
  60125. * @param array defines the source array
  60126. * @param offset defines an offset in the source array
  60127. * @returns a new Color3 object
  60128. */
  60129. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60130. /**
  60131. * Creates a new Color3 from integer values (< 256)
  60132. * @param r defines the red component to read from (value between 0 and 255)
  60133. * @param g defines the green component to read from (value between 0 and 255)
  60134. * @param b defines the blue component to read from (value between 0 and 255)
  60135. * @returns a new Color3 object
  60136. */
  60137. static FromInts(r: number, g: number, b: number): Color3;
  60138. /**
  60139. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60140. * @param start defines the start Color3 value
  60141. * @param end defines the end Color3 value
  60142. * @param amount defines the gradient value between start and end
  60143. * @returns a new Color3 object
  60144. */
  60145. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60146. /**
  60147. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60148. * @param left defines the start value
  60149. * @param right defines the end value
  60150. * @param amount defines the gradient factor
  60151. * @param result defines the Color3 object where to store the result
  60152. */
  60153. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60154. /**
  60155. * Returns a Color3 value containing a red color
  60156. * @returns a new Color3 object
  60157. */
  60158. static Red(): Color3;
  60159. /**
  60160. * Returns a Color3 value containing a green color
  60161. * @returns a new Color3 object
  60162. */
  60163. static Green(): Color3;
  60164. /**
  60165. * Returns a Color3 value containing a blue color
  60166. * @returns a new Color3 object
  60167. */
  60168. static Blue(): Color3;
  60169. /**
  60170. * Returns a Color3 value containing a black color
  60171. * @returns a new Color3 object
  60172. */
  60173. static Black(): Color3;
  60174. /**
  60175. * Gets a Color3 value containing a black color that must not be updated
  60176. */
  60177. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60178. /**
  60179. * Returns a Color3 value containing a white color
  60180. * @returns a new Color3 object
  60181. */
  60182. static White(): Color3;
  60183. /**
  60184. * Returns a Color3 value containing a purple color
  60185. * @returns a new Color3 object
  60186. */
  60187. static Purple(): Color3;
  60188. /**
  60189. * Returns a Color3 value containing a magenta color
  60190. * @returns a new Color3 object
  60191. */
  60192. static Magenta(): Color3;
  60193. /**
  60194. * Returns a Color3 value containing a yellow color
  60195. * @returns a new Color3 object
  60196. */
  60197. static Yellow(): Color3;
  60198. /**
  60199. * Returns a Color3 value containing a gray color
  60200. * @returns a new Color3 object
  60201. */
  60202. static Gray(): Color3;
  60203. /**
  60204. * Returns a Color3 value containing a teal color
  60205. * @returns a new Color3 object
  60206. */
  60207. static Teal(): Color3;
  60208. /**
  60209. * Returns a Color3 value containing a random color
  60210. * @returns a new Color3 object
  60211. */
  60212. static Random(): Color3;
  60213. }
  60214. /**
  60215. * Class used to hold a RBGA color
  60216. */
  60217. export class Color4 {
  60218. /**
  60219. * Defines the red component (between 0 and 1, default is 0)
  60220. */
  60221. r: number;
  60222. /**
  60223. * Defines the green component (between 0 and 1, default is 0)
  60224. */
  60225. g: number;
  60226. /**
  60227. * Defines the blue component (between 0 and 1, default is 0)
  60228. */
  60229. b: number;
  60230. /**
  60231. * Defines the alpha component (between 0 and 1, default is 1)
  60232. */
  60233. a: number;
  60234. /**
  60235. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60236. * @param r defines the red component (between 0 and 1, default is 0)
  60237. * @param g defines the green component (between 0 and 1, default is 0)
  60238. * @param b defines the blue component (between 0 and 1, default is 0)
  60239. * @param a defines the alpha component (between 0 and 1, default is 1)
  60240. */
  60241. constructor(
  60242. /**
  60243. * Defines the red component (between 0 and 1, default is 0)
  60244. */
  60245. r?: number,
  60246. /**
  60247. * Defines the green component (between 0 and 1, default is 0)
  60248. */
  60249. g?: number,
  60250. /**
  60251. * Defines the blue component (between 0 and 1, default is 0)
  60252. */
  60253. b?: number,
  60254. /**
  60255. * Defines the alpha component (between 0 and 1, default is 1)
  60256. */
  60257. a?: number);
  60258. /**
  60259. * Adds in place the given Color4 values to the current Color4 object
  60260. * @param right defines the second operand
  60261. * @returns the current updated Color4 object
  60262. */
  60263. addInPlace(right: DeepImmutable<Color4>): Color4;
  60264. /**
  60265. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60266. * @returns the new array
  60267. */
  60268. asArray(): number[];
  60269. /**
  60270. * Stores from the starting index in the given array the Color4 successive values
  60271. * @param array defines the array where to store the r,g,b components
  60272. * @param index defines an optional index in the target array to define where to start storing values
  60273. * @returns the current Color4 object
  60274. */
  60275. toArray(array: number[], index?: number): Color4;
  60276. /**
  60277. * Determines equality between Color4 objects
  60278. * @param otherColor defines the second operand
  60279. * @returns true if the rgba values are equal to the given ones
  60280. */
  60281. equals(otherColor: DeepImmutable<Color4>): boolean;
  60282. /**
  60283. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60284. * @param right defines the second operand
  60285. * @returns a new Color4 object
  60286. */
  60287. add(right: DeepImmutable<Color4>): Color4;
  60288. /**
  60289. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60290. * @param right defines the second operand
  60291. * @returns a new Color4 object
  60292. */
  60293. subtract(right: DeepImmutable<Color4>): Color4;
  60294. /**
  60295. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60296. * @param right defines the second operand
  60297. * @param result defines the Color4 object where to store the result
  60298. * @returns the current Color4 object
  60299. */
  60300. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60301. /**
  60302. * Creates a new Color4 with the current Color4 values multiplied by scale
  60303. * @param scale defines the scaling factor to apply
  60304. * @returns a new Color4 object
  60305. */
  60306. scale(scale: number): Color4;
  60307. /**
  60308. * Multiplies the current Color4 values by scale and stores the result in "result"
  60309. * @param scale defines the scaling factor to apply
  60310. * @param result defines the Color4 object where to store the result
  60311. * @returns the current unmodified Color4
  60312. */
  60313. scaleToRef(scale: number, result: Color4): Color4;
  60314. /**
  60315. * Scale the current Color4 values by a factor and add the result to a given Color4
  60316. * @param scale defines the scale factor
  60317. * @param result defines the Color4 object where to store the result
  60318. * @returns the unmodified current Color4
  60319. */
  60320. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60321. /**
  60322. * Clamps the rgb values by the min and max values and stores the result into "result"
  60323. * @param min defines minimum clamping value (default is 0)
  60324. * @param max defines maximum clamping value (default is 1)
  60325. * @param result defines color to store the result into.
  60326. * @returns the cuurent Color4
  60327. */
  60328. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60329. /**
  60330. * Multipy an Color4 value by another and return a new Color4 object
  60331. * @param color defines the Color4 value to multiply by
  60332. * @returns a new Color4 object
  60333. */
  60334. multiply(color: Color4): Color4;
  60335. /**
  60336. * Multipy a Color4 value by another and push the result in a reference value
  60337. * @param color defines the Color4 value to multiply by
  60338. * @param result defines the Color4 to fill the result in
  60339. * @returns the result Color4
  60340. */
  60341. multiplyToRef(color: Color4, result: Color4): Color4;
  60342. /**
  60343. * Creates a string with the Color4 current values
  60344. * @returns the string representation of the Color4 object
  60345. */
  60346. toString(): string;
  60347. /**
  60348. * Returns the string "Color4"
  60349. * @returns "Color4"
  60350. */
  60351. getClassName(): string;
  60352. /**
  60353. * Compute the Color4 hash code
  60354. * @returns an unique number that can be used to hash Color4 objects
  60355. */
  60356. getHashCode(): number;
  60357. /**
  60358. * Creates a new Color4 copied from the current one
  60359. * @returns a new Color4 object
  60360. */
  60361. clone(): Color4;
  60362. /**
  60363. * Copies the given Color4 values into the current one
  60364. * @param source defines the source Color4 object
  60365. * @returns the current updated Color4 object
  60366. */
  60367. copyFrom(source: Color4): Color4;
  60368. /**
  60369. * Copies the given float values into the current one
  60370. * @param r defines the red component to read from
  60371. * @param g defines the green component to read from
  60372. * @param b defines the blue component to read from
  60373. * @param a defines the alpha component to read from
  60374. * @returns the current updated Color4 object
  60375. */
  60376. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60377. /**
  60378. * Copies the given float values into the current one
  60379. * @param r defines the red component to read from
  60380. * @param g defines the green component to read from
  60381. * @param b defines the blue component to read from
  60382. * @param a defines the alpha component to read from
  60383. * @returns the current updated Color4 object
  60384. */
  60385. set(r: number, g: number, b: number, a: number): Color4;
  60386. /**
  60387. * Compute the Color4 hexadecimal code as a string
  60388. * @returns a string containing the hexadecimal representation of the Color4 object
  60389. */
  60390. toHexString(): string;
  60391. /**
  60392. * Computes a new Color4 converted from the current one to linear space
  60393. * @returns a new Color4 object
  60394. */
  60395. toLinearSpace(): Color4;
  60396. /**
  60397. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60398. * @param convertedColor defines the Color4 object where to store the linear space version
  60399. * @returns the unmodified Color4
  60400. */
  60401. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60402. /**
  60403. * Computes a new Color4 converted from the current one to gamma space
  60404. * @returns a new Color4 object
  60405. */
  60406. toGammaSpace(): Color4;
  60407. /**
  60408. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60409. * @param convertedColor defines the Color4 object where to store the gamma space version
  60410. * @returns the unmodified Color4
  60411. */
  60412. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60413. /**
  60414. * Creates a new Color4 from the string containing valid hexadecimal values
  60415. * @param hex defines a string containing valid hexadecimal values
  60416. * @returns a new Color4 object
  60417. */
  60418. static FromHexString(hex: string): Color4;
  60419. /**
  60420. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60421. * @param left defines the start value
  60422. * @param right defines the end value
  60423. * @param amount defines the gradient factor
  60424. * @returns a new Color4 object
  60425. */
  60426. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60427. /**
  60428. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60429. * @param left defines the start value
  60430. * @param right defines the end value
  60431. * @param amount defines the gradient factor
  60432. * @param result defines the Color4 object where to store data
  60433. */
  60434. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60435. /**
  60436. * Creates a new Color4 from a Color3 and an alpha value
  60437. * @param color3 defines the source Color3 to read from
  60438. * @param alpha defines the alpha component (1.0 by default)
  60439. * @returns a new Color4 object
  60440. */
  60441. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60442. /**
  60443. * Creates a new Color4 from the starting index element of the given array
  60444. * @param array defines the source array to read from
  60445. * @param offset defines the offset in the source array
  60446. * @returns a new Color4 object
  60447. */
  60448. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60449. /**
  60450. * Creates a new Color3 from integer values (< 256)
  60451. * @param r defines the red component to read from (value between 0 and 255)
  60452. * @param g defines the green component to read from (value between 0 and 255)
  60453. * @param b defines the blue component to read from (value between 0 and 255)
  60454. * @param a defines the alpha component to read from (value between 0 and 255)
  60455. * @returns a new Color3 object
  60456. */
  60457. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60458. /**
  60459. * Check the content of a given array and convert it to an array containing RGBA data
  60460. * If the original array was already containing count * 4 values then it is returned directly
  60461. * @param colors defines the array to check
  60462. * @param count defines the number of RGBA data to expect
  60463. * @returns an array containing count * 4 values (RGBA)
  60464. */
  60465. static CheckColors4(colors: number[], count: number): number[];
  60466. }
  60467. /**
  60468. * Class representing a vector containing 2 coordinates
  60469. */
  60470. export class Vector2 {
  60471. /** defines the first coordinate */
  60472. x: number;
  60473. /** defines the second coordinate */
  60474. y: number;
  60475. /**
  60476. * Creates a new Vector2 from the given x and y coordinates
  60477. * @param x defines the first coordinate
  60478. * @param y defines the second coordinate
  60479. */
  60480. constructor(
  60481. /** defines the first coordinate */
  60482. x?: number,
  60483. /** defines the second coordinate */
  60484. y?: number);
  60485. /**
  60486. * Gets a string with the Vector2 coordinates
  60487. * @returns a string with the Vector2 coordinates
  60488. */
  60489. toString(): string;
  60490. /**
  60491. * Gets class name
  60492. * @returns the string "Vector2"
  60493. */
  60494. getClassName(): string;
  60495. /**
  60496. * Gets current vector hash code
  60497. * @returns the Vector2 hash code as a number
  60498. */
  60499. getHashCode(): number;
  60500. /**
  60501. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60502. * @param array defines the source array
  60503. * @param index defines the offset in source array
  60504. * @returns the current Vector2
  60505. */
  60506. toArray(array: FloatArray, index?: number): Vector2;
  60507. /**
  60508. * Copy the current vector to an array
  60509. * @returns a new array with 2 elements: the Vector2 coordinates.
  60510. */
  60511. asArray(): number[];
  60512. /**
  60513. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60514. * @param source defines the source Vector2
  60515. * @returns the current updated Vector2
  60516. */
  60517. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60518. /**
  60519. * Sets the Vector2 coordinates with the given floats
  60520. * @param x defines the first coordinate
  60521. * @param y defines the second coordinate
  60522. * @returns the current updated Vector2
  60523. */
  60524. copyFromFloats(x: number, y: number): Vector2;
  60525. /**
  60526. * Sets the Vector2 coordinates with the given floats
  60527. * @param x defines the first coordinate
  60528. * @param y defines the second coordinate
  60529. * @returns the current updated Vector2
  60530. */
  60531. set(x: number, y: number): Vector2;
  60532. /**
  60533. * Add another vector with the current one
  60534. * @param otherVector defines the other vector
  60535. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60536. */
  60537. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60538. /**
  60539. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60540. * @param otherVector defines the other vector
  60541. * @param result defines the target vector
  60542. * @returns the unmodified current Vector2
  60543. */
  60544. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60545. /**
  60546. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60547. * @param otherVector defines the other vector
  60548. * @returns the current updated Vector2
  60549. */
  60550. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60551. /**
  60552. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60553. * @param otherVector defines the other vector
  60554. * @returns a new Vector2
  60555. */
  60556. addVector3(otherVector: Vector3): Vector2;
  60557. /**
  60558. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60559. * @param otherVector defines the other vector
  60560. * @returns a new Vector2
  60561. */
  60562. subtract(otherVector: Vector2): Vector2;
  60563. /**
  60564. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60565. * @param otherVector defines the other vector
  60566. * @param result defines the target vector
  60567. * @returns the unmodified current Vector2
  60568. */
  60569. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60570. /**
  60571. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60572. * @param otherVector defines the other vector
  60573. * @returns the current updated Vector2
  60574. */
  60575. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60576. /**
  60577. * Multiplies in place the current Vector2 coordinates by the given ones
  60578. * @param otherVector defines the other vector
  60579. * @returns the current updated Vector2
  60580. */
  60581. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60582. /**
  60583. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60584. * @param otherVector defines the other vector
  60585. * @returns a new Vector2
  60586. */
  60587. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60588. /**
  60589. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60590. * @param otherVector defines the other vector
  60591. * @param result defines the target vector
  60592. * @returns the unmodified current Vector2
  60593. */
  60594. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60595. /**
  60596. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60597. * @param x defines the first coordinate
  60598. * @param y defines the second coordinate
  60599. * @returns a new Vector2
  60600. */
  60601. multiplyByFloats(x: number, y: number): Vector2;
  60602. /**
  60603. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60604. * @param otherVector defines the other vector
  60605. * @returns a new Vector2
  60606. */
  60607. divide(otherVector: Vector2): Vector2;
  60608. /**
  60609. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60610. * @param otherVector defines the other vector
  60611. * @param result defines the target vector
  60612. * @returns the unmodified current Vector2
  60613. */
  60614. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60615. /**
  60616. * Divides the current Vector2 coordinates by the given ones
  60617. * @param otherVector defines the other vector
  60618. * @returns the current updated Vector2
  60619. */
  60620. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60621. /**
  60622. * Gets a new Vector2 with current Vector2 negated coordinates
  60623. * @returns a new Vector2
  60624. */
  60625. negate(): Vector2;
  60626. /**
  60627. * Multiply the Vector2 coordinates by scale
  60628. * @param scale defines the scaling factor
  60629. * @returns the current updated Vector2
  60630. */
  60631. scaleInPlace(scale: number): Vector2;
  60632. /**
  60633. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60634. * @param scale defines the scaling factor
  60635. * @returns a new Vector2
  60636. */
  60637. scale(scale: number): Vector2;
  60638. /**
  60639. * Scale the current Vector2 values by a factor to a given Vector2
  60640. * @param scale defines the scale factor
  60641. * @param result defines the Vector2 object where to store the result
  60642. * @returns the unmodified current Vector2
  60643. */
  60644. scaleToRef(scale: number, result: Vector2): Vector2;
  60645. /**
  60646. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60647. * @param scale defines the scale factor
  60648. * @param result defines the Vector2 object where to store the result
  60649. * @returns the unmodified current Vector2
  60650. */
  60651. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60652. /**
  60653. * Gets a boolean if two vectors are equals
  60654. * @param otherVector defines the other vector
  60655. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60656. */
  60657. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60658. /**
  60659. * Gets a boolean if two vectors are equals (using an epsilon value)
  60660. * @param otherVector defines the other vector
  60661. * @param epsilon defines the minimal distance to consider equality
  60662. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60663. */
  60664. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60665. /**
  60666. * Gets a new Vector2 from current Vector2 floored values
  60667. * @returns a new Vector2
  60668. */
  60669. floor(): Vector2;
  60670. /**
  60671. * Gets a new Vector2 from current Vector2 floored values
  60672. * @returns a new Vector2
  60673. */
  60674. fract(): Vector2;
  60675. /**
  60676. * Gets the length of the vector
  60677. * @returns the vector length (float)
  60678. */
  60679. length(): number;
  60680. /**
  60681. * Gets the vector squared length
  60682. * @returns the vector squared length (float)
  60683. */
  60684. lengthSquared(): number;
  60685. /**
  60686. * Normalize the vector
  60687. * @returns the current updated Vector2
  60688. */
  60689. normalize(): Vector2;
  60690. /**
  60691. * Gets a new Vector2 copied from the Vector2
  60692. * @returns a new Vector2
  60693. */
  60694. clone(): Vector2;
  60695. /**
  60696. * Gets a new Vector2(0, 0)
  60697. * @returns a new Vector2
  60698. */
  60699. static Zero(): Vector2;
  60700. /**
  60701. * Gets a new Vector2(1, 1)
  60702. * @returns a new Vector2
  60703. */
  60704. static One(): Vector2;
  60705. /**
  60706. * Gets a new Vector2 set from the given index element of the given array
  60707. * @param array defines the data source
  60708. * @param offset defines the offset in the data source
  60709. * @returns a new Vector2
  60710. */
  60711. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60712. /**
  60713. * Sets "result" from the given index element of the given array
  60714. * @param array defines the data source
  60715. * @param offset defines the offset in the data source
  60716. * @param result defines the target vector
  60717. */
  60718. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60719. /**
  60720. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60721. * @param value1 defines 1st point of control
  60722. * @param value2 defines 2nd point of control
  60723. * @param value3 defines 3rd point of control
  60724. * @param value4 defines 4th point of control
  60725. * @param amount defines the interpolation factor
  60726. * @returns a new Vector2
  60727. */
  60728. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60729. /**
  60730. * 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".
  60731. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60732. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60733. * @param value defines the value to clamp
  60734. * @param min defines the lower limit
  60735. * @param max defines the upper limit
  60736. * @returns a new Vector2
  60737. */
  60738. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60739. /**
  60740. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60741. * @param value1 defines the 1st control point
  60742. * @param tangent1 defines the outgoing tangent
  60743. * @param value2 defines the 2nd control point
  60744. * @param tangent2 defines the incoming tangent
  60745. * @param amount defines the interpolation factor
  60746. * @returns a new Vector2
  60747. */
  60748. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60749. /**
  60750. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60751. * @param start defines the start vector
  60752. * @param end defines the end vector
  60753. * @param amount defines the interpolation factor
  60754. * @returns a new Vector2
  60755. */
  60756. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60757. /**
  60758. * Gets the dot product of the vector "left" and the vector "right"
  60759. * @param left defines first vector
  60760. * @param right defines second vector
  60761. * @returns the dot product (float)
  60762. */
  60763. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60764. /**
  60765. * Returns a new Vector2 equal to the normalized given vector
  60766. * @param vector defines the vector to normalize
  60767. * @returns a new Vector2
  60768. */
  60769. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60770. /**
  60771. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60772. * @param left defines 1st vector
  60773. * @param right defines 2nd vector
  60774. * @returns a new Vector2
  60775. */
  60776. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60777. /**
  60778. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60779. * @param left defines 1st vector
  60780. * @param right defines 2nd vector
  60781. * @returns a new Vector2
  60782. */
  60783. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60784. /**
  60785. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60786. * @param vector defines the vector to transform
  60787. * @param transformation defines the matrix to apply
  60788. * @returns a new Vector2
  60789. */
  60790. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60791. /**
  60792. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60793. * @param vector defines the vector to transform
  60794. * @param transformation defines the matrix to apply
  60795. * @param result defines the target vector
  60796. */
  60797. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60798. /**
  60799. * Determines if a given vector is included in a triangle
  60800. * @param p defines the vector to test
  60801. * @param p0 defines 1st triangle point
  60802. * @param p1 defines 2nd triangle point
  60803. * @param p2 defines 3rd triangle point
  60804. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60805. */
  60806. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60807. /**
  60808. * Gets the distance between the vectors "value1" and "value2"
  60809. * @param value1 defines first vector
  60810. * @param value2 defines second vector
  60811. * @returns the distance between vectors
  60812. */
  60813. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60814. /**
  60815. * Returns the squared distance between the vectors "value1" and "value2"
  60816. * @param value1 defines first vector
  60817. * @param value2 defines second vector
  60818. * @returns the squared distance between vectors
  60819. */
  60820. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60821. /**
  60822. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60823. * @param value1 defines first vector
  60824. * @param value2 defines second vector
  60825. * @returns a new Vector2
  60826. */
  60827. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60828. /**
  60829. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60830. * @param p defines the middle point
  60831. * @param segA defines one point of the segment
  60832. * @param segB defines the other point of the segment
  60833. * @returns the shortest distance
  60834. */
  60835. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60836. }
  60837. /**
  60838. * Classed used to store (x,y,z) vector representation
  60839. * A Vector3 is the main object used in 3D geometry
  60840. * It can represent etiher the coordinates of a point the space, either a direction
  60841. * Reminder: js uses a left handed forward facing system
  60842. */
  60843. export class Vector3 {
  60844. /**
  60845. * Defines the first coordinates (on X axis)
  60846. */
  60847. x: number;
  60848. /**
  60849. * Defines the second coordinates (on Y axis)
  60850. */
  60851. y: number;
  60852. /**
  60853. * Defines the third coordinates (on Z axis)
  60854. */
  60855. z: number;
  60856. private static _UpReadOnly;
  60857. /**
  60858. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60859. * @param x defines the first coordinates (on X axis)
  60860. * @param y defines the second coordinates (on Y axis)
  60861. * @param z defines the third coordinates (on Z axis)
  60862. */
  60863. constructor(
  60864. /**
  60865. * Defines the first coordinates (on X axis)
  60866. */
  60867. x?: number,
  60868. /**
  60869. * Defines the second coordinates (on Y axis)
  60870. */
  60871. y?: number,
  60872. /**
  60873. * Defines the third coordinates (on Z axis)
  60874. */
  60875. z?: number);
  60876. /**
  60877. * Creates a string representation of the Vector3
  60878. * @returns a string with the Vector3 coordinates.
  60879. */
  60880. toString(): string;
  60881. /**
  60882. * Gets the class name
  60883. * @returns the string "Vector3"
  60884. */
  60885. getClassName(): string;
  60886. /**
  60887. * Creates the Vector3 hash code
  60888. * @returns a number which tends to be unique between Vector3 instances
  60889. */
  60890. getHashCode(): number;
  60891. /**
  60892. * Creates an array containing three elements : the coordinates of the Vector3
  60893. * @returns a new array of numbers
  60894. */
  60895. asArray(): number[];
  60896. /**
  60897. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60898. * @param array defines the destination array
  60899. * @param index defines the offset in the destination array
  60900. * @returns the current Vector3
  60901. */
  60902. toArray(array: FloatArray, index?: number): Vector3;
  60903. /**
  60904. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60905. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60906. */
  60907. toQuaternion(): Quaternion;
  60908. /**
  60909. * Adds the given vector to the current Vector3
  60910. * @param otherVector defines the second operand
  60911. * @returns the current updated Vector3
  60912. */
  60913. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60914. /**
  60915. * Adds the given coordinates to the current Vector3
  60916. * @param x defines the x coordinate of the operand
  60917. * @param y defines the y coordinate of the operand
  60918. * @param z defines the z coordinate of the operand
  60919. * @returns the current updated Vector3
  60920. */
  60921. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60922. /**
  60923. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  60924. * @param otherVector defines the second operand
  60925. * @returns the resulting Vector3
  60926. */
  60927. add(otherVector: DeepImmutable<Vector3>): Vector3;
  60928. /**
  60929. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  60930. * @param otherVector defines the second operand
  60931. * @param result defines the Vector3 object where to store the result
  60932. * @returns the current Vector3
  60933. */
  60934. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60935. /**
  60936. * Subtract the given vector from the current Vector3
  60937. * @param otherVector defines the second operand
  60938. * @returns the current updated Vector3
  60939. */
  60940. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60941. /**
  60942. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  60943. * @param otherVector defines the second operand
  60944. * @returns the resulting Vector3
  60945. */
  60946. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  60947. /**
  60948. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  60949. * @param otherVector defines the second operand
  60950. * @param result defines the Vector3 object where to store the result
  60951. * @returns the current Vector3
  60952. */
  60953. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60954. /**
  60955. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  60956. * @param x defines the x coordinate of the operand
  60957. * @param y defines the y coordinate of the operand
  60958. * @param z defines the z coordinate of the operand
  60959. * @returns the resulting Vector3
  60960. */
  60961. subtractFromFloats(x: number, y: number, z: number): Vector3;
  60962. /**
  60963. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  60964. * @param x defines the x coordinate of the operand
  60965. * @param y defines the y coordinate of the operand
  60966. * @param z defines the z coordinate of the operand
  60967. * @param result defines the Vector3 object where to store the result
  60968. * @returns the current Vector3
  60969. */
  60970. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  60971. /**
  60972. * Gets a new Vector3 set with the current Vector3 negated coordinates
  60973. * @returns a new Vector3
  60974. */
  60975. negate(): Vector3;
  60976. /**
  60977. * Multiplies the Vector3 coordinates by the float "scale"
  60978. * @param scale defines the multiplier factor
  60979. * @returns the current updated Vector3
  60980. */
  60981. scaleInPlace(scale: number): Vector3;
  60982. /**
  60983. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  60984. * @param scale defines the multiplier factor
  60985. * @returns a new Vector3
  60986. */
  60987. scale(scale: number): Vector3;
  60988. /**
  60989. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  60990. * @param scale defines the multiplier factor
  60991. * @param result defines the Vector3 object where to store the result
  60992. * @returns the current Vector3
  60993. */
  60994. scaleToRef(scale: number, result: Vector3): Vector3;
  60995. /**
  60996. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60997. * @param scale defines the scale factor
  60998. * @param result defines the Vector3 object where to store the result
  60999. * @returns the unmodified current Vector3
  61000. */
  61001. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61002. /**
  61003. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61004. * @param otherVector defines the second operand
  61005. * @returns true if both vectors are equals
  61006. */
  61007. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61008. /**
  61009. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61010. * @param otherVector defines the second operand
  61011. * @param epsilon defines the minimal distance to define values as equals
  61012. * @returns true if both vectors are distant less than epsilon
  61013. */
  61014. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61015. /**
  61016. * Returns true if the current Vector3 coordinates equals the given floats
  61017. * @param x defines the x coordinate of the operand
  61018. * @param y defines the y coordinate of the operand
  61019. * @param z defines the z coordinate of the operand
  61020. * @returns true if both vectors are equals
  61021. */
  61022. equalsToFloats(x: number, y: number, z: number): boolean;
  61023. /**
  61024. * Multiplies the current Vector3 coordinates by the given ones
  61025. * @param otherVector defines the second operand
  61026. * @returns the current updated Vector3
  61027. */
  61028. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61029. /**
  61030. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61031. * @param otherVector defines the second operand
  61032. * @returns the new Vector3
  61033. */
  61034. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61035. /**
  61036. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61037. * @param otherVector defines the second operand
  61038. * @param result defines the Vector3 object where to store the result
  61039. * @returns the current Vector3
  61040. */
  61041. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61042. /**
  61043. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61044. * @param x defines the x coordinate of the operand
  61045. * @param y defines the y coordinate of the operand
  61046. * @param z defines the z coordinate of the operand
  61047. * @returns the new Vector3
  61048. */
  61049. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61050. /**
  61051. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61052. * @param otherVector defines the second operand
  61053. * @returns the new Vector3
  61054. */
  61055. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61056. /**
  61057. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61058. * @param otherVector defines the second operand
  61059. * @param result defines the Vector3 object where to store the result
  61060. * @returns the current Vector3
  61061. */
  61062. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61063. /**
  61064. * Divides the current Vector3 coordinates by the given ones.
  61065. * @param otherVector defines the second operand
  61066. * @returns the current updated Vector3
  61067. */
  61068. divideInPlace(otherVector: Vector3): Vector3;
  61069. /**
  61070. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61071. * @param other defines the second operand
  61072. * @returns the current updated Vector3
  61073. */
  61074. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61075. /**
  61076. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61077. * @param other defines the second operand
  61078. * @returns the current updated Vector3
  61079. */
  61080. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61081. /**
  61082. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61083. * @param x defines the x coordinate of the operand
  61084. * @param y defines the y coordinate of the operand
  61085. * @param z defines the z coordinate of the operand
  61086. * @returns the current updated Vector3
  61087. */
  61088. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61089. /**
  61090. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61091. * @param x defines the x coordinate of the operand
  61092. * @param y defines the y coordinate of the operand
  61093. * @param z defines the z coordinate of the operand
  61094. * @returns the current updated Vector3
  61095. */
  61096. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61097. /**
  61098. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61099. * Check if is non uniform within a certain amount of decimal places to account for this
  61100. * @param epsilon the amount the values can differ
  61101. * @returns if the the vector is non uniform to a certain number of decimal places
  61102. */
  61103. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61104. /**
  61105. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61106. */
  61107. readonly isNonUniform: boolean;
  61108. /**
  61109. * Gets a new Vector3 from current Vector3 floored values
  61110. * @returns a new Vector3
  61111. */
  61112. floor(): Vector3;
  61113. /**
  61114. * Gets a new Vector3 from current Vector3 floored values
  61115. * @returns a new Vector3
  61116. */
  61117. fract(): Vector3;
  61118. /**
  61119. * Gets the length of the Vector3
  61120. * @returns the length of the Vecto3
  61121. */
  61122. length(): number;
  61123. /**
  61124. * Gets the squared length of the Vector3
  61125. * @returns squared length of the Vector3
  61126. */
  61127. lengthSquared(): number;
  61128. /**
  61129. * Normalize the current Vector3.
  61130. * Please note that this is an in place operation.
  61131. * @returns the current updated Vector3
  61132. */
  61133. normalize(): Vector3;
  61134. /**
  61135. * Reorders the x y z properties of the vector in place
  61136. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61137. * @returns the current updated vector
  61138. */
  61139. reorderInPlace(order: string): this;
  61140. /**
  61141. * Rotates the vector around 0,0,0 by a quaternion
  61142. * @param quaternion the rotation quaternion
  61143. * @param result vector to store the result
  61144. * @returns the resulting vector
  61145. */
  61146. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61147. /**
  61148. * Rotates a vector around a given point
  61149. * @param quaternion the rotation quaternion
  61150. * @param point the point to rotate around
  61151. * @param result vector to store the result
  61152. * @returns the resulting vector
  61153. */
  61154. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61155. /**
  61156. * Normalize the current Vector3 with the given input length.
  61157. * Please note that this is an in place operation.
  61158. * @param len the length of the vector
  61159. * @returns the current updated Vector3
  61160. */
  61161. normalizeFromLength(len: number): Vector3;
  61162. /**
  61163. * Normalize the current Vector3 to a new vector
  61164. * @returns the new Vector3
  61165. */
  61166. normalizeToNew(): Vector3;
  61167. /**
  61168. * Normalize the current Vector3 to the reference
  61169. * @param reference define the Vector3 to update
  61170. * @returns the updated Vector3
  61171. */
  61172. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61173. /**
  61174. * Creates a new Vector3 copied from the current Vector3
  61175. * @returns the new Vector3
  61176. */
  61177. clone(): Vector3;
  61178. /**
  61179. * Copies the given vector coordinates to the current Vector3 ones
  61180. * @param source defines the source Vector3
  61181. * @returns the current updated Vector3
  61182. */
  61183. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61184. /**
  61185. * Copies the given floats to the current Vector3 coordinates
  61186. * @param x defines the x coordinate of the operand
  61187. * @param y defines the y coordinate of the operand
  61188. * @param z defines the z coordinate of the operand
  61189. * @returns the current updated Vector3
  61190. */
  61191. copyFromFloats(x: number, y: number, z: number): Vector3;
  61192. /**
  61193. * Copies the given floats to the current Vector3 coordinates
  61194. * @param x defines the x coordinate of the operand
  61195. * @param y defines the y coordinate of the operand
  61196. * @param z defines the z coordinate of the operand
  61197. * @returns the current updated Vector3
  61198. */
  61199. set(x: number, y: number, z: number): Vector3;
  61200. /**
  61201. * Copies the given float to the current Vector3 coordinates
  61202. * @param v defines the x, y and z coordinates of the operand
  61203. * @returns the current updated Vector3
  61204. */
  61205. setAll(v: number): Vector3;
  61206. /**
  61207. * Get the clip factor between two vectors
  61208. * @param vector0 defines the first operand
  61209. * @param vector1 defines the second operand
  61210. * @param axis defines the axis to use
  61211. * @param size defines the size along the axis
  61212. * @returns the clip factor
  61213. */
  61214. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61215. /**
  61216. * Get angle between two vectors
  61217. * @param vector0 angle between vector0 and vector1
  61218. * @param vector1 angle between vector0 and vector1
  61219. * @param normal direction of the normal
  61220. * @return the angle between vector0 and vector1
  61221. */
  61222. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61223. /**
  61224. * Returns a new Vector3 set from the index "offset" of the given array
  61225. * @param array defines the source array
  61226. * @param offset defines the offset in the source array
  61227. * @returns the new Vector3
  61228. */
  61229. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61230. /**
  61231. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61232. * This function is deprecated. Use FromArray instead
  61233. * @param array defines the source array
  61234. * @param offset defines the offset in the source array
  61235. * @returns the new Vector3
  61236. */
  61237. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61238. /**
  61239. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61240. * @param array defines the source array
  61241. * @param offset defines the offset in the source array
  61242. * @param result defines the Vector3 where to store the result
  61243. */
  61244. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61245. /**
  61246. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61247. * This function is deprecated. Use FromArrayToRef instead.
  61248. * @param array defines the source array
  61249. * @param offset defines the offset in the source array
  61250. * @param result defines the Vector3 where to store the result
  61251. */
  61252. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61253. /**
  61254. * Sets the given vector "result" with the given floats.
  61255. * @param x defines the x coordinate of the source
  61256. * @param y defines the y coordinate of the source
  61257. * @param z defines the z coordinate of the source
  61258. * @param result defines the Vector3 where to store the result
  61259. */
  61260. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61261. /**
  61262. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61263. * @returns a new empty Vector3
  61264. */
  61265. static Zero(): Vector3;
  61266. /**
  61267. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61268. * @returns a new unit Vector3
  61269. */
  61270. static One(): Vector3;
  61271. /**
  61272. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61273. * @returns a new up Vector3
  61274. */
  61275. static Up(): Vector3;
  61276. /**
  61277. * Gets a up Vector3 that must not be updated
  61278. */
  61279. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61280. /**
  61281. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61282. * @returns a new down Vector3
  61283. */
  61284. static Down(): Vector3;
  61285. /**
  61286. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61287. * @returns a new forward Vector3
  61288. */
  61289. static Forward(): Vector3;
  61290. /**
  61291. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61292. * @returns a new forward Vector3
  61293. */
  61294. static Backward(): Vector3;
  61295. /**
  61296. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61297. * @returns a new right Vector3
  61298. */
  61299. static Right(): Vector3;
  61300. /**
  61301. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61302. * @returns a new left Vector3
  61303. */
  61304. static Left(): Vector3;
  61305. /**
  61306. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61307. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61308. * @param vector defines the Vector3 to transform
  61309. * @param transformation defines the transformation matrix
  61310. * @returns the transformed Vector3
  61311. */
  61312. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61313. /**
  61314. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61315. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61316. * @param vector defines the Vector3 to transform
  61317. * @param transformation defines the transformation matrix
  61318. * @param result defines the Vector3 where to store the result
  61319. */
  61320. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61321. /**
  61322. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61323. * This method computes tranformed coordinates only, not transformed direction vectors
  61324. * @param x define the x coordinate of the source vector
  61325. * @param y define the y coordinate of the source vector
  61326. * @param z define the z coordinate of the source vector
  61327. * @param transformation defines the transformation matrix
  61328. * @param result defines the Vector3 where to store the result
  61329. */
  61330. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61331. /**
  61332. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61333. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61334. * @param vector defines the Vector3 to transform
  61335. * @param transformation defines the transformation matrix
  61336. * @returns the new Vector3
  61337. */
  61338. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61339. /**
  61340. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61341. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61342. * @param vector defines the Vector3 to transform
  61343. * @param transformation defines the transformation matrix
  61344. * @param result defines the Vector3 where to store the result
  61345. */
  61346. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61347. /**
  61348. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61349. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61350. * @param x define the x coordinate of the source vector
  61351. * @param y define the y coordinate of the source vector
  61352. * @param z define the z coordinate of the source vector
  61353. * @param transformation defines the transformation matrix
  61354. * @param result defines the Vector3 where to store the result
  61355. */
  61356. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61357. /**
  61358. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61359. * @param value1 defines the first control point
  61360. * @param value2 defines the second control point
  61361. * @param value3 defines the third control point
  61362. * @param value4 defines the fourth control point
  61363. * @param amount defines the amount on the spline to use
  61364. * @returns the new Vector3
  61365. */
  61366. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61367. /**
  61368. * 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"
  61369. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61370. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61371. * @param value defines the current value
  61372. * @param min defines the lower range value
  61373. * @param max defines the upper range value
  61374. * @returns the new Vector3
  61375. */
  61376. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61377. /**
  61378. * 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"
  61379. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61380. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61381. * @param value defines the current value
  61382. * @param min defines the lower range value
  61383. * @param max defines the upper range value
  61384. * @param result defines the Vector3 where to store the result
  61385. */
  61386. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61387. /**
  61388. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61389. * @param value1 defines the first control point
  61390. * @param tangent1 defines the first tangent vector
  61391. * @param value2 defines the second control point
  61392. * @param tangent2 defines the second tangent vector
  61393. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61394. * @returns the new Vector3
  61395. */
  61396. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61397. /**
  61398. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61399. * @param start defines the start value
  61400. * @param end defines the end value
  61401. * @param amount max defines amount between both (between 0 and 1)
  61402. * @returns the new Vector3
  61403. */
  61404. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61405. /**
  61406. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61407. * @param start defines the start value
  61408. * @param end defines the end value
  61409. * @param amount max defines amount between both (between 0 and 1)
  61410. * @param result defines the Vector3 where to store the result
  61411. */
  61412. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61413. /**
  61414. * Returns the dot product (float) between the vectors "left" and "right"
  61415. * @param left defines the left operand
  61416. * @param right defines the right operand
  61417. * @returns the dot product
  61418. */
  61419. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61420. /**
  61421. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61422. * The cross product is then orthogonal to both "left" and "right"
  61423. * @param left defines the left operand
  61424. * @param right defines the right operand
  61425. * @returns the cross product
  61426. */
  61427. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61428. /**
  61429. * Sets the given vector "result" with the cross product of "left" and "right"
  61430. * The cross product is then orthogonal to both "left" and "right"
  61431. * @param left defines the left operand
  61432. * @param right defines the right operand
  61433. * @param result defines the Vector3 where to store the result
  61434. */
  61435. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61436. /**
  61437. * Returns a new Vector3 as the normalization of the given vector
  61438. * @param vector defines the Vector3 to normalize
  61439. * @returns the new Vector3
  61440. */
  61441. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61442. /**
  61443. * Sets the given vector "result" with the normalization of the given first vector
  61444. * @param vector defines the Vector3 to normalize
  61445. * @param result defines the Vector3 where to store the result
  61446. */
  61447. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61448. /**
  61449. * Project a Vector3 onto screen space
  61450. * @param vector defines the Vector3 to project
  61451. * @param world defines the world matrix to use
  61452. * @param transform defines the transform (view x projection) matrix to use
  61453. * @param viewport defines the screen viewport to use
  61454. * @returns the new Vector3
  61455. */
  61456. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61457. /** @hidden */
  61458. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61459. /**
  61460. * Unproject from screen space to object space
  61461. * @param source defines the screen space Vector3 to use
  61462. * @param viewportWidth defines the current width of the viewport
  61463. * @param viewportHeight defines the current height of the viewport
  61464. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61465. * @param transform defines the transform (view x projection) matrix to use
  61466. * @returns the new Vector3
  61467. */
  61468. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61469. /**
  61470. * Unproject from screen space to object space
  61471. * @param source defines the screen space Vector3 to use
  61472. * @param viewportWidth defines the current width of the viewport
  61473. * @param viewportHeight defines the current height of the viewport
  61474. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61475. * @param view defines the view matrix to use
  61476. * @param projection defines the projection matrix to use
  61477. * @returns the new Vector3
  61478. */
  61479. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61480. /**
  61481. * Unproject from screen space to object space
  61482. * @param source defines the screen space Vector3 to use
  61483. * @param viewportWidth defines the current width of the viewport
  61484. * @param viewportHeight defines the current height of the viewport
  61485. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61486. * @param view defines the view matrix to use
  61487. * @param projection defines the projection matrix to use
  61488. * @param result defines the Vector3 where to store the result
  61489. */
  61490. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61491. /**
  61492. * Unproject from screen space to object space
  61493. * @param sourceX defines the screen space x coordinate to use
  61494. * @param sourceY defines the screen space y coordinate to use
  61495. * @param sourceZ defines the screen space z coordinate to use
  61496. * @param viewportWidth defines the current width of the viewport
  61497. * @param viewportHeight defines the current height of the viewport
  61498. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61499. * @param view defines the view matrix to use
  61500. * @param projection defines the projection matrix to use
  61501. * @param result defines the Vector3 where to store the result
  61502. */
  61503. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61504. /**
  61505. * Gets the minimal coordinate values between two Vector3
  61506. * @param left defines the first operand
  61507. * @param right defines the second operand
  61508. * @returns the new Vector3
  61509. */
  61510. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61511. /**
  61512. * Gets the maximal coordinate values between two Vector3
  61513. * @param left defines the first operand
  61514. * @param right defines the second operand
  61515. * @returns the new Vector3
  61516. */
  61517. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61518. /**
  61519. * Returns the distance between the vectors "value1" and "value2"
  61520. * @param value1 defines the first operand
  61521. * @param value2 defines the second operand
  61522. * @returns the distance
  61523. */
  61524. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61525. /**
  61526. * Returns the squared distance between the vectors "value1" and "value2"
  61527. * @param value1 defines the first operand
  61528. * @param value2 defines the second operand
  61529. * @returns the squared distance
  61530. */
  61531. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61532. /**
  61533. * Returns a new Vector3 located at the center between "value1" and "value2"
  61534. * @param value1 defines the first operand
  61535. * @param value2 defines the second operand
  61536. * @returns the new Vector3
  61537. */
  61538. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61539. /**
  61540. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61541. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61542. * to something in order to rotate it from its local system to the given target system
  61543. * Note: axis1, axis2 and axis3 are normalized during this operation
  61544. * @param axis1 defines the first axis
  61545. * @param axis2 defines the second axis
  61546. * @param axis3 defines the third axis
  61547. * @returns a new Vector3
  61548. */
  61549. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61550. /**
  61551. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61552. * @param axis1 defines the first axis
  61553. * @param axis2 defines the second axis
  61554. * @param axis3 defines the third axis
  61555. * @param ref defines the Vector3 where to store the result
  61556. */
  61557. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61558. }
  61559. /**
  61560. * Vector4 class created for EulerAngle class conversion to Quaternion
  61561. */
  61562. export class Vector4 {
  61563. /** x value of the vector */
  61564. x: number;
  61565. /** y value of the vector */
  61566. y: number;
  61567. /** z value of the vector */
  61568. z: number;
  61569. /** w value of the vector */
  61570. w: number;
  61571. /**
  61572. * Creates a Vector4 object from the given floats.
  61573. * @param x x value of the vector
  61574. * @param y y value of the vector
  61575. * @param z z value of the vector
  61576. * @param w w value of the vector
  61577. */
  61578. constructor(
  61579. /** x value of the vector */
  61580. x: number,
  61581. /** y value of the vector */
  61582. y: number,
  61583. /** z value of the vector */
  61584. z: number,
  61585. /** w value of the vector */
  61586. w: number);
  61587. /**
  61588. * Returns the string with the Vector4 coordinates.
  61589. * @returns a string containing all the vector values
  61590. */
  61591. toString(): string;
  61592. /**
  61593. * Returns the string "Vector4".
  61594. * @returns "Vector4"
  61595. */
  61596. getClassName(): string;
  61597. /**
  61598. * Returns the Vector4 hash code.
  61599. * @returns a unique hash code
  61600. */
  61601. getHashCode(): number;
  61602. /**
  61603. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61604. * @returns the resulting array
  61605. */
  61606. asArray(): number[];
  61607. /**
  61608. * Populates the given array from the given index with the Vector4 coordinates.
  61609. * @param array array to populate
  61610. * @param index index of the array to start at (default: 0)
  61611. * @returns the Vector4.
  61612. */
  61613. toArray(array: FloatArray, index?: number): Vector4;
  61614. /**
  61615. * Adds the given vector to the current Vector4.
  61616. * @param otherVector the vector to add
  61617. * @returns the updated Vector4.
  61618. */
  61619. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61620. /**
  61621. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61622. * @param otherVector the vector to add
  61623. * @returns the resulting vector
  61624. */
  61625. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61626. /**
  61627. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61628. * @param otherVector the vector to add
  61629. * @param result the vector to store the result
  61630. * @returns the current Vector4.
  61631. */
  61632. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61633. /**
  61634. * Subtract in place the given vector from the current Vector4.
  61635. * @param otherVector the vector to subtract
  61636. * @returns the updated Vector4.
  61637. */
  61638. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61639. /**
  61640. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61641. * @param otherVector the vector to add
  61642. * @returns the new vector with the result
  61643. */
  61644. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61645. /**
  61646. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61647. * @param otherVector the vector to subtract
  61648. * @param result the vector to store the result
  61649. * @returns the current Vector4.
  61650. */
  61651. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61652. /**
  61653. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61654. */
  61655. /**
  61656. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61657. * @param x value to subtract
  61658. * @param y value to subtract
  61659. * @param z value to subtract
  61660. * @param w value to subtract
  61661. * @returns new vector containing the result
  61662. */
  61663. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61664. /**
  61665. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61666. * @param x value to subtract
  61667. * @param y value to subtract
  61668. * @param z value to subtract
  61669. * @param w value to subtract
  61670. * @param result the vector to store the result in
  61671. * @returns the current Vector4.
  61672. */
  61673. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61674. /**
  61675. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61676. * @returns a new vector with the negated values
  61677. */
  61678. negate(): Vector4;
  61679. /**
  61680. * Multiplies the current Vector4 coordinates by scale (float).
  61681. * @param scale the number to scale with
  61682. * @returns the updated Vector4.
  61683. */
  61684. scaleInPlace(scale: number): Vector4;
  61685. /**
  61686. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61687. * @param scale the number to scale with
  61688. * @returns a new vector with the result
  61689. */
  61690. scale(scale: number): Vector4;
  61691. /**
  61692. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61693. * @param scale the number to scale with
  61694. * @param result a vector to store the result in
  61695. * @returns the current Vector4.
  61696. */
  61697. scaleToRef(scale: number, result: Vector4): Vector4;
  61698. /**
  61699. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61700. * @param scale defines the scale factor
  61701. * @param result defines the Vector4 object where to store the result
  61702. * @returns the unmodified current Vector4
  61703. */
  61704. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61705. /**
  61706. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61707. * @param otherVector the vector to compare against
  61708. * @returns true if they are equal
  61709. */
  61710. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61711. /**
  61712. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61713. * @param otherVector vector to compare against
  61714. * @param epsilon (Default: very small number)
  61715. * @returns true if they are equal
  61716. */
  61717. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61718. /**
  61719. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61720. * @param x x value to compare against
  61721. * @param y y value to compare against
  61722. * @param z z value to compare against
  61723. * @param w w value to compare against
  61724. * @returns true if equal
  61725. */
  61726. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61727. /**
  61728. * Multiplies in place the current Vector4 by the given one.
  61729. * @param otherVector vector to multiple with
  61730. * @returns the updated Vector4.
  61731. */
  61732. multiplyInPlace(otherVector: Vector4): Vector4;
  61733. /**
  61734. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61735. * @param otherVector vector to multiple with
  61736. * @returns resulting new vector
  61737. */
  61738. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61739. /**
  61740. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61741. * @param otherVector vector to multiple with
  61742. * @param result vector to store the result
  61743. * @returns the current Vector4.
  61744. */
  61745. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61746. /**
  61747. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61748. * @param x x value multiply with
  61749. * @param y y value multiply with
  61750. * @param z z value multiply with
  61751. * @param w w value multiply with
  61752. * @returns resulting new vector
  61753. */
  61754. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61755. /**
  61756. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61757. * @param otherVector vector to devide with
  61758. * @returns resulting new vector
  61759. */
  61760. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61761. /**
  61762. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61763. * @param otherVector vector to devide with
  61764. * @param result vector to store the result
  61765. * @returns the current Vector4.
  61766. */
  61767. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61768. /**
  61769. * Divides the current Vector3 coordinates by the given ones.
  61770. * @param otherVector vector to devide with
  61771. * @returns the updated Vector3.
  61772. */
  61773. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61774. /**
  61775. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61776. * @param other defines the second operand
  61777. * @returns the current updated Vector4
  61778. */
  61779. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61780. /**
  61781. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61782. * @param other defines the second operand
  61783. * @returns the current updated Vector4
  61784. */
  61785. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61786. /**
  61787. * Gets a new Vector4 from current Vector4 floored values
  61788. * @returns a new Vector4
  61789. */
  61790. floor(): Vector4;
  61791. /**
  61792. * Gets a new Vector4 from current Vector3 floored values
  61793. * @returns a new Vector4
  61794. */
  61795. fract(): Vector4;
  61796. /**
  61797. * Returns the Vector4 length (float).
  61798. * @returns the length
  61799. */
  61800. length(): number;
  61801. /**
  61802. * Returns the Vector4 squared length (float).
  61803. * @returns the length squared
  61804. */
  61805. lengthSquared(): number;
  61806. /**
  61807. * Normalizes in place the Vector4.
  61808. * @returns the updated Vector4.
  61809. */
  61810. normalize(): Vector4;
  61811. /**
  61812. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61813. * @returns this converted to a new vector3
  61814. */
  61815. toVector3(): Vector3;
  61816. /**
  61817. * Returns a new Vector4 copied from the current one.
  61818. * @returns the new cloned vector
  61819. */
  61820. clone(): Vector4;
  61821. /**
  61822. * Updates the current Vector4 with the given one coordinates.
  61823. * @param source the source vector to copy from
  61824. * @returns the updated Vector4.
  61825. */
  61826. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61827. /**
  61828. * Updates the current Vector4 coordinates with the given floats.
  61829. * @param x float to copy from
  61830. * @param y float to copy from
  61831. * @param z float to copy from
  61832. * @param w float to copy from
  61833. * @returns the updated Vector4.
  61834. */
  61835. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61836. /**
  61837. * Updates the current Vector4 coordinates with the given floats.
  61838. * @param x float to set from
  61839. * @param y float to set from
  61840. * @param z float to set from
  61841. * @param w float to set from
  61842. * @returns the updated Vector4.
  61843. */
  61844. set(x: number, y: number, z: number, w: number): Vector4;
  61845. /**
  61846. * Copies the given float to the current Vector3 coordinates
  61847. * @param v defines the x, y, z and w coordinates of the operand
  61848. * @returns the current updated Vector3
  61849. */
  61850. setAll(v: number): Vector4;
  61851. /**
  61852. * Returns a new Vector4 set from the starting index of the given array.
  61853. * @param array the array to pull values from
  61854. * @param offset the offset into the array to start at
  61855. * @returns the new vector
  61856. */
  61857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61858. /**
  61859. * Updates the given vector "result" from the starting index of the given array.
  61860. * @param array the array to pull values from
  61861. * @param offset the offset into the array to start at
  61862. * @param result the vector to store the result in
  61863. */
  61864. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61865. /**
  61866. * Updates the given vector "result" from the starting index of the given Float32Array.
  61867. * @param array the array to pull values from
  61868. * @param offset the offset into the array to start at
  61869. * @param result the vector to store the result in
  61870. */
  61871. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61872. /**
  61873. * Updates the given vector "result" coordinates from the given floats.
  61874. * @param x float to set from
  61875. * @param y float to set from
  61876. * @param z float to set from
  61877. * @param w float to set from
  61878. * @param result the vector to the floats in
  61879. */
  61880. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61881. /**
  61882. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61883. * @returns the new vector
  61884. */
  61885. static Zero(): Vector4;
  61886. /**
  61887. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61888. * @returns the new vector
  61889. */
  61890. static One(): Vector4;
  61891. /**
  61892. * Returns a new normalized Vector4 from the given one.
  61893. * @param vector the vector to normalize
  61894. * @returns the vector
  61895. */
  61896. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61897. /**
  61898. * Updates the given vector "result" from the normalization of the given one.
  61899. * @param vector the vector to normalize
  61900. * @param result the vector to store the result in
  61901. */
  61902. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61903. /**
  61904. * Returns a vector with the minimum values from the left and right vectors
  61905. * @param left left vector to minimize
  61906. * @param right right vector to minimize
  61907. * @returns a new vector with the minimum of the left and right vector values
  61908. */
  61909. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61910. /**
  61911. * Returns a vector with the maximum values from the left and right vectors
  61912. * @param left left vector to maximize
  61913. * @param right right vector to maximize
  61914. * @returns a new vector with the maximum of the left and right vector values
  61915. */
  61916. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61917. /**
  61918. * Returns the distance (float) between the vectors "value1" and "value2".
  61919. * @param value1 value to calulate the distance between
  61920. * @param value2 value to calulate the distance between
  61921. * @return the distance between the two vectors
  61922. */
  61923. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61924. /**
  61925. * Returns the squared distance (float) between the vectors "value1" and "value2".
  61926. * @param value1 value to calulate the distance between
  61927. * @param value2 value to calulate the distance between
  61928. * @return the distance between the two vectors squared
  61929. */
  61930. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61931. /**
  61932. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  61933. * @param value1 value to calulate the center between
  61934. * @param value2 value to calulate the center between
  61935. * @return the center between the two vectors
  61936. */
  61937. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  61938. /**
  61939. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  61940. * This methods computes transformed normalized direction vectors only.
  61941. * @param vector the vector to transform
  61942. * @param transformation the transformation matrix to apply
  61943. * @returns the new vector
  61944. */
  61945. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  61946. /**
  61947. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  61948. * This methods computes transformed normalized direction vectors only.
  61949. * @param vector the vector to transform
  61950. * @param transformation the transformation matrix to apply
  61951. * @param result the vector to store the result in
  61952. */
  61953. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61954. /**
  61955. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  61956. * This methods computes transformed normalized direction vectors only.
  61957. * @param x value to transform
  61958. * @param y value to transform
  61959. * @param z value to transform
  61960. * @param w value to transform
  61961. * @param transformation the transformation matrix to apply
  61962. * @param result the vector to store the results in
  61963. */
  61964. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61965. /**
  61966. * Creates a new Vector4 from a Vector3
  61967. * @param source defines the source data
  61968. * @param w defines the 4th component (default is 0)
  61969. * @returns a new Vector4
  61970. */
  61971. static FromVector3(source: Vector3, w?: number): Vector4;
  61972. }
  61973. /**
  61974. * Interface for the size containing width and height
  61975. */
  61976. export interface ISize {
  61977. /**
  61978. * Width
  61979. */
  61980. width: number;
  61981. /**
  61982. * Heighht
  61983. */
  61984. height: number;
  61985. }
  61986. /**
  61987. * Size containing widht and height
  61988. */
  61989. export class Size implements ISize {
  61990. /**
  61991. * Width
  61992. */
  61993. width: number;
  61994. /**
  61995. * Height
  61996. */
  61997. height: number;
  61998. /**
  61999. * Creates a Size object from the given width and height (floats).
  62000. * @param width width of the new size
  62001. * @param height height of the new size
  62002. */
  62003. constructor(width: number, height: number);
  62004. /**
  62005. * Returns a string with the Size width and height
  62006. * @returns a string with the Size width and height
  62007. */
  62008. toString(): string;
  62009. /**
  62010. * "Size"
  62011. * @returns the string "Size"
  62012. */
  62013. getClassName(): string;
  62014. /**
  62015. * Returns the Size hash code.
  62016. * @returns a hash code for a unique width and height
  62017. */
  62018. getHashCode(): number;
  62019. /**
  62020. * Updates the current size from the given one.
  62021. * @param src the given size
  62022. */
  62023. copyFrom(src: Size): void;
  62024. /**
  62025. * Updates in place the current Size from the given floats.
  62026. * @param width width of the new size
  62027. * @param height height of the new size
  62028. * @returns the updated Size.
  62029. */
  62030. copyFromFloats(width: number, height: number): Size;
  62031. /**
  62032. * Updates in place the current Size from the given floats.
  62033. * @param width width to set
  62034. * @param height height to set
  62035. * @returns the updated Size.
  62036. */
  62037. set(width: number, height: number): Size;
  62038. /**
  62039. * Multiplies the width and height by numbers
  62040. * @param w factor to multiple the width by
  62041. * @param h factor to multiple the height by
  62042. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62043. */
  62044. multiplyByFloats(w: number, h: number): Size;
  62045. /**
  62046. * Clones the size
  62047. * @returns a new Size copied from the given one.
  62048. */
  62049. clone(): Size;
  62050. /**
  62051. * True if the current Size and the given one width and height are strictly equal.
  62052. * @param other the other size to compare against
  62053. * @returns True if the current Size and the given one width and height are strictly equal.
  62054. */
  62055. equals(other: Size): boolean;
  62056. /**
  62057. * The surface of the Size : width * height (float).
  62058. */
  62059. readonly surface: number;
  62060. /**
  62061. * Create a new size of zero
  62062. * @returns a new Size set to (0.0, 0.0)
  62063. */
  62064. static Zero(): Size;
  62065. /**
  62066. * Sums the width and height of two sizes
  62067. * @param otherSize size to add to this size
  62068. * @returns a new Size set as the addition result of the current Size and the given one.
  62069. */
  62070. add(otherSize: Size): Size;
  62071. /**
  62072. * Subtracts the width and height of two
  62073. * @param otherSize size to subtract to this size
  62074. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62075. */
  62076. subtract(otherSize: Size): Size;
  62077. /**
  62078. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62079. * @param start starting size to lerp between
  62080. * @param end end size to lerp between
  62081. * @param amount amount to lerp between the start and end values
  62082. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62083. */
  62084. static Lerp(start: Size, end: Size, amount: number): Size;
  62085. }
  62086. /**
  62087. * Class used to store quaternion data
  62088. * @see https://en.wikipedia.org/wiki/Quaternion
  62089. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62090. */
  62091. export class Quaternion {
  62092. /** defines the first component (0 by default) */
  62093. x: number;
  62094. /** defines the second component (0 by default) */
  62095. y: number;
  62096. /** defines the third component (0 by default) */
  62097. z: number;
  62098. /** defines the fourth component (1.0 by default) */
  62099. w: number;
  62100. /**
  62101. * Creates a new Quaternion from the given floats
  62102. * @param x defines the first component (0 by default)
  62103. * @param y defines the second component (0 by default)
  62104. * @param z defines the third component (0 by default)
  62105. * @param w defines the fourth component (1.0 by default)
  62106. */
  62107. constructor(
  62108. /** defines the first component (0 by default) */
  62109. x?: number,
  62110. /** defines the second component (0 by default) */
  62111. y?: number,
  62112. /** defines the third component (0 by default) */
  62113. z?: number,
  62114. /** defines the fourth component (1.0 by default) */
  62115. w?: number);
  62116. /**
  62117. * Gets a string representation for the current quaternion
  62118. * @returns a string with the Quaternion coordinates
  62119. */
  62120. toString(): string;
  62121. /**
  62122. * Gets the class name of the quaternion
  62123. * @returns the string "Quaternion"
  62124. */
  62125. getClassName(): string;
  62126. /**
  62127. * Gets a hash code for this quaternion
  62128. * @returns the quaternion hash code
  62129. */
  62130. getHashCode(): number;
  62131. /**
  62132. * Copy the quaternion to an array
  62133. * @returns a new array populated with 4 elements from the quaternion coordinates
  62134. */
  62135. asArray(): number[];
  62136. /**
  62137. * Check if two quaternions are equals
  62138. * @param otherQuaternion defines the second operand
  62139. * @return true if the current quaternion and the given one coordinates are strictly equals
  62140. */
  62141. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62142. /**
  62143. * Clone the current quaternion
  62144. * @returns a new quaternion copied from the current one
  62145. */
  62146. clone(): Quaternion;
  62147. /**
  62148. * Copy a quaternion to the current one
  62149. * @param other defines the other quaternion
  62150. * @returns the updated current quaternion
  62151. */
  62152. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62153. /**
  62154. * Updates the current quaternion with the given float coordinates
  62155. * @param x defines the x coordinate
  62156. * @param y defines the y coordinate
  62157. * @param z defines the z coordinate
  62158. * @param w defines the w coordinate
  62159. * @returns the updated current quaternion
  62160. */
  62161. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62162. /**
  62163. * Updates the current quaternion from the given float coordinates
  62164. * @param x defines the x coordinate
  62165. * @param y defines the y coordinate
  62166. * @param z defines the z coordinate
  62167. * @param w defines the w coordinate
  62168. * @returns the updated current quaternion
  62169. */
  62170. set(x: number, y: number, z: number, w: number): Quaternion;
  62171. /**
  62172. * Adds two quaternions
  62173. * @param other defines the second operand
  62174. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62175. */
  62176. add(other: DeepImmutable<Quaternion>): Quaternion;
  62177. /**
  62178. * Add a quaternion to the current one
  62179. * @param other defines the quaternion to add
  62180. * @returns the current quaternion
  62181. */
  62182. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62183. /**
  62184. * Subtract two quaternions
  62185. * @param other defines the second operand
  62186. * @returns a new quaternion as the subtraction result of the given one from the current one
  62187. */
  62188. subtract(other: Quaternion): Quaternion;
  62189. /**
  62190. * Multiplies the current quaternion by a scale factor
  62191. * @param value defines the scale factor
  62192. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62193. */
  62194. scale(value: number): Quaternion;
  62195. /**
  62196. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62197. * @param scale defines the scale factor
  62198. * @param result defines the Quaternion object where to store the result
  62199. * @returns the unmodified current quaternion
  62200. */
  62201. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62202. /**
  62203. * Multiplies in place the current quaternion by a scale factor
  62204. * @param value defines the scale factor
  62205. * @returns the current modified quaternion
  62206. */
  62207. scaleInPlace(value: number): Quaternion;
  62208. /**
  62209. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62210. * @param scale defines the scale factor
  62211. * @param result defines the Quaternion object where to store the result
  62212. * @returns the unmodified current quaternion
  62213. */
  62214. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62215. /**
  62216. * Multiplies two quaternions
  62217. * @param q1 defines the second operand
  62218. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62219. */
  62220. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62221. /**
  62222. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62223. * @param q1 defines the second operand
  62224. * @param result defines the target quaternion
  62225. * @returns the current quaternion
  62226. */
  62227. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62228. /**
  62229. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62230. * @param q1 defines the second operand
  62231. * @returns the currentupdated quaternion
  62232. */
  62233. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62234. /**
  62235. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62236. * @param ref defines the target quaternion
  62237. * @returns the current quaternion
  62238. */
  62239. conjugateToRef(ref: Quaternion): Quaternion;
  62240. /**
  62241. * Conjugates in place (1-q) the current quaternion
  62242. * @returns the current updated quaternion
  62243. */
  62244. conjugateInPlace(): Quaternion;
  62245. /**
  62246. * Conjugates in place (1-q) the current quaternion
  62247. * @returns a new quaternion
  62248. */
  62249. conjugate(): Quaternion;
  62250. /**
  62251. * Gets length of current quaternion
  62252. * @returns the quaternion length (float)
  62253. */
  62254. length(): number;
  62255. /**
  62256. * Normalize in place the current quaternion
  62257. * @returns the current updated quaternion
  62258. */
  62259. normalize(): Quaternion;
  62260. /**
  62261. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62262. * @param order is a reserved parameter and is ignore for now
  62263. * @returns a new Vector3 containing the Euler angles
  62264. */
  62265. toEulerAngles(order?: string): Vector3;
  62266. /**
  62267. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62268. * @param result defines the vector which will be filled with the Euler angles
  62269. * @param order is a reserved parameter and is ignore for now
  62270. * @returns the current unchanged quaternion
  62271. */
  62272. toEulerAnglesToRef(result: Vector3): Quaternion;
  62273. /**
  62274. * Updates the given rotation matrix with the current quaternion values
  62275. * @param result defines the target matrix
  62276. * @returns the current unchanged quaternion
  62277. */
  62278. toRotationMatrix(result: Matrix): Quaternion;
  62279. /**
  62280. * Updates the current quaternion from the given rotation matrix values
  62281. * @param matrix defines the source matrix
  62282. * @returns the current updated quaternion
  62283. */
  62284. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62285. /**
  62286. * Creates a new quaternion from a rotation matrix
  62287. * @param matrix defines the source matrix
  62288. * @returns a new quaternion created from the given rotation matrix values
  62289. */
  62290. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62291. /**
  62292. * Updates the given quaternion with the given rotation matrix values
  62293. * @param matrix defines the source matrix
  62294. * @param result defines the target quaternion
  62295. */
  62296. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62297. /**
  62298. * Returns the dot product (float) between the quaternions "left" and "right"
  62299. * @param left defines the left operand
  62300. * @param right defines the right operand
  62301. * @returns the dot product
  62302. */
  62303. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62304. /**
  62305. * Checks if the two quaternions are close to each other
  62306. * @param quat0 defines the first quaternion to check
  62307. * @param quat1 defines the second quaternion to check
  62308. * @returns true if the two quaternions are close to each other
  62309. */
  62310. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62311. /**
  62312. * Creates an empty quaternion
  62313. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62314. */
  62315. static Zero(): Quaternion;
  62316. /**
  62317. * Inverse a given quaternion
  62318. * @param q defines the source quaternion
  62319. * @returns a new quaternion as the inverted current quaternion
  62320. */
  62321. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62322. /**
  62323. * Inverse a given quaternion
  62324. * @param q defines the source quaternion
  62325. * @param result the quaternion the result will be stored in
  62326. * @returns the result quaternion
  62327. */
  62328. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62329. /**
  62330. * Creates an identity quaternion
  62331. * @returns the identity quaternion
  62332. */
  62333. static Identity(): Quaternion;
  62334. /**
  62335. * Gets a boolean indicating if the given quaternion is identity
  62336. * @param quaternion defines the quaternion to check
  62337. * @returns true if the quaternion is identity
  62338. */
  62339. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62340. /**
  62341. * Creates a quaternion from a rotation around an axis
  62342. * @param axis defines the axis to use
  62343. * @param angle defines the angle to use
  62344. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62345. */
  62346. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62347. /**
  62348. * Creates a rotation around an axis and stores it into the given quaternion
  62349. * @param axis defines the axis to use
  62350. * @param angle defines the angle to use
  62351. * @param result defines the target quaternion
  62352. * @returns the target quaternion
  62353. */
  62354. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62355. /**
  62356. * Creates a new quaternion from data stored into an array
  62357. * @param array defines the data source
  62358. * @param offset defines the offset in the source array where the data starts
  62359. * @returns a new quaternion
  62360. */
  62361. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62362. /**
  62363. * Create a quaternion from Euler rotation angles
  62364. * @param x Pitch
  62365. * @param y Yaw
  62366. * @param z Roll
  62367. * @returns the new Quaternion
  62368. */
  62369. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62370. /**
  62371. * Updates a quaternion from Euler rotation angles
  62372. * @param x Pitch
  62373. * @param y Yaw
  62374. * @param z Roll
  62375. * @param result the quaternion to store the result
  62376. * @returns the updated quaternion
  62377. */
  62378. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62379. /**
  62380. * Create a quaternion from Euler rotation vector
  62381. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62382. * @returns the new Quaternion
  62383. */
  62384. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62385. /**
  62386. * Updates a quaternion from Euler rotation vector
  62387. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62388. * @param result the quaternion to store the result
  62389. * @returns the updated quaternion
  62390. */
  62391. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62392. /**
  62393. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62394. * @param yaw defines the rotation around Y axis
  62395. * @param pitch defines the rotation around X axis
  62396. * @param roll defines the rotation around Z axis
  62397. * @returns the new quaternion
  62398. */
  62399. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62400. /**
  62401. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62402. * @param yaw defines the rotation around Y axis
  62403. * @param pitch defines the rotation around X axis
  62404. * @param roll defines the rotation around Z axis
  62405. * @param result defines the target quaternion
  62406. */
  62407. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62408. /**
  62409. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62410. * @param alpha defines the rotation around first axis
  62411. * @param beta defines the rotation around second axis
  62412. * @param gamma defines the rotation around third axis
  62413. * @returns the new quaternion
  62414. */
  62415. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62416. /**
  62417. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62418. * @param alpha defines the rotation around first axis
  62419. * @param beta defines the rotation around second axis
  62420. * @param gamma defines the rotation around third axis
  62421. * @param result defines the target quaternion
  62422. */
  62423. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62424. /**
  62425. * 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)
  62426. * @param axis1 defines the first axis
  62427. * @param axis2 defines the second axis
  62428. * @param axis3 defines the third axis
  62429. * @returns the new quaternion
  62430. */
  62431. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62432. /**
  62433. * 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
  62434. * @param axis1 defines the first axis
  62435. * @param axis2 defines the second axis
  62436. * @param axis3 defines the third axis
  62437. * @param ref defines the target quaternion
  62438. */
  62439. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62440. /**
  62441. * Interpolates between two quaternions
  62442. * @param left defines first quaternion
  62443. * @param right defines second quaternion
  62444. * @param amount defines the gradient to use
  62445. * @returns the new interpolated quaternion
  62446. */
  62447. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62448. /**
  62449. * Interpolates between two quaternions and stores it into a target quaternion
  62450. * @param left defines first quaternion
  62451. * @param right defines second quaternion
  62452. * @param amount defines the gradient to use
  62453. * @param result defines the target quaternion
  62454. */
  62455. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62456. /**
  62457. * Interpolate between two quaternions using Hermite interpolation
  62458. * @param value1 defines first quaternion
  62459. * @param tangent1 defines the incoming tangent
  62460. * @param value2 defines second quaternion
  62461. * @param tangent2 defines the outgoing tangent
  62462. * @param amount defines the target quaternion
  62463. * @returns the new interpolated quaternion
  62464. */
  62465. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62466. }
  62467. /**
  62468. * Class used to store matrix data (4x4)
  62469. */
  62470. export class Matrix {
  62471. private static _updateFlagSeed;
  62472. private static _identityReadOnly;
  62473. private _isIdentity;
  62474. private _isIdentityDirty;
  62475. private _isIdentity3x2;
  62476. private _isIdentity3x2Dirty;
  62477. /**
  62478. * Gets the update flag of the matrix which is an unique number for the matrix.
  62479. * It will be incremented every time the matrix data change.
  62480. * You can use it to speed the comparison between two versions of the same matrix.
  62481. */
  62482. updateFlag: number;
  62483. private readonly _m;
  62484. /**
  62485. * Gets the internal data of the matrix
  62486. */
  62487. readonly m: DeepImmutable<Float32Array>;
  62488. /** @hidden */
  62489. _markAsUpdated(): void;
  62490. /** @hidden */
  62491. private _updateIdentityStatus;
  62492. /**
  62493. * Creates an empty matrix (filled with zeros)
  62494. */
  62495. constructor();
  62496. /**
  62497. * Check if the current matrix is identity
  62498. * @returns true is the matrix is the identity matrix
  62499. */
  62500. isIdentity(): boolean;
  62501. /**
  62502. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62503. * @returns true is the matrix is the identity matrix
  62504. */
  62505. isIdentityAs3x2(): boolean;
  62506. /**
  62507. * Gets the determinant of the matrix
  62508. * @returns the matrix determinant
  62509. */
  62510. determinant(): number;
  62511. /**
  62512. * Returns the matrix as a Float32Array
  62513. * @returns the matrix underlying array
  62514. */
  62515. toArray(): DeepImmutable<Float32Array>;
  62516. /**
  62517. * Returns the matrix as a Float32Array
  62518. * @returns the matrix underlying array.
  62519. */
  62520. asArray(): DeepImmutable<Float32Array>;
  62521. /**
  62522. * Inverts the current matrix in place
  62523. * @returns the current inverted matrix
  62524. */
  62525. invert(): Matrix;
  62526. /**
  62527. * Sets all the matrix elements to zero
  62528. * @returns the current matrix
  62529. */
  62530. reset(): Matrix;
  62531. /**
  62532. * Adds the current matrix with a second one
  62533. * @param other defines the matrix to add
  62534. * @returns a new matrix as the addition of the current matrix and the given one
  62535. */
  62536. add(other: DeepImmutable<Matrix>): Matrix;
  62537. /**
  62538. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62539. * @param other defines the matrix to add
  62540. * @param result defines the target matrix
  62541. * @returns the current matrix
  62542. */
  62543. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62544. /**
  62545. * Adds in place the given matrix to the current matrix
  62546. * @param other defines the second operand
  62547. * @returns the current updated matrix
  62548. */
  62549. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62550. /**
  62551. * Sets the given matrix to the current inverted Matrix
  62552. * @param other defines the target matrix
  62553. * @returns the unmodified current matrix
  62554. */
  62555. invertToRef(other: Matrix): Matrix;
  62556. /**
  62557. * add a value at the specified position in the current Matrix
  62558. * @param index the index of the value within the matrix. between 0 and 15.
  62559. * @param value the value to be added
  62560. * @returns the current updated matrix
  62561. */
  62562. addAtIndex(index: number, value: number): Matrix;
  62563. /**
  62564. * mutiply the specified position in the current Matrix by a value
  62565. * @param index the index of the value within the matrix. between 0 and 15.
  62566. * @param value the value to be added
  62567. * @returns the current updated matrix
  62568. */
  62569. multiplyAtIndex(index: number, value: number): Matrix;
  62570. /**
  62571. * Inserts the translation vector (using 3 floats) in the current matrix
  62572. * @param x defines the 1st component of the translation
  62573. * @param y defines the 2nd component of the translation
  62574. * @param z defines the 3rd component of the translation
  62575. * @returns the current updated matrix
  62576. */
  62577. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62578. /**
  62579. * Adds the translation vector (using 3 floats) in the current matrix
  62580. * @param x defines the 1st component of the translation
  62581. * @param y defines the 2nd component of the translation
  62582. * @param z defines the 3rd component of the translation
  62583. * @returns the current updated matrix
  62584. */
  62585. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62586. /**
  62587. * Inserts the translation vector in the current matrix
  62588. * @param vector3 defines the translation to insert
  62589. * @returns the current updated matrix
  62590. */
  62591. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62592. /**
  62593. * Gets the translation value of the current matrix
  62594. * @returns a new Vector3 as the extracted translation from the matrix
  62595. */
  62596. getTranslation(): Vector3;
  62597. /**
  62598. * Fill a Vector3 with the extracted translation from the matrix
  62599. * @param result defines the Vector3 where to store the translation
  62600. * @returns the current matrix
  62601. */
  62602. getTranslationToRef(result: Vector3): Matrix;
  62603. /**
  62604. * Remove rotation and scaling part from the matrix
  62605. * @returns the updated matrix
  62606. */
  62607. removeRotationAndScaling(): Matrix;
  62608. /**
  62609. * Multiply two matrices
  62610. * @param other defines the second operand
  62611. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62612. */
  62613. multiply(other: DeepImmutable<Matrix>): Matrix;
  62614. /**
  62615. * Copy the current matrix from the given one
  62616. * @param other defines the source matrix
  62617. * @returns the current updated matrix
  62618. */
  62619. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62620. /**
  62621. * Populates the given array from the starting index with the current matrix values
  62622. * @param array defines the target array
  62623. * @param offset defines the offset in the target array where to start storing values
  62624. * @returns the current matrix
  62625. */
  62626. copyToArray(array: Float32Array, offset?: number): Matrix;
  62627. /**
  62628. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62629. * @param other defines the second operand
  62630. * @param result defines the matrix where to store the multiplication
  62631. * @returns the current matrix
  62632. */
  62633. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62634. /**
  62635. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62636. * @param other defines the second operand
  62637. * @param result defines the array where to store the multiplication
  62638. * @param offset defines the offset in the target array where to start storing values
  62639. * @returns the current matrix
  62640. */
  62641. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62642. /**
  62643. * Check equality between this matrix and a second one
  62644. * @param value defines the second matrix to compare
  62645. * @returns true is the current matrix and the given one values are strictly equal
  62646. */
  62647. equals(value: DeepImmutable<Matrix>): boolean;
  62648. /**
  62649. * Clone the current matrix
  62650. * @returns a new matrix from the current matrix
  62651. */
  62652. clone(): Matrix;
  62653. /**
  62654. * Returns the name of the current matrix class
  62655. * @returns the string "Matrix"
  62656. */
  62657. getClassName(): string;
  62658. /**
  62659. * Gets the hash code of the current matrix
  62660. * @returns the hash code
  62661. */
  62662. getHashCode(): number;
  62663. /**
  62664. * Decomposes the current Matrix into a translation, rotation and scaling components
  62665. * @param scale defines the scale vector3 given as a reference to update
  62666. * @param rotation defines the rotation quaternion given as a reference to update
  62667. * @param translation defines the translation vector3 given as a reference to update
  62668. * @returns true if operation was successful
  62669. */
  62670. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62671. /**
  62672. * Gets specific row of the matrix
  62673. * @param index defines the number of the row to get
  62674. * @returns the index-th row of the current matrix as a new Vector4
  62675. */
  62676. getRow(index: number): Nullable<Vector4>;
  62677. /**
  62678. * Sets the index-th row of the current matrix to the vector4 values
  62679. * @param index defines the number of the row to set
  62680. * @param row defines the target vector4
  62681. * @returns the updated current matrix
  62682. */
  62683. setRow(index: number, row: Vector4): Matrix;
  62684. /**
  62685. * Compute the transpose of the matrix
  62686. * @returns the new transposed matrix
  62687. */
  62688. transpose(): Matrix;
  62689. /**
  62690. * Compute the transpose of the matrix and store it in a given matrix
  62691. * @param result defines the target matrix
  62692. * @returns the current matrix
  62693. */
  62694. transposeToRef(result: Matrix): Matrix;
  62695. /**
  62696. * Sets the index-th row of the current matrix with the given 4 x float values
  62697. * @param index defines the row index
  62698. * @param x defines the x component to set
  62699. * @param y defines the y component to set
  62700. * @param z defines the z component to set
  62701. * @param w defines the w component to set
  62702. * @returns the updated current matrix
  62703. */
  62704. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62705. /**
  62706. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62707. * @param scale defines the scale factor
  62708. * @returns a new matrix
  62709. */
  62710. scale(scale: number): Matrix;
  62711. /**
  62712. * Scale the current matrix values by a factor to a given result matrix
  62713. * @param scale defines the scale factor
  62714. * @param result defines the matrix to store the result
  62715. * @returns the current matrix
  62716. */
  62717. scaleToRef(scale: number, result: Matrix): Matrix;
  62718. /**
  62719. * Scale the current matrix values by a factor and add the result to a given matrix
  62720. * @param scale defines the scale factor
  62721. * @param result defines the Matrix to store the result
  62722. * @returns the current matrix
  62723. */
  62724. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62725. /**
  62726. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62727. * @param ref matrix to store the result
  62728. */
  62729. toNormalMatrix(ref: Matrix): void;
  62730. /**
  62731. * Gets only rotation part of the current matrix
  62732. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62733. */
  62734. getRotationMatrix(): Matrix;
  62735. /**
  62736. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62737. * @param result defines the target matrix to store data to
  62738. * @returns the current matrix
  62739. */
  62740. getRotationMatrixToRef(result: Matrix): Matrix;
  62741. /**
  62742. * Toggles model matrix from being right handed to left handed in place and vice versa
  62743. */
  62744. toggleModelMatrixHandInPlace(): void;
  62745. /**
  62746. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62747. */
  62748. toggleProjectionMatrixHandInPlace(): void;
  62749. /**
  62750. * Creates a matrix from an array
  62751. * @param array defines the source array
  62752. * @param offset defines an offset in the source array
  62753. * @returns a new Matrix set from the starting index of the given array
  62754. */
  62755. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62756. /**
  62757. * Copy the content of an array into a given matrix
  62758. * @param array defines the source array
  62759. * @param offset defines an offset in the source array
  62760. * @param result defines the target matrix
  62761. */
  62762. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62763. /**
  62764. * Stores an array into a matrix after having multiplied each component by a given factor
  62765. * @param array defines the source array
  62766. * @param offset defines the offset in the source array
  62767. * @param scale defines the scaling factor
  62768. * @param result defines the target matrix
  62769. */
  62770. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62771. /**
  62772. * Gets an identity matrix that must not be updated
  62773. */
  62774. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62775. /**
  62776. * Stores a list of values (16) inside a given matrix
  62777. * @param initialM11 defines 1st value of 1st row
  62778. * @param initialM12 defines 2nd value of 1st row
  62779. * @param initialM13 defines 3rd value of 1st row
  62780. * @param initialM14 defines 4th value of 1st row
  62781. * @param initialM21 defines 1st value of 2nd row
  62782. * @param initialM22 defines 2nd value of 2nd row
  62783. * @param initialM23 defines 3rd value of 2nd row
  62784. * @param initialM24 defines 4th value of 2nd row
  62785. * @param initialM31 defines 1st value of 3rd row
  62786. * @param initialM32 defines 2nd value of 3rd row
  62787. * @param initialM33 defines 3rd value of 3rd row
  62788. * @param initialM34 defines 4th value of 3rd row
  62789. * @param initialM41 defines 1st value of 4th row
  62790. * @param initialM42 defines 2nd value of 4th row
  62791. * @param initialM43 defines 3rd value of 4th row
  62792. * @param initialM44 defines 4th value of 4th row
  62793. * @param result defines the target matrix
  62794. */
  62795. 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;
  62796. /**
  62797. * Creates new matrix from a list of values (16)
  62798. * @param initialM11 defines 1st value of 1st row
  62799. * @param initialM12 defines 2nd value of 1st row
  62800. * @param initialM13 defines 3rd value of 1st row
  62801. * @param initialM14 defines 4th value of 1st row
  62802. * @param initialM21 defines 1st value of 2nd row
  62803. * @param initialM22 defines 2nd value of 2nd row
  62804. * @param initialM23 defines 3rd value of 2nd row
  62805. * @param initialM24 defines 4th value of 2nd row
  62806. * @param initialM31 defines 1st value of 3rd row
  62807. * @param initialM32 defines 2nd value of 3rd row
  62808. * @param initialM33 defines 3rd value of 3rd row
  62809. * @param initialM34 defines 4th value of 3rd row
  62810. * @param initialM41 defines 1st value of 4th row
  62811. * @param initialM42 defines 2nd value of 4th row
  62812. * @param initialM43 defines 3rd value of 4th row
  62813. * @param initialM44 defines 4th value of 4th row
  62814. * @returns the new matrix
  62815. */
  62816. 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;
  62817. /**
  62818. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62819. * @param scale defines the scale vector3
  62820. * @param rotation defines the rotation quaternion
  62821. * @param translation defines the translation vector3
  62822. * @returns a new matrix
  62823. */
  62824. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62825. /**
  62826. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62827. * @param scale defines the scale vector3
  62828. * @param rotation defines the rotation quaternion
  62829. * @param translation defines the translation vector3
  62830. * @param result defines the target matrix
  62831. */
  62832. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62833. /**
  62834. * Creates a new identity matrix
  62835. * @returns a new identity matrix
  62836. */
  62837. static Identity(): Matrix;
  62838. /**
  62839. * Creates a new identity matrix and stores the result in a given matrix
  62840. * @param result defines the target matrix
  62841. */
  62842. static IdentityToRef(result: Matrix): void;
  62843. /**
  62844. * Creates a new zero matrix
  62845. * @returns a new zero matrix
  62846. */
  62847. static Zero(): Matrix;
  62848. /**
  62849. * Creates a new rotation matrix for "angle" radians around the X axis
  62850. * @param angle defines the angle (in radians) to use
  62851. * @return the new matrix
  62852. */
  62853. static RotationX(angle: number): Matrix;
  62854. /**
  62855. * Creates a new matrix as the invert of a given matrix
  62856. * @param source defines the source matrix
  62857. * @returns the new matrix
  62858. */
  62859. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62860. /**
  62861. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62862. * @param angle defines the angle (in radians) to use
  62863. * @param result defines the target matrix
  62864. */
  62865. static RotationXToRef(angle: number, result: Matrix): void;
  62866. /**
  62867. * Creates a new rotation matrix for "angle" radians around the Y axis
  62868. * @param angle defines the angle (in radians) to use
  62869. * @return the new matrix
  62870. */
  62871. static RotationY(angle: number): Matrix;
  62872. /**
  62873. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62874. * @param angle defines the angle (in radians) to use
  62875. * @param result defines the target matrix
  62876. */
  62877. static RotationYToRef(angle: number, result: Matrix): void;
  62878. /**
  62879. * Creates a new rotation matrix for "angle" radians around the Z axis
  62880. * @param angle defines the angle (in radians) to use
  62881. * @return the new matrix
  62882. */
  62883. static RotationZ(angle: number): Matrix;
  62884. /**
  62885. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62886. * @param angle defines the angle (in radians) to use
  62887. * @param result defines the target matrix
  62888. */
  62889. static RotationZToRef(angle: number, result: Matrix): void;
  62890. /**
  62891. * Creates a new rotation matrix for "angle" radians around the given axis
  62892. * @param axis defines the axis to use
  62893. * @param angle defines the angle (in radians) to use
  62894. * @return the new matrix
  62895. */
  62896. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62897. /**
  62898. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62899. * @param axis defines the axis to use
  62900. * @param angle defines the angle (in radians) to use
  62901. * @param result defines the target matrix
  62902. */
  62903. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62904. /**
  62905. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  62906. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  62907. * @param from defines the vector to align
  62908. * @param to defines the vector to align to
  62909. * @param result defines the target matrix
  62910. */
  62911. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  62912. /**
  62913. * Creates a rotation matrix
  62914. * @param yaw defines the yaw angle in radians (Y axis)
  62915. * @param pitch defines the pitch angle in radians (X axis)
  62916. * @param roll defines the roll angle in radians (X axis)
  62917. * @returns the new rotation matrix
  62918. */
  62919. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  62920. /**
  62921. * Creates a rotation matrix and stores it in a given matrix
  62922. * @param yaw defines the yaw angle in radians (Y axis)
  62923. * @param pitch defines the pitch angle in radians (X axis)
  62924. * @param roll defines the roll angle in radians (X axis)
  62925. * @param result defines the target matrix
  62926. */
  62927. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  62928. /**
  62929. * Creates a scaling matrix
  62930. * @param x defines the scale factor on X axis
  62931. * @param y defines the scale factor on Y axis
  62932. * @param z defines the scale factor on Z axis
  62933. * @returns the new matrix
  62934. */
  62935. static Scaling(x: number, y: number, z: number): Matrix;
  62936. /**
  62937. * Creates a scaling matrix and stores it in a given matrix
  62938. * @param x defines the scale factor on X axis
  62939. * @param y defines the scale factor on Y axis
  62940. * @param z defines the scale factor on Z axis
  62941. * @param result defines the target matrix
  62942. */
  62943. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  62944. /**
  62945. * Creates a translation matrix
  62946. * @param x defines the translation on X axis
  62947. * @param y defines the translation on Y axis
  62948. * @param z defines the translationon Z axis
  62949. * @returns the new matrix
  62950. */
  62951. static Translation(x: number, y: number, z: number): Matrix;
  62952. /**
  62953. * Creates a translation matrix and stores it in a given matrix
  62954. * @param x defines the translation on X axis
  62955. * @param y defines the translation on Y axis
  62956. * @param z defines the translationon Z axis
  62957. * @param result defines the target matrix
  62958. */
  62959. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  62960. /**
  62961. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62962. * @param startValue defines the start value
  62963. * @param endValue defines the end value
  62964. * @param gradient defines the gradient factor
  62965. * @returns the new matrix
  62966. */
  62967. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62968. /**
  62969. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62970. * @param startValue defines the start value
  62971. * @param endValue defines the end value
  62972. * @param gradient defines the gradient factor
  62973. * @param result defines the Matrix object where to store data
  62974. */
  62975. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62976. /**
  62977. * Builds a new matrix whose values are computed by:
  62978. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62979. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62980. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62981. * @param startValue defines the first matrix
  62982. * @param endValue defines the second matrix
  62983. * @param gradient defines the gradient between the two matrices
  62984. * @returns the new matrix
  62985. */
  62986. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62987. /**
  62988. * Update a matrix to values which are computed by:
  62989. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62990. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62991. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62992. * @param startValue defines the first matrix
  62993. * @param endValue defines the second matrix
  62994. * @param gradient defines the gradient between the two matrices
  62995. * @param result defines the target matrix
  62996. */
  62997. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62998. /**
  62999. * 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"
  63000. * This function works in left handed mode
  63001. * @param eye defines the final position of the entity
  63002. * @param target defines where the entity should look at
  63003. * @param up defines the up vector for the entity
  63004. * @returns the new matrix
  63005. */
  63006. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63007. /**
  63008. * 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".
  63009. * This function works in left handed mode
  63010. * @param eye defines the final position of the entity
  63011. * @param target defines where the entity should look at
  63012. * @param up defines the up vector for the entity
  63013. * @param result defines the target matrix
  63014. */
  63015. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63016. /**
  63017. * 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"
  63018. * This function works in right handed mode
  63019. * @param eye defines the final position of the entity
  63020. * @param target defines where the entity should look at
  63021. * @param up defines the up vector for the entity
  63022. * @returns the new matrix
  63023. */
  63024. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63025. /**
  63026. * 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".
  63027. * This function works in right handed mode
  63028. * @param eye defines the final position of the entity
  63029. * @param target defines where the entity should look at
  63030. * @param up defines the up vector for the entity
  63031. * @param result defines the target matrix
  63032. */
  63033. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63034. /**
  63035. * Create a left-handed orthographic projection matrix
  63036. * @param width defines the viewport width
  63037. * @param height defines the viewport height
  63038. * @param znear defines the near clip plane
  63039. * @param zfar defines the far clip plane
  63040. * @returns a new matrix as a left-handed orthographic projection matrix
  63041. */
  63042. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63043. /**
  63044. * Store a left-handed orthographic projection to a given matrix
  63045. * @param width defines the viewport width
  63046. * @param height defines the viewport height
  63047. * @param znear defines the near clip plane
  63048. * @param zfar defines the far clip plane
  63049. * @param result defines the target matrix
  63050. */
  63051. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63052. /**
  63053. * Create a left-handed orthographic projection matrix
  63054. * @param left defines the viewport left coordinate
  63055. * @param right defines the viewport right coordinate
  63056. * @param bottom defines the viewport bottom coordinate
  63057. * @param top defines the viewport top coordinate
  63058. * @param znear defines the near clip plane
  63059. * @param zfar defines the far clip plane
  63060. * @returns a new matrix as a left-handed orthographic projection matrix
  63061. */
  63062. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63063. /**
  63064. * Stores a left-handed orthographic projection into a given matrix
  63065. * @param left defines the viewport left coordinate
  63066. * @param right defines the viewport right coordinate
  63067. * @param bottom defines the viewport bottom coordinate
  63068. * @param top defines the viewport top coordinate
  63069. * @param znear defines the near clip plane
  63070. * @param zfar defines the far clip plane
  63071. * @param result defines the target matrix
  63072. */
  63073. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63074. /**
  63075. * Creates a right-handed orthographic projection matrix
  63076. * @param left defines the viewport left coordinate
  63077. * @param right defines the viewport right coordinate
  63078. * @param bottom defines the viewport bottom coordinate
  63079. * @param top defines the viewport top coordinate
  63080. * @param znear defines the near clip plane
  63081. * @param zfar defines the far clip plane
  63082. * @returns a new matrix as a right-handed orthographic projection matrix
  63083. */
  63084. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63085. /**
  63086. * Stores a right-handed orthographic projection into a given matrix
  63087. * @param left defines the viewport left coordinate
  63088. * @param right defines the viewport right coordinate
  63089. * @param bottom defines the viewport bottom coordinate
  63090. * @param top defines the viewport top coordinate
  63091. * @param znear defines the near clip plane
  63092. * @param zfar defines the far clip plane
  63093. * @param result defines the target matrix
  63094. */
  63095. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63096. /**
  63097. * Creates a left-handed perspective projection matrix
  63098. * @param width defines the viewport width
  63099. * @param height defines the viewport height
  63100. * @param znear defines the near clip plane
  63101. * @param zfar defines the far clip plane
  63102. * @returns a new matrix as a left-handed perspective projection matrix
  63103. */
  63104. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63105. /**
  63106. * Creates a left-handed perspective projection matrix
  63107. * @param fov defines the horizontal field of view
  63108. * @param aspect defines the aspect ratio
  63109. * @param znear defines the near clip plane
  63110. * @param zfar defines the far clip plane
  63111. * @returns a new matrix as a left-handed perspective projection matrix
  63112. */
  63113. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63114. /**
  63115. * Stores a left-handed perspective projection into a given matrix
  63116. * @param fov defines the horizontal field of view
  63117. * @param aspect defines the aspect ratio
  63118. * @param znear defines the near clip plane
  63119. * @param zfar defines the far clip plane
  63120. * @param result defines the target matrix
  63121. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63122. */
  63123. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63124. /**
  63125. * Creates a right-handed perspective projection matrix
  63126. * @param fov defines the horizontal field of view
  63127. * @param aspect defines the aspect ratio
  63128. * @param znear defines the near clip plane
  63129. * @param zfar defines the far clip plane
  63130. * @returns a new matrix as a right-handed perspective projection matrix
  63131. */
  63132. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63133. /**
  63134. * Stores a right-handed perspective projection into a given matrix
  63135. * @param fov defines the horizontal field of view
  63136. * @param aspect defines the aspect ratio
  63137. * @param znear defines the near clip plane
  63138. * @param zfar defines the far clip plane
  63139. * @param result defines the target matrix
  63140. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63141. */
  63142. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63143. /**
  63144. * Stores a perspective projection for WebVR info a given matrix
  63145. * @param fov defines the field of view
  63146. * @param znear defines the near clip plane
  63147. * @param zfar defines the far clip plane
  63148. * @param result defines the target matrix
  63149. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63150. */
  63151. static PerspectiveFovWebVRToRef(fov: {
  63152. upDegrees: number;
  63153. downDegrees: number;
  63154. leftDegrees: number;
  63155. rightDegrees: number;
  63156. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63157. /**
  63158. * Computes a complete transformation matrix
  63159. * @param viewport defines the viewport to use
  63160. * @param world defines the world matrix
  63161. * @param view defines the view matrix
  63162. * @param projection defines the projection matrix
  63163. * @param zmin defines the near clip plane
  63164. * @param zmax defines the far clip plane
  63165. * @returns the transformation matrix
  63166. */
  63167. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63168. /**
  63169. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63170. * @param matrix defines the matrix to use
  63171. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63172. */
  63173. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63174. /**
  63175. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63176. * @param matrix defines the matrix to use
  63177. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63178. */
  63179. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63180. /**
  63181. * Compute the transpose of a given matrix
  63182. * @param matrix defines the matrix to transpose
  63183. * @returns the new matrix
  63184. */
  63185. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63186. /**
  63187. * Compute the transpose of a matrix and store it in a target matrix
  63188. * @param matrix defines the matrix to transpose
  63189. * @param result defines the target matrix
  63190. */
  63191. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63192. /**
  63193. * Computes a reflection matrix from a plane
  63194. * @param plane defines the reflection plane
  63195. * @returns a new matrix
  63196. */
  63197. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63198. /**
  63199. * Computes a reflection matrix from a plane
  63200. * @param plane defines the reflection plane
  63201. * @param result defines the target matrix
  63202. */
  63203. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63204. /**
  63205. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63206. * @param xaxis defines the value of the 1st axis
  63207. * @param yaxis defines the value of the 2nd axis
  63208. * @param zaxis defines the value of the 3rd axis
  63209. * @param result defines the target matrix
  63210. */
  63211. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63212. /**
  63213. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63214. * @param quat defines the quaternion to use
  63215. * @param result defines the target matrix
  63216. */
  63217. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63218. }
  63219. /**
  63220. * Represens a plane by the equation ax + by + cz + d = 0
  63221. */
  63222. export class Plane {
  63223. /**
  63224. * Normal of the plane (a,b,c)
  63225. */
  63226. normal: Vector3;
  63227. /**
  63228. * d component of the plane
  63229. */
  63230. d: number;
  63231. /**
  63232. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63233. * @param a a component of the plane
  63234. * @param b b component of the plane
  63235. * @param c c component of the plane
  63236. * @param d d component of the plane
  63237. */
  63238. constructor(a: number, b: number, c: number, d: number);
  63239. /**
  63240. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63241. */
  63242. asArray(): number[];
  63243. /**
  63244. * @returns a new plane copied from the current Plane.
  63245. */
  63246. clone(): Plane;
  63247. /**
  63248. * @returns the string "Plane".
  63249. */
  63250. getClassName(): string;
  63251. /**
  63252. * @returns the Plane hash code.
  63253. */
  63254. getHashCode(): number;
  63255. /**
  63256. * Normalize the current Plane in place.
  63257. * @returns the updated Plane.
  63258. */
  63259. normalize(): Plane;
  63260. /**
  63261. * Applies a transformation the plane and returns the result
  63262. * @param transformation the transformation matrix to be applied to the plane
  63263. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63264. */
  63265. transform(transformation: DeepImmutable<Matrix>): Plane;
  63266. /**
  63267. * Calcualtte the dot product between the point and the plane normal
  63268. * @param point point to calculate the dot product with
  63269. * @returns the dot product (float) of the point coordinates and the plane normal.
  63270. */
  63271. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63272. /**
  63273. * Updates the current Plane from the plane defined by the three given points.
  63274. * @param point1 one of the points used to contruct the plane
  63275. * @param point2 one of the points used to contruct the plane
  63276. * @param point3 one of the points used to contruct the plane
  63277. * @returns the updated Plane.
  63278. */
  63279. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63280. /**
  63281. * Checks if the plane is facing a given direction
  63282. * @param direction the direction to check if the plane is facing
  63283. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63284. * @returns True is the vector "direction" is the same side than the plane normal.
  63285. */
  63286. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63287. /**
  63288. * Calculates the distance to a point
  63289. * @param point point to calculate distance to
  63290. * @returns the signed distance (float) from the given point to the Plane.
  63291. */
  63292. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63293. /**
  63294. * Creates a plane from an array
  63295. * @param array the array to create a plane from
  63296. * @returns a new Plane from the given array.
  63297. */
  63298. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63299. /**
  63300. * Creates a plane from three points
  63301. * @param point1 point used to create the plane
  63302. * @param point2 point used to create the plane
  63303. * @param point3 point used to create the plane
  63304. * @returns a new Plane defined by the three given points.
  63305. */
  63306. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63307. /**
  63308. * Creates a plane from an origin point and a normal
  63309. * @param origin origin of the plane to be constructed
  63310. * @param normal normal of the plane to be constructed
  63311. * @returns a new Plane the normal vector to this plane at the given origin point.
  63312. * Note : the vector "normal" is updated because normalized.
  63313. */
  63314. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63315. /**
  63316. * Calculates the distance from a plane and a point
  63317. * @param origin origin of the plane to be constructed
  63318. * @param normal normal of the plane to be constructed
  63319. * @param point point to calculate distance to
  63320. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63321. */
  63322. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63323. }
  63324. /**
  63325. * Class used to represent a viewport on screen
  63326. */
  63327. export class Viewport {
  63328. /** viewport left coordinate */
  63329. x: number;
  63330. /** viewport top coordinate */
  63331. y: number;
  63332. /**viewport width */
  63333. width: number;
  63334. /** viewport height */
  63335. height: number;
  63336. /**
  63337. * Creates a Viewport object located at (x, y) and sized (width, height)
  63338. * @param x defines viewport left coordinate
  63339. * @param y defines viewport top coordinate
  63340. * @param width defines the viewport width
  63341. * @param height defines the viewport height
  63342. */
  63343. constructor(
  63344. /** viewport left coordinate */
  63345. x: number,
  63346. /** viewport top coordinate */
  63347. y: number,
  63348. /**viewport width */
  63349. width: number,
  63350. /** viewport height */
  63351. height: number);
  63352. /**
  63353. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63354. * @param renderWidth defines the rendering width
  63355. * @param renderHeight defines the rendering height
  63356. * @returns a new Viewport
  63357. */
  63358. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63359. /**
  63360. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63361. * @param renderWidth defines the rendering width
  63362. * @param renderHeight defines the rendering height
  63363. * @param ref defines the target viewport
  63364. * @returns the current viewport
  63365. */
  63366. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63367. /**
  63368. * Returns a new Viewport copied from the current one
  63369. * @returns a new Viewport
  63370. */
  63371. clone(): Viewport;
  63372. }
  63373. /**
  63374. * Reprasents a camera frustum
  63375. */
  63376. export class Frustum {
  63377. /**
  63378. * Gets the planes representing the frustum
  63379. * @param transform matrix to be applied to the returned planes
  63380. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63381. */
  63382. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63383. /**
  63384. * Gets the near frustum plane transformed by the transform matrix
  63385. * @param transform transformation matrix to be applied to the resulting frustum plane
  63386. * @param frustumPlane the resuling frustum plane
  63387. */
  63388. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63389. /**
  63390. * Gets the far frustum plane transformed by the transform matrix
  63391. * @param transform transformation matrix to be applied to the resulting frustum plane
  63392. * @param frustumPlane the resuling frustum plane
  63393. */
  63394. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63395. /**
  63396. * Gets the left frustum plane transformed by the transform matrix
  63397. * @param transform transformation matrix to be applied to the resulting frustum plane
  63398. * @param frustumPlane the resuling frustum plane
  63399. */
  63400. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63401. /**
  63402. * Gets the right frustum plane transformed by the transform matrix
  63403. * @param transform transformation matrix to be applied to the resulting frustum plane
  63404. * @param frustumPlane the resuling frustum plane
  63405. */
  63406. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63407. /**
  63408. * Gets the top frustum plane transformed by the transform matrix
  63409. * @param transform transformation matrix to be applied to the resulting frustum plane
  63410. * @param frustumPlane the resuling frustum plane
  63411. */
  63412. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63413. /**
  63414. * Gets the bottom frustum plane transformed by the transform matrix
  63415. * @param transform transformation matrix to be applied to the resulting frustum plane
  63416. * @param frustumPlane the resuling frustum plane
  63417. */
  63418. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63419. /**
  63420. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63421. * @param transform transformation matrix to be applied to the resulting frustum planes
  63422. * @param frustumPlanes the resuling frustum planes
  63423. */
  63424. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63425. }
  63426. /** Defines supported spaces */
  63427. export enum Space {
  63428. /** Local (object) space */
  63429. LOCAL = 0,
  63430. /** World space */
  63431. WORLD = 1,
  63432. /** Bone space */
  63433. BONE = 2
  63434. }
  63435. /** Defines the 3 main axes */
  63436. export class Axis {
  63437. /** X axis */
  63438. static X: Vector3;
  63439. /** Y axis */
  63440. static Y: Vector3;
  63441. /** Z axis */
  63442. static Z: Vector3;
  63443. }
  63444. /** Class used to represent a Bezier curve */
  63445. export class BezierCurve {
  63446. /**
  63447. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63448. * @param t defines the time
  63449. * @param x1 defines the left coordinate on X axis
  63450. * @param y1 defines the left coordinate on Y axis
  63451. * @param x2 defines the right coordinate on X axis
  63452. * @param y2 defines the right coordinate on Y axis
  63453. * @returns the interpolated value
  63454. */
  63455. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63456. }
  63457. /**
  63458. * Defines potential orientation for back face culling
  63459. */
  63460. export enum Orientation {
  63461. /**
  63462. * Clockwise
  63463. */
  63464. CW = 0,
  63465. /** Counter clockwise */
  63466. CCW = 1
  63467. }
  63468. /**
  63469. * Defines angle representation
  63470. */
  63471. export class Angle {
  63472. private _radians;
  63473. /**
  63474. * Creates an Angle object of "radians" radians (float).
  63475. * @param radians the angle in radians
  63476. */
  63477. constructor(radians: number);
  63478. /**
  63479. * Get value in degrees
  63480. * @returns the Angle value in degrees (float)
  63481. */
  63482. degrees(): number;
  63483. /**
  63484. * Get value in radians
  63485. * @returns the Angle value in radians (float)
  63486. */
  63487. radians(): number;
  63488. /**
  63489. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63490. * @param a defines first vector
  63491. * @param b defines second vector
  63492. * @returns a new Angle
  63493. */
  63494. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63495. /**
  63496. * Gets a new Angle object from the given float in radians
  63497. * @param radians defines the angle value in radians
  63498. * @returns a new Angle
  63499. */
  63500. static FromRadians(radians: number): Angle;
  63501. /**
  63502. * Gets a new Angle object from the given float in degrees
  63503. * @param degrees defines the angle value in degrees
  63504. * @returns a new Angle
  63505. */
  63506. static FromDegrees(degrees: number): Angle;
  63507. }
  63508. /**
  63509. * This represents an arc in a 2d space.
  63510. */
  63511. export class Arc2 {
  63512. /** Defines the start point of the arc */
  63513. startPoint: Vector2;
  63514. /** Defines the mid point of the arc */
  63515. midPoint: Vector2;
  63516. /** Defines the end point of the arc */
  63517. endPoint: Vector2;
  63518. /**
  63519. * Defines the center point of the arc.
  63520. */
  63521. centerPoint: Vector2;
  63522. /**
  63523. * Defines the radius of the arc.
  63524. */
  63525. radius: number;
  63526. /**
  63527. * Defines the angle of the arc (from mid point to end point).
  63528. */
  63529. angle: Angle;
  63530. /**
  63531. * Defines the start angle of the arc (from start point to middle point).
  63532. */
  63533. startAngle: Angle;
  63534. /**
  63535. * Defines the orientation of the arc (clock wise/counter clock wise).
  63536. */
  63537. orientation: Orientation;
  63538. /**
  63539. * Creates an Arc object from the three given points : start, middle and end.
  63540. * @param startPoint Defines the start point of the arc
  63541. * @param midPoint Defines the midlle point of the arc
  63542. * @param endPoint Defines the end point of the arc
  63543. */
  63544. constructor(
  63545. /** Defines the start point of the arc */
  63546. startPoint: Vector2,
  63547. /** Defines the mid point of the arc */
  63548. midPoint: Vector2,
  63549. /** Defines the end point of the arc */
  63550. endPoint: Vector2);
  63551. }
  63552. /**
  63553. * Represents a 2D path made up of multiple 2D points
  63554. */
  63555. export class Path2 {
  63556. private _points;
  63557. private _length;
  63558. /**
  63559. * If the path start and end point are the same
  63560. */
  63561. closed: boolean;
  63562. /**
  63563. * Creates a Path2 object from the starting 2D coordinates x and y.
  63564. * @param x the starting points x value
  63565. * @param y the starting points y value
  63566. */
  63567. constructor(x: number, y: number);
  63568. /**
  63569. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63570. * @param x the added points x value
  63571. * @param y the added points y value
  63572. * @returns the updated Path2.
  63573. */
  63574. addLineTo(x: number, y: number): Path2;
  63575. /**
  63576. * 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.
  63577. * @param midX middle point x value
  63578. * @param midY middle point y value
  63579. * @param endX end point x value
  63580. * @param endY end point y value
  63581. * @param numberOfSegments (default: 36)
  63582. * @returns the updated Path2.
  63583. */
  63584. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63585. /**
  63586. * Closes the Path2.
  63587. * @returns the Path2.
  63588. */
  63589. close(): Path2;
  63590. /**
  63591. * Gets the sum of the distance between each sequential point in the path
  63592. * @returns the Path2 total length (float).
  63593. */
  63594. length(): number;
  63595. /**
  63596. * Gets the points which construct the path
  63597. * @returns the Path2 internal array of points.
  63598. */
  63599. getPoints(): Vector2[];
  63600. /**
  63601. * Retreives the point at the distance aways from the starting point
  63602. * @param normalizedLengthPosition the length along the path to retreive the point from
  63603. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63604. */
  63605. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63606. /**
  63607. * Creates a new path starting from an x and y position
  63608. * @param x starting x value
  63609. * @param y starting y value
  63610. * @returns a new Path2 starting at the coordinates (x, y).
  63611. */
  63612. static StartingAt(x: number, y: number): Path2;
  63613. }
  63614. /**
  63615. * Represents a 3D path made up of multiple 3D points
  63616. */
  63617. export class Path3D {
  63618. /**
  63619. * an array of Vector3, the curve axis of the Path3D
  63620. */
  63621. path: Vector3[];
  63622. private _curve;
  63623. private _distances;
  63624. private _tangents;
  63625. private _normals;
  63626. private _binormals;
  63627. private _raw;
  63628. /**
  63629. * new Path3D(path, normal, raw)
  63630. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63631. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63632. * @param path an array of Vector3, the curve axis of the Path3D
  63633. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63634. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63635. */
  63636. constructor(
  63637. /**
  63638. * an array of Vector3, the curve axis of the Path3D
  63639. */
  63640. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63641. /**
  63642. * Returns the Path3D array of successive Vector3 designing its curve.
  63643. * @returns the Path3D array of successive Vector3 designing its curve.
  63644. */
  63645. getCurve(): Vector3[];
  63646. /**
  63647. * Returns an array populated with tangent vectors on each Path3D curve point.
  63648. * @returns an array populated with tangent vectors on each Path3D curve point.
  63649. */
  63650. getTangents(): Vector3[];
  63651. /**
  63652. * Returns an array populated with normal vectors on each Path3D curve point.
  63653. * @returns an array populated with normal vectors on each Path3D curve point.
  63654. */
  63655. getNormals(): Vector3[];
  63656. /**
  63657. * Returns an array populated with binormal vectors on each Path3D curve point.
  63658. * @returns an array populated with binormal vectors on each Path3D curve point.
  63659. */
  63660. getBinormals(): Vector3[];
  63661. /**
  63662. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63663. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63664. */
  63665. getDistances(): number[];
  63666. /**
  63667. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63668. * @param path path which all values are copied into the curves points
  63669. * @param firstNormal which should be projected onto the curve
  63670. * @returns the same object updated.
  63671. */
  63672. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63673. private _compute;
  63674. private _getFirstNonNullVector;
  63675. private _getLastNonNullVector;
  63676. private _normalVector;
  63677. }
  63678. /**
  63679. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63680. * A Curve3 is designed from a series of successive Vector3.
  63681. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63682. */
  63683. export class Curve3 {
  63684. private _points;
  63685. private _length;
  63686. /**
  63687. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63688. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63689. * @param v1 (Vector3) the control point
  63690. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63691. * @param nbPoints (integer) the wanted number of points in the curve
  63692. * @returns the created Curve3
  63693. */
  63694. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63695. /**
  63696. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63697. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63698. * @param v1 (Vector3) the first control point
  63699. * @param v2 (Vector3) the second control point
  63700. * @param v3 (Vector3) the end point of the Cubic Bezier
  63701. * @param nbPoints (integer) the wanted number of points in the curve
  63702. * @returns the created Curve3
  63703. */
  63704. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63705. /**
  63706. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63707. * @param p1 (Vector3) the origin point of the Hermite Spline
  63708. * @param t1 (Vector3) the tangent vector at the origin point
  63709. * @param p2 (Vector3) the end point of the Hermite Spline
  63710. * @param t2 (Vector3) the tangent vector at the end point
  63711. * @param nbPoints (integer) the wanted number of points in the curve
  63712. * @returns the created Curve3
  63713. */
  63714. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63715. /**
  63716. * Returns a Curve3 object along a CatmullRom Spline curve :
  63717. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63718. * @param nbPoints (integer) the wanted number of points between each curve control points
  63719. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63720. * @returns the created Curve3
  63721. */
  63722. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63723. /**
  63724. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63725. * A Curve3 is designed from a series of successive Vector3.
  63726. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63727. * @param points points which make up the curve
  63728. */
  63729. constructor(points: Vector3[]);
  63730. /**
  63731. * @returns the Curve3 stored array of successive Vector3
  63732. */
  63733. getPoints(): Vector3[];
  63734. /**
  63735. * @returns the computed length (float) of the curve.
  63736. */
  63737. length(): number;
  63738. /**
  63739. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63740. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63741. * curveA and curveB keep unchanged.
  63742. * @param curve the curve to continue from this curve
  63743. * @returns the newly constructed curve
  63744. */
  63745. continue(curve: DeepImmutable<Curve3>): Curve3;
  63746. private _computeLength;
  63747. }
  63748. /**
  63749. * Contains position and normal vectors for a vertex
  63750. */
  63751. export class PositionNormalVertex {
  63752. /** the position of the vertex (defaut: 0,0,0) */
  63753. position: Vector3;
  63754. /** the normal of the vertex (defaut: 0,1,0) */
  63755. normal: Vector3;
  63756. /**
  63757. * Creates a PositionNormalVertex
  63758. * @param position the position of the vertex (defaut: 0,0,0)
  63759. * @param normal the normal of the vertex (defaut: 0,1,0)
  63760. */
  63761. constructor(
  63762. /** the position of the vertex (defaut: 0,0,0) */
  63763. position?: Vector3,
  63764. /** the normal of the vertex (defaut: 0,1,0) */
  63765. normal?: Vector3);
  63766. /**
  63767. * Clones the PositionNormalVertex
  63768. * @returns the cloned PositionNormalVertex
  63769. */
  63770. clone(): PositionNormalVertex;
  63771. }
  63772. /**
  63773. * Contains position, normal and uv vectors for a vertex
  63774. */
  63775. export class PositionNormalTextureVertex {
  63776. /** the position of the vertex (defaut: 0,0,0) */
  63777. position: Vector3;
  63778. /** the normal of the vertex (defaut: 0,1,0) */
  63779. normal: Vector3;
  63780. /** the uv of the vertex (default: 0,0) */
  63781. uv: Vector2;
  63782. /**
  63783. * Creates a PositionNormalTextureVertex
  63784. * @param position the position of the vertex (defaut: 0,0,0)
  63785. * @param normal the normal of the vertex (defaut: 0,1,0)
  63786. * @param uv the uv of the vertex (default: 0,0)
  63787. */
  63788. constructor(
  63789. /** the position of the vertex (defaut: 0,0,0) */
  63790. position?: Vector3,
  63791. /** the normal of the vertex (defaut: 0,1,0) */
  63792. normal?: Vector3,
  63793. /** the uv of the vertex (default: 0,0) */
  63794. uv?: Vector2);
  63795. /**
  63796. * Clones the PositionNormalTextureVertex
  63797. * @returns the cloned PositionNormalTextureVertex
  63798. */
  63799. clone(): PositionNormalTextureVertex;
  63800. }
  63801. /**
  63802. * @hidden
  63803. */
  63804. export class Tmp {
  63805. static Color3: Color3[];
  63806. static Color4: Color4[];
  63807. static Vector2: Vector2[];
  63808. static Vector3: Vector3[];
  63809. static Vector4: Vector4[];
  63810. static Quaternion: Quaternion[];
  63811. static Matrix: Matrix[];
  63812. }
  63813. }
  63814. declare module BABYLON {
  63815. /**
  63816. * Class used to enable access to offline support
  63817. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63818. */
  63819. export interface IOfflineProvider {
  63820. /**
  63821. * Gets a boolean indicating if scene must be saved in the database
  63822. */
  63823. enableSceneOffline: boolean;
  63824. /**
  63825. * Gets a boolean indicating if textures must be saved in the database
  63826. */
  63827. enableTexturesOffline: boolean;
  63828. /**
  63829. * Open the offline support and make it available
  63830. * @param successCallback defines the callback to call on success
  63831. * @param errorCallback defines the callback to call on error
  63832. */
  63833. open(successCallback: () => void, errorCallback: () => void): void;
  63834. /**
  63835. * Loads an image from the offline support
  63836. * @param url defines the url to load from
  63837. * @param image defines the target DOM image
  63838. */
  63839. loadImage(url: string, image: HTMLImageElement): void;
  63840. /**
  63841. * Loads a file from offline support
  63842. * @param url defines the URL to load from
  63843. * @param sceneLoaded defines a callback to call on success
  63844. * @param progressCallBack defines a callback to call when progress changed
  63845. * @param errorCallback defines a callback to call on error
  63846. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63847. */
  63848. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63849. }
  63850. }
  63851. declare module BABYLON {
  63852. /**
  63853. * A class serves as a medium between the observable and its observers
  63854. */
  63855. export class EventState {
  63856. /**
  63857. * Create a new EventState
  63858. * @param mask defines the mask associated with this state
  63859. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63860. * @param target defines the original target of the state
  63861. * @param currentTarget defines the current target of the state
  63862. */
  63863. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63864. /**
  63865. * Initialize the current event state
  63866. * @param mask defines the mask associated with this state
  63867. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63868. * @param target defines the original target of the state
  63869. * @param currentTarget defines the current target of the state
  63870. * @returns the current event state
  63871. */
  63872. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63873. /**
  63874. * An Observer can set this property to true to prevent subsequent observers of being notified
  63875. */
  63876. skipNextObservers: boolean;
  63877. /**
  63878. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63879. */
  63880. mask: number;
  63881. /**
  63882. * The object that originally notified the event
  63883. */
  63884. target?: any;
  63885. /**
  63886. * The current object in the bubbling phase
  63887. */
  63888. currentTarget?: any;
  63889. /**
  63890. * This will be populated with the return value of the last function that was executed.
  63891. * If it is the first function in the callback chain it will be the event data.
  63892. */
  63893. lastReturnValue?: any;
  63894. }
  63895. /**
  63896. * Represent an Observer registered to a given Observable object.
  63897. */
  63898. export class Observer<T> {
  63899. /**
  63900. * Defines the callback to call when the observer is notified
  63901. */
  63902. callback: (eventData: T, eventState: EventState) => void;
  63903. /**
  63904. * Defines the mask of the observer (used to filter notifications)
  63905. */
  63906. mask: number;
  63907. /**
  63908. * Defines the current scope used to restore the JS context
  63909. */
  63910. scope: any;
  63911. /** @hidden */
  63912. _willBeUnregistered: boolean;
  63913. /**
  63914. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63915. */
  63916. unregisterOnNextCall: boolean;
  63917. /**
  63918. * Creates a new observer
  63919. * @param callback defines the callback to call when the observer is notified
  63920. * @param mask defines the mask of the observer (used to filter notifications)
  63921. * @param scope defines the current scope used to restore the JS context
  63922. */
  63923. constructor(
  63924. /**
  63925. * Defines the callback to call when the observer is notified
  63926. */
  63927. callback: (eventData: T, eventState: EventState) => void,
  63928. /**
  63929. * Defines the mask of the observer (used to filter notifications)
  63930. */
  63931. mask: number,
  63932. /**
  63933. * Defines the current scope used to restore the JS context
  63934. */
  63935. scope?: any);
  63936. }
  63937. /**
  63938. * Represent a list of observers registered to multiple Observables object.
  63939. */
  63940. export class MultiObserver<T> {
  63941. private _observers;
  63942. private _observables;
  63943. /**
  63944. * Release associated resources
  63945. */
  63946. dispose(): void;
  63947. /**
  63948. * Raise a callback when one of the observable will notify
  63949. * @param observables defines a list of observables to watch
  63950. * @param callback defines the callback to call on notification
  63951. * @param mask defines the mask used to filter notifications
  63952. * @param scope defines the current scope used to restore the JS context
  63953. * @returns the new MultiObserver
  63954. */
  63955. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63956. }
  63957. /**
  63958. * The Observable class is a simple implementation of the Observable pattern.
  63959. *
  63960. * 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.
  63961. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63962. * 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).
  63963. * 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.
  63964. */
  63965. export class Observable<T> {
  63966. private _observers;
  63967. private _eventState;
  63968. private _onObserverAdded;
  63969. /**
  63970. * Creates a new observable
  63971. * @param onObserverAdded defines a callback to call when a new observer is added
  63972. */
  63973. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63974. /**
  63975. * Create a new Observer with the specified callback
  63976. * @param callback the callback that will be executed for that Observer
  63977. * @param mask the mask used to filter observers
  63978. * @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.
  63979. * @param scope optional scope for the callback to be called from
  63980. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63981. * @returns the new observer created for the callback
  63982. */
  63983. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63984. /**
  63985. * Create a new Observer with the specified callback and unregisters after the next notification
  63986. * @param callback the callback that will be executed for that Observer
  63987. * @returns the new observer created for the callback
  63988. */
  63989. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63990. /**
  63991. * Remove an Observer from the Observable object
  63992. * @param observer the instance of the Observer to remove
  63993. * @returns false if it doesn't belong to this Observable
  63994. */
  63995. remove(observer: Nullable<Observer<T>>): boolean;
  63996. /**
  63997. * Remove a callback from the Observable object
  63998. * @param callback the callback to remove
  63999. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64000. * @returns false if it doesn't belong to this Observable
  64001. */
  64002. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64003. private _deferUnregister;
  64004. private _remove;
  64005. /**
  64006. * Moves the observable to the top of the observer list making it get called first when notified
  64007. * @param observer the observer to move
  64008. */
  64009. makeObserverTopPriority(observer: Observer<T>): void;
  64010. /**
  64011. * Moves the observable to the bottom of the observer list making it get called last when notified
  64012. * @param observer the observer to move
  64013. */
  64014. makeObserverBottomPriority(observer: Observer<T>): void;
  64015. /**
  64016. * Notify all Observers by calling their respective callback with the given data
  64017. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64018. * @param eventData defines the data to send to all observers
  64019. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64020. * @param target defines the original target of the state
  64021. * @param currentTarget defines the current target of the state
  64022. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64023. */
  64024. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64025. /**
  64026. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64027. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64028. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64029. * and it is crucial that all callbacks will be executed.
  64030. * The order of the callbacks is kept, callbacks are not executed parallel.
  64031. *
  64032. * @param eventData The data to be sent to each callback
  64033. * @param mask is used to filter observers defaults to -1
  64034. * @param target defines the callback target (see EventState)
  64035. * @param currentTarget defines he current object in the bubbling phase
  64036. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64037. */
  64038. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64039. /**
  64040. * Notify a specific observer
  64041. * @param observer defines the observer to notify
  64042. * @param eventData defines the data to be sent to each callback
  64043. * @param mask is used to filter observers defaults to -1
  64044. */
  64045. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64046. /**
  64047. * Gets a boolean indicating if the observable has at least one observer
  64048. * @returns true is the Observable has at least one Observer registered
  64049. */
  64050. hasObservers(): boolean;
  64051. /**
  64052. * Clear the list of observers
  64053. */
  64054. clear(): void;
  64055. /**
  64056. * Clone the current observable
  64057. * @returns a new observable
  64058. */
  64059. clone(): Observable<T>;
  64060. /**
  64061. * Does this observable handles observer registered with a given mask
  64062. * @param mask defines the mask to be tested
  64063. * @return whether or not one observer registered with the given mask is handeled
  64064. **/
  64065. hasSpecificMask(mask?: number): boolean;
  64066. }
  64067. }
  64068. declare module BABYLON {
  64069. /**
  64070. * Class used to help managing file picking and drag'n'drop
  64071. * File Storage
  64072. */
  64073. export class FilesInputStore {
  64074. /**
  64075. * List of files ready to be loaded
  64076. */
  64077. static FilesToLoad: {
  64078. [key: string]: File;
  64079. };
  64080. }
  64081. }
  64082. declare module BABYLON {
  64083. /** Defines the cross module used constants to avoid circular dependncies */
  64084. export class Constants {
  64085. /** Defines that alpha blending is disabled */
  64086. static readonly ALPHA_DISABLE: number;
  64087. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64088. static readonly ALPHA_ADD: number;
  64089. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64090. static readonly ALPHA_COMBINE: number;
  64091. /** Defines that alpha blending to DEST - SRC * DEST */
  64092. static readonly ALPHA_SUBTRACT: number;
  64093. /** Defines that alpha blending to SRC * DEST */
  64094. static readonly ALPHA_MULTIPLY: number;
  64095. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64096. static readonly ALPHA_MAXIMIZED: number;
  64097. /** Defines that alpha blending to SRC + DEST */
  64098. static readonly ALPHA_ONEONE: number;
  64099. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64100. static readonly ALPHA_PREMULTIPLIED: number;
  64101. /**
  64102. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64103. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64104. */
  64105. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64106. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64107. static readonly ALPHA_INTERPOLATE: number;
  64108. /**
  64109. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64110. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64111. */
  64112. static readonly ALPHA_SCREENMODE: number;
  64113. /** Defines that the ressource is not delayed*/
  64114. static readonly DELAYLOADSTATE_NONE: number;
  64115. /** Defines that the ressource was successfully delay loaded */
  64116. static readonly DELAYLOADSTATE_LOADED: number;
  64117. /** Defines that the ressource is currently delay loading */
  64118. static readonly DELAYLOADSTATE_LOADING: number;
  64119. /** Defines that the ressource is delayed and has not started loading */
  64120. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64121. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64122. static readonly NEVER: number;
  64123. /** 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 */
  64124. static readonly ALWAYS: number;
  64125. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64126. static readonly LESS: number;
  64127. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64128. static readonly EQUAL: number;
  64129. /** 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 */
  64130. static readonly LEQUAL: number;
  64131. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64132. static readonly GREATER: number;
  64133. /** 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 */
  64134. static readonly GEQUAL: number;
  64135. /** 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 */
  64136. static readonly NOTEQUAL: number;
  64137. /** Passed to stencilOperation to specify that stencil value must be kept */
  64138. static readonly KEEP: number;
  64139. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64140. static readonly REPLACE: number;
  64141. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64142. static readonly INCR: number;
  64143. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64144. static readonly DECR: number;
  64145. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64146. static readonly INVERT: number;
  64147. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64148. static readonly INCR_WRAP: number;
  64149. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64150. static readonly DECR_WRAP: number;
  64151. /** Texture is not repeating outside of 0..1 UVs */
  64152. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64153. /** Texture is repeating outside of 0..1 UVs */
  64154. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64155. /** Texture is repeating and mirrored */
  64156. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64157. /** ALPHA */
  64158. static readonly TEXTUREFORMAT_ALPHA: number;
  64159. /** LUMINANCE */
  64160. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64161. /** LUMINANCE_ALPHA */
  64162. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64163. /** RGB */
  64164. static readonly TEXTUREFORMAT_RGB: number;
  64165. /** RGBA */
  64166. static readonly TEXTUREFORMAT_RGBA: number;
  64167. /** RED */
  64168. static readonly TEXTUREFORMAT_RED: number;
  64169. /** RED (2nd reference) */
  64170. static readonly TEXTUREFORMAT_R: number;
  64171. /** RG */
  64172. static readonly TEXTUREFORMAT_RG: number;
  64173. /** RED_INTEGER */
  64174. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64175. /** RED_INTEGER (2nd reference) */
  64176. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64177. /** RG_INTEGER */
  64178. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64179. /** RGB_INTEGER */
  64180. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64181. /** RGBA_INTEGER */
  64182. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64183. /** UNSIGNED_BYTE */
  64184. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64185. /** UNSIGNED_BYTE (2nd reference) */
  64186. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64187. /** FLOAT */
  64188. static readonly TEXTURETYPE_FLOAT: number;
  64189. /** HALF_FLOAT */
  64190. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64191. /** BYTE */
  64192. static readonly TEXTURETYPE_BYTE: number;
  64193. /** SHORT */
  64194. static readonly TEXTURETYPE_SHORT: number;
  64195. /** UNSIGNED_SHORT */
  64196. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64197. /** INT */
  64198. static readonly TEXTURETYPE_INT: number;
  64199. /** UNSIGNED_INT */
  64200. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64201. /** UNSIGNED_SHORT_4_4_4_4 */
  64202. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64203. /** UNSIGNED_SHORT_5_5_5_1 */
  64204. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64205. /** UNSIGNED_SHORT_5_6_5 */
  64206. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64207. /** UNSIGNED_INT_2_10_10_10_REV */
  64208. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64209. /** UNSIGNED_INT_24_8 */
  64210. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64211. /** UNSIGNED_INT_10F_11F_11F_REV */
  64212. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64213. /** UNSIGNED_INT_5_9_9_9_REV */
  64214. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64215. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64216. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64217. /** nearest is mag = nearest and min = nearest and mip = linear */
  64218. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64219. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64220. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64221. /** Trilinear is mag = linear and min = linear and mip = linear */
  64222. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64223. /** nearest is mag = nearest and min = nearest and mip = linear */
  64224. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64225. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64226. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64227. /** Trilinear is mag = linear and min = linear and mip = linear */
  64228. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64229. /** mag = nearest and min = nearest and mip = nearest */
  64230. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64231. /** mag = nearest and min = linear and mip = nearest */
  64232. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64233. /** mag = nearest and min = linear and mip = linear */
  64234. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64235. /** mag = nearest and min = linear and mip = none */
  64236. static readonly TEXTURE_NEAREST_LINEAR: number;
  64237. /** mag = nearest and min = nearest and mip = none */
  64238. static readonly TEXTURE_NEAREST_NEAREST: number;
  64239. /** mag = linear and min = nearest and mip = nearest */
  64240. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64241. /** mag = linear and min = nearest and mip = linear */
  64242. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64243. /** mag = linear and min = linear and mip = none */
  64244. static readonly TEXTURE_LINEAR_LINEAR: number;
  64245. /** mag = linear and min = nearest and mip = none */
  64246. static readonly TEXTURE_LINEAR_NEAREST: number;
  64247. /** Explicit coordinates mode */
  64248. static readonly TEXTURE_EXPLICIT_MODE: number;
  64249. /** Spherical coordinates mode */
  64250. static readonly TEXTURE_SPHERICAL_MODE: number;
  64251. /** Planar coordinates mode */
  64252. static readonly TEXTURE_PLANAR_MODE: number;
  64253. /** Cubic coordinates mode */
  64254. static readonly TEXTURE_CUBIC_MODE: number;
  64255. /** Projection coordinates mode */
  64256. static readonly TEXTURE_PROJECTION_MODE: number;
  64257. /** Skybox coordinates mode */
  64258. static readonly TEXTURE_SKYBOX_MODE: number;
  64259. /** Inverse Cubic coordinates mode */
  64260. static readonly TEXTURE_INVCUBIC_MODE: number;
  64261. /** Equirectangular coordinates mode */
  64262. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64263. /** Equirectangular Fixed coordinates mode */
  64264. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64265. /** Equirectangular Fixed Mirrored coordinates mode */
  64266. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64267. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64268. static readonly SCALEMODE_FLOOR: number;
  64269. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64270. static readonly SCALEMODE_NEAREST: number;
  64271. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64272. static readonly SCALEMODE_CEILING: number;
  64273. /**
  64274. * The dirty texture flag value
  64275. */
  64276. static readonly MATERIAL_TextureDirtyFlag: number;
  64277. /**
  64278. * The dirty light flag value
  64279. */
  64280. static readonly MATERIAL_LightDirtyFlag: number;
  64281. /**
  64282. * The dirty fresnel flag value
  64283. */
  64284. static readonly MATERIAL_FresnelDirtyFlag: number;
  64285. /**
  64286. * The dirty attribute flag value
  64287. */
  64288. static readonly MATERIAL_AttributesDirtyFlag: number;
  64289. /**
  64290. * The dirty misc flag value
  64291. */
  64292. static readonly MATERIAL_MiscDirtyFlag: number;
  64293. /**
  64294. * The all dirty flag value
  64295. */
  64296. static readonly MATERIAL_AllDirtyFlag: number;
  64297. /**
  64298. * Returns the triangle fill mode
  64299. */
  64300. static readonly MATERIAL_TriangleFillMode: number;
  64301. /**
  64302. * Returns the wireframe mode
  64303. */
  64304. static readonly MATERIAL_WireFrameFillMode: number;
  64305. /**
  64306. * Returns the point fill mode
  64307. */
  64308. static readonly MATERIAL_PointFillMode: number;
  64309. /**
  64310. * Returns the point list draw mode
  64311. */
  64312. static readonly MATERIAL_PointListDrawMode: number;
  64313. /**
  64314. * Returns the line list draw mode
  64315. */
  64316. static readonly MATERIAL_LineListDrawMode: number;
  64317. /**
  64318. * Returns the line loop draw mode
  64319. */
  64320. static readonly MATERIAL_LineLoopDrawMode: number;
  64321. /**
  64322. * Returns the line strip draw mode
  64323. */
  64324. static readonly MATERIAL_LineStripDrawMode: number;
  64325. /**
  64326. * Returns the triangle strip draw mode
  64327. */
  64328. static readonly MATERIAL_TriangleStripDrawMode: number;
  64329. /**
  64330. * Returns the triangle fan draw mode
  64331. */
  64332. static readonly MATERIAL_TriangleFanDrawMode: number;
  64333. /**
  64334. * Stores the clock-wise side orientation
  64335. */
  64336. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64337. /**
  64338. * Stores the counter clock-wise side orientation
  64339. */
  64340. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64341. /**
  64342. * Nothing
  64343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64344. */
  64345. static readonly ACTION_NothingTrigger: number;
  64346. /**
  64347. * On pick
  64348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64349. */
  64350. static readonly ACTION_OnPickTrigger: number;
  64351. /**
  64352. * On left pick
  64353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64354. */
  64355. static readonly ACTION_OnLeftPickTrigger: number;
  64356. /**
  64357. * On right pick
  64358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64359. */
  64360. static readonly ACTION_OnRightPickTrigger: number;
  64361. /**
  64362. * On center pick
  64363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64364. */
  64365. static readonly ACTION_OnCenterPickTrigger: number;
  64366. /**
  64367. * On pick down
  64368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64369. */
  64370. static readonly ACTION_OnPickDownTrigger: number;
  64371. /**
  64372. * On double pick
  64373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64374. */
  64375. static readonly ACTION_OnDoublePickTrigger: number;
  64376. /**
  64377. * On pick up
  64378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64379. */
  64380. static readonly ACTION_OnPickUpTrigger: number;
  64381. /**
  64382. * On pick out.
  64383. * This trigger will only be raised if you also declared a OnPickDown
  64384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64385. */
  64386. static readonly ACTION_OnPickOutTrigger: number;
  64387. /**
  64388. * On long press
  64389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64390. */
  64391. static readonly ACTION_OnLongPressTrigger: number;
  64392. /**
  64393. * On pointer over
  64394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64395. */
  64396. static readonly ACTION_OnPointerOverTrigger: number;
  64397. /**
  64398. * On pointer out
  64399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64400. */
  64401. static readonly ACTION_OnPointerOutTrigger: number;
  64402. /**
  64403. * On every frame
  64404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64405. */
  64406. static readonly ACTION_OnEveryFrameTrigger: number;
  64407. /**
  64408. * On intersection enter
  64409. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64410. */
  64411. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64412. /**
  64413. * On intersection exit
  64414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64415. */
  64416. static readonly ACTION_OnIntersectionExitTrigger: number;
  64417. /**
  64418. * On key down
  64419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64420. */
  64421. static readonly ACTION_OnKeyDownTrigger: number;
  64422. /**
  64423. * On key up
  64424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64425. */
  64426. static readonly ACTION_OnKeyUpTrigger: number;
  64427. /**
  64428. * Billboard mode will only apply to Y axis
  64429. */
  64430. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64431. /**
  64432. * Billboard mode will apply to all axes
  64433. */
  64434. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64435. /**
  64436. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64437. */
  64438. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64439. /**
  64440. * Gets or sets base Assets URL
  64441. */
  64442. static readonly PARTICLES_BaseAssetsUrl: string;
  64443. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64444. * Test order :
  64445. * Is the bounding sphere outside the frustum ?
  64446. * If not, are the bounding box vertices outside the frustum ?
  64447. * It not, then the cullable object is in the frustum.
  64448. */
  64449. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64450. /** Culling strategy : Bounding Sphere Only.
  64451. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64452. * It's also less accurate than the standard because some not visible objects can still be selected.
  64453. * Test : is the bounding sphere outside the frustum ?
  64454. * If not, then the cullable object is in the frustum.
  64455. */
  64456. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64457. /** Culling strategy : Optimistic Inclusion.
  64458. * This in an inclusion test first, then the standard exclusion test.
  64459. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64460. * 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.
  64461. * Anyway, it's as accurate as the standard strategy.
  64462. * Test :
  64463. * Is the cullable object bounding sphere center in the frustum ?
  64464. * If not, apply the default culling strategy.
  64465. */
  64466. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64467. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64468. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64469. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64470. * 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.
  64471. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64472. * Test :
  64473. * Is the cullable object bounding sphere center in the frustum ?
  64474. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64475. */
  64476. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64477. /**
  64478. * No logging while loading
  64479. */
  64480. static readonly SCENELOADER_NO_LOGGING: number;
  64481. /**
  64482. * Minimal logging while loading
  64483. */
  64484. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64485. /**
  64486. * Summary logging while loading
  64487. */
  64488. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64489. /**
  64490. * Detailled logging while loading
  64491. */
  64492. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64493. }
  64494. }
  64495. declare module BABYLON {
  64496. /**
  64497. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64498. * Babylon.js
  64499. */
  64500. export class DomManagement {
  64501. /**
  64502. * Checks if the window object exists
  64503. * @returns true if the window object exists
  64504. */
  64505. static IsWindowObjectExist(): boolean;
  64506. /**
  64507. * Extracts text content from a DOM element hierarchy
  64508. * @param element defines the root element
  64509. * @returns a string
  64510. */
  64511. static GetDOMTextContent(element: HTMLElement): string;
  64512. }
  64513. }
  64514. declare module BABYLON {
  64515. /**
  64516. * Logger used througouht the application to allow configuration of
  64517. * the log level required for the messages.
  64518. */
  64519. export class Logger {
  64520. /**
  64521. * No log
  64522. */
  64523. static readonly NoneLogLevel: number;
  64524. /**
  64525. * Only message logs
  64526. */
  64527. static readonly MessageLogLevel: number;
  64528. /**
  64529. * Only warning logs
  64530. */
  64531. static readonly WarningLogLevel: number;
  64532. /**
  64533. * Only error logs
  64534. */
  64535. static readonly ErrorLogLevel: number;
  64536. /**
  64537. * All logs
  64538. */
  64539. static readonly AllLogLevel: number;
  64540. private static _LogCache;
  64541. /**
  64542. * Gets a value indicating the number of loading errors
  64543. * @ignorenaming
  64544. */
  64545. static errorsCount: number;
  64546. /**
  64547. * Callback called when a new log is added
  64548. */
  64549. static OnNewCacheEntry: (entry: string) => void;
  64550. private static _AddLogEntry;
  64551. private static _FormatMessage;
  64552. private static _LogDisabled;
  64553. private static _LogEnabled;
  64554. private static _WarnDisabled;
  64555. private static _WarnEnabled;
  64556. private static _ErrorDisabled;
  64557. private static _ErrorEnabled;
  64558. /**
  64559. * Log a message to the console
  64560. */
  64561. static Log: (message: string) => void;
  64562. /**
  64563. * Write a warning message to the console
  64564. */
  64565. static Warn: (message: string) => void;
  64566. /**
  64567. * Write an error message to the console
  64568. */
  64569. static Error: (message: string) => void;
  64570. /**
  64571. * Gets current log cache (list of logs)
  64572. */
  64573. static readonly LogCache: string;
  64574. /**
  64575. * Clears the log cache
  64576. */
  64577. static ClearLogCache(): void;
  64578. /**
  64579. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64580. */
  64581. static LogLevels: number;
  64582. }
  64583. }
  64584. declare module BABYLON {
  64585. /** @hidden */
  64586. export class _TypeStore {
  64587. /** @hidden */
  64588. static RegisteredTypes: {
  64589. [key: string]: Object;
  64590. };
  64591. /** @hidden */
  64592. static GetClass(fqdn: string): any;
  64593. }
  64594. }
  64595. declare module BABYLON {
  64596. /**
  64597. * Class containing a set of static utilities functions for deep copy.
  64598. */
  64599. export class DeepCopier {
  64600. /**
  64601. * Tries to copy an object by duplicating every property
  64602. * @param source defines the source object
  64603. * @param destination defines the target object
  64604. * @param doNotCopyList defines a list of properties to avoid
  64605. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64606. */
  64607. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64608. }
  64609. }
  64610. declare module BABYLON {
  64611. /**
  64612. * Class containing a set of static utilities functions for precision date
  64613. */
  64614. export class PrecisionDate {
  64615. /**
  64616. * Gets either window.performance.now() if supported or Date.now() else
  64617. */
  64618. static readonly Now: number;
  64619. }
  64620. }
  64621. declare module BABYLON {
  64622. /** @hidden */
  64623. export class _DevTools {
  64624. static WarnImport(name: string): string;
  64625. }
  64626. }
  64627. declare module BABYLON {
  64628. /**
  64629. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64630. */
  64631. export class WebRequest {
  64632. private _xhr;
  64633. /**
  64634. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64635. * i.e. when loading files, where the server/service expects an Authorization header
  64636. */
  64637. static CustomRequestHeaders: {
  64638. [key: string]: string;
  64639. };
  64640. /**
  64641. * Add callback functions in this array to update all the requests before they get sent to the network
  64642. */
  64643. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64644. private _injectCustomRequestHeaders;
  64645. /**
  64646. * Gets or sets a function to be called when loading progress changes
  64647. */
  64648. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64649. /**
  64650. * Returns client's state
  64651. */
  64652. readonly readyState: number;
  64653. /**
  64654. * Returns client's status
  64655. */
  64656. readonly status: number;
  64657. /**
  64658. * Returns client's status as a text
  64659. */
  64660. readonly statusText: string;
  64661. /**
  64662. * Returns client's response
  64663. */
  64664. readonly response: any;
  64665. /**
  64666. * Returns client's response url
  64667. */
  64668. readonly responseURL: string;
  64669. /**
  64670. * Returns client's response as text
  64671. */
  64672. readonly responseText: string;
  64673. /**
  64674. * Gets or sets the expected response type
  64675. */
  64676. responseType: XMLHttpRequestResponseType;
  64677. /** @hidden */
  64678. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64679. /** @hidden */
  64680. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64681. /**
  64682. * Cancels any network activity
  64683. */
  64684. abort(): void;
  64685. /**
  64686. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64687. * @param body defines an optional request body
  64688. */
  64689. send(body?: Document | BodyInit | null): void;
  64690. /**
  64691. * Sets the request method, request URL
  64692. * @param method defines the method to use (GET, POST, etc..)
  64693. * @param url defines the url to connect with
  64694. */
  64695. open(method: string, url: string): void;
  64696. }
  64697. }
  64698. declare module BABYLON {
  64699. /**
  64700. * Class used to evalaute queries containing `and` and `or` operators
  64701. */
  64702. export class AndOrNotEvaluator {
  64703. /**
  64704. * Evaluate a query
  64705. * @param query defines the query to evaluate
  64706. * @param evaluateCallback defines the callback used to filter result
  64707. * @returns true if the query matches
  64708. */
  64709. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64710. private static _HandleParenthesisContent;
  64711. private static _SimplifyNegation;
  64712. }
  64713. }
  64714. declare module BABYLON {
  64715. /**
  64716. * Class used to store custom tags
  64717. */
  64718. export class Tags {
  64719. /**
  64720. * Adds support for tags on the given object
  64721. * @param obj defines the object to use
  64722. */
  64723. static EnableFor(obj: any): void;
  64724. /**
  64725. * Removes tags support
  64726. * @param obj defines the object to use
  64727. */
  64728. static DisableFor(obj: any): void;
  64729. /**
  64730. * Gets a boolean indicating if the given object has tags
  64731. * @param obj defines the object to use
  64732. * @returns a boolean
  64733. */
  64734. static HasTags(obj: any): boolean;
  64735. /**
  64736. * Gets the tags available on a given object
  64737. * @param obj defines the object to use
  64738. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64739. * @returns the tags
  64740. */
  64741. static GetTags(obj: any, asString?: boolean): any;
  64742. /**
  64743. * Adds tags to an object
  64744. * @param obj defines the object to use
  64745. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64746. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64747. */
  64748. static AddTagsTo(obj: any, tagsString: string): void;
  64749. /**
  64750. * @hidden
  64751. */
  64752. static _AddTagTo(obj: any, tag: string): void;
  64753. /**
  64754. * Removes specific tags from a specific object
  64755. * @param obj defines the object to use
  64756. * @param tagsString defines the tags to remove
  64757. */
  64758. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64759. /**
  64760. * @hidden
  64761. */
  64762. static _RemoveTagFrom(obj: any, tag: string): void;
  64763. /**
  64764. * Defines if tags hosted on an object match a given query
  64765. * @param obj defines the object to use
  64766. * @param tagsQuery defines the tag query
  64767. * @returns a boolean
  64768. */
  64769. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64770. }
  64771. }
  64772. declare module BABYLON {
  64773. /**
  64774. * Manages the defines for the Material
  64775. */
  64776. export class MaterialDefines {
  64777. private _keys;
  64778. private _isDirty;
  64779. /** @hidden */
  64780. _renderId: number;
  64781. /** @hidden */
  64782. _areLightsDirty: boolean;
  64783. /** @hidden */
  64784. _areAttributesDirty: boolean;
  64785. /** @hidden */
  64786. _areTexturesDirty: boolean;
  64787. /** @hidden */
  64788. _areFresnelDirty: boolean;
  64789. /** @hidden */
  64790. _areMiscDirty: boolean;
  64791. /** @hidden */
  64792. _areImageProcessingDirty: boolean;
  64793. /** @hidden */
  64794. _normals: boolean;
  64795. /** @hidden */
  64796. _uvs: boolean;
  64797. /** @hidden */
  64798. _needNormals: boolean;
  64799. /** @hidden */
  64800. _needUVs: boolean;
  64801. /**
  64802. * Specifies if the material needs to be re-calculated
  64803. */
  64804. readonly isDirty: boolean;
  64805. /**
  64806. * Marks the material to indicate that it has been re-calculated
  64807. */
  64808. markAsProcessed(): void;
  64809. /**
  64810. * Marks the material to indicate that it needs to be re-calculated
  64811. */
  64812. markAsUnprocessed(): void;
  64813. /**
  64814. * Marks the material to indicate all of its defines need to be re-calculated
  64815. */
  64816. markAllAsDirty(): void;
  64817. /**
  64818. * Marks the material to indicate that image processing needs to be re-calculated
  64819. */
  64820. markAsImageProcessingDirty(): void;
  64821. /**
  64822. * Marks the material to indicate the lights need to be re-calculated
  64823. */
  64824. markAsLightDirty(): void;
  64825. /**
  64826. * Marks the attribute state as changed
  64827. */
  64828. markAsAttributesDirty(): void;
  64829. /**
  64830. * Marks the texture state as changed
  64831. */
  64832. markAsTexturesDirty(): void;
  64833. /**
  64834. * Marks the fresnel state as changed
  64835. */
  64836. markAsFresnelDirty(): void;
  64837. /**
  64838. * Marks the misc state as changed
  64839. */
  64840. markAsMiscDirty(): void;
  64841. /**
  64842. * Rebuilds the material defines
  64843. */
  64844. rebuild(): void;
  64845. /**
  64846. * Specifies if two material defines are equal
  64847. * @param other - A material define instance to compare to
  64848. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64849. */
  64850. isEqual(other: MaterialDefines): boolean;
  64851. /**
  64852. * Clones this instance's defines to another instance
  64853. * @param other - material defines to clone values to
  64854. */
  64855. cloneTo(other: MaterialDefines): void;
  64856. /**
  64857. * Resets the material define values
  64858. */
  64859. reset(): void;
  64860. /**
  64861. * Converts the material define values to a string
  64862. * @returns - String of material define information
  64863. */
  64864. toString(): string;
  64865. }
  64866. }
  64867. declare module BABYLON {
  64868. /**
  64869. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64870. */
  64871. export class PerformanceMonitor {
  64872. private _enabled;
  64873. private _rollingFrameTime;
  64874. private _lastFrameTimeMs;
  64875. /**
  64876. * constructor
  64877. * @param frameSampleSize The number of samples required to saturate the sliding window
  64878. */
  64879. constructor(frameSampleSize?: number);
  64880. /**
  64881. * Samples current frame
  64882. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64883. */
  64884. sampleFrame(timeMs?: number): void;
  64885. /**
  64886. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64887. */
  64888. readonly averageFrameTime: number;
  64889. /**
  64890. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64891. */
  64892. readonly averageFrameTimeVariance: number;
  64893. /**
  64894. * Returns the frame time of the most recent frame
  64895. */
  64896. readonly instantaneousFrameTime: number;
  64897. /**
  64898. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64899. */
  64900. readonly averageFPS: number;
  64901. /**
  64902. * Returns the average framerate in frames per second using the most recent frame time
  64903. */
  64904. readonly instantaneousFPS: number;
  64905. /**
  64906. * Returns true if enough samples have been taken to completely fill the sliding window
  64907. */
  64908. readonly isSaturated: boolean;
  64909. /**
  64910. * Enables contributions to the sliding window sample set
  64911. */
  64912. enable(): void;
  64913. /**
  64914. * Disables contributions to the sliding window sample set
  64915. * Samples will not be interpolated over the disabled period
  64916. */
  64917. disable(): void;
  64918. /**
  64919. * Returns true if sampling is enabled
  64920. */
  64921. readonly isEnabled: boolean;
  64922. /**
  64923. * Resets performance monitor
  64924. */
  64925. reset(): void;
  64926. }
  64927. /**
  64928. * RollingAverage
  64929. *
  64930. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64931. */
  64932. export class RollingAverage {
  64933. /**
  64934. * Current average
  64935. */
  64936. average: number;
  64937. /**
  64938. * Current variance
  64939. */
  64940. variance: number;
  64941. protected _samples: Array<number>;
  64942. protected _sampleCount: number;
  64943. protected _pos: number;
  64944. protected _m2: number;
  64945. /**
  64946. * constructor
  64947. * @param length The number of samples required to saturate the sliding window
  64948. */
  64949. constructor(length: number);
  64950. /**
  64951. * Adds a sample to the sample set
  64952. * @param v The sample value
  64953. */
  64954. add(v: number): void;
  64955. /**
  64956. * Returns previously added values or null if outside of history or outside the sliding window domain
  64957. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64958. * @return Value previously recorded with add() or null if outside of range
  64959. */
  64960. history(i: number): number;
  64961. /**
  64962. * Returns true if enough samples have been taken to completely fill the sliding window
  64963. * @return true if sample-set saturated
  64964. */
  64965. isSaturated(): boolean;
  64966. /**
  64967. * Resets the rolling average (equivalent to 0 samples taken so far)
  64968. */
  64969. reset(): void;
  64970. /**
  64971. * Wraps a value around the sample range boundaries
  64972. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64973. * @return Wrapped position in sample range
  64974. */
  64975. protected _wrapPosition(i: number): number;
  64976. }
  64977. }
  64978. declare module BABYLON {
  64979. /**
  64980. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64981. * The underlying implementation relies on an associative array to ensure the best performances.
  64982. * The value can be anything including 'null' but except 'undefined'
  64983. */
  64984. export class StringDictionary<T> {
  64985. /**
  64986. * This will clear this dictionary and copy the content from the 'source' one.
  64987. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64988. * @param source the dictionary to take the content from and copy to this dictionary
  64989. */
  64990. copyFrom(source: StringDictionary<T>): void;
  64991. /**
  64992. * Get a value based from its key
  64993. * @param key the given key to get the matching value from
  64994. * @return the value if found, otherwise undefined is returned
  64995. */
  64996. get(key: string): T | undefined;
  64997. /**
  64998. * Get a value from its key or add it if it doesn't exist.
  64999. * This method will ensure you that a given key/data will be present in the dictionary.
  65000. * @param key the given key to get the matching value from
  65001. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65002. * The factory will only be invoked if there's no data for the given key.
  65003. * @return the value corresponding to the key.
  65004. */
  65005. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65006. /**
  65007. * Get a value from its key if present in the dictionary otherwise add it
  65008. * @param key the key to get the value from
  65009. * @param val if there's no such key/value pair in the dictionary add it with this value
  65010. * @return the value corresponding to the key
  65011. */
  65012. getOrAdd(key: string, val: T): T;
  65013. /**
  65014. * Check if there's a given key in the dictionary
  65015. * @param key the key to check for
  65016. * @return true if the key is present, false otherwise
  65017. */
  65018. contains(key: string): boolean;
  65019. /**
  65020. * Add a new key and its corresponding value
  65021. * @param key the key to add
  65022. * @param value the value corresponding to the key
  65023. * @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
  65024. */
  65025. add(key: string, value: T): boolean;
  65026. /**
  65027. * Update a specific value associated to a key
  65028. * @param key defines the key to use
  65029. * @param value defines the value to store
  65030. * @returns true if the value was updated (or false if the key was not found)
  65031. */
  65032. set(key: string, value: T): boolean;
  65033. /**
  65034. * Get the element of the given key and remove it from the dictionary
  65035. * @param key defines the key to search
  65036. * @returns the value associated with the key or null if not found
  65037. */
  65038. getAndRemove(key: string): Nullable<T>;
  65039. /**
  65040. * Remove a key/value from the dictionary.
  65041. * @param key the key to remove
  65042. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65043. */
  65044. remove(key: string): boolean;
  65045. /**
  65046. * Clear the whole content of the dictionary
  65047. */
  65048. clear(): void;
  65049. /**
  65050. * Gets the current count
  65051. */
  65052. readonly count: number;
  65053. /**
  65054. * Execute a callback on each key/val of the dictionary.
  65055. * Note that you can remove any element in this dictionary in the callback implementation
  65056. * @param callback the callback to execute on a given key/value pair
  65057. */
  65058. forEach(callback: (key: string, val: T) => void): void;
  65059. /**
  65060. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65061. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65062. * Note that you can remove any element in this dictionary in the callback implementation
  65063. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65064. * @returns the first item
  65065. */
  65066. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65067. private _count;
  65068. private _data;
  65069. }
  65070. }
  65071. declare module BABYLON {
  65072. /**
  65073. * Helper class that provides a small promise polyfill
  65074. */
  65075. export class PromisePolyfill {
  65076. /**
  65077. * Static function used to check if the polyfill is required
  65078. * If this is the case then the function will inject the polyfill to window.Promise
  65079. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65080. */
  65081. static Apply(force?: boolean): void;
  65082. }
  65083. }
  65084. declare module BABYLON {
  65085. /**
  65086. * Class used to store data that will be store in GPU memory
  65087. */
  65088. export class Buffer {
  65089. private _engine;
  65090. private _buffer;
  65091. /** @hidden */
  65092. _data: Nullable<DataArray>;
  65093. private _updatable;
  65094. private _instanced;
  65095. /**
  65096. * Gets the byte stride.
  65097. */
  65098. readonly byteStride: number;
  65099. /**
  65100. * Constructor
  65101. * @param engine the engine
  65102. * @param data the data to use for this buffer
  65103. * @param updatable whether the data is updatable
  65104. * @param stride the stride (optional)
  65105. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65106. * @param instanced whether the buffer is instanced (optional)
  65107. * @param useBytes set to true if the stride in in bytes (optional)
  65108. */
  65109. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65110. /**
  65111. * Create a new VertexBuffer based on the current buffer
  65112. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65113. * @param offset defines offset in the buffer (0 by default)
  65114. * @param size defines the size in floats of attributes (position is 3 for instance)
  65115. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65116. * @param instanced defines if the vertex buffer contains indexed data
  65117. * @param useBytes defines if the offset and stride are in bytes
  65118. * @returns the new vertex buffer
  65119. */
  65120. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65121. /**
  65122. * Gets a boolean indicating if the Buffer is updatable?
  65123. * @returns true if the buffer is updatable
  65124. */
  65125. isUpdatable(): boolean;
  65126. /**
  65127. * Gets current buffer's data
  65128. * @returns a DataArray or null
  65129. */
  65130. getData(): Nullable<DataArray>;
  65131. /**
  65132. * Gets underlying native buffer
  65133. * @returns underlying native buffer
  65134. */
  65135. getBuffer(): Nullable<WebGLBuffer>;
  65136. /**
  65137. * Gets the stride in float32 units (i.e. byte stride / 4).
  65138. * May not be an integer if the byte stride is not divisible by 4.
  65139. * DEPRECATED. Use byteStride instead.
  65140. * @returns the stride in float32 units
  65141. */
  65142. getStrideSize(): number;
  65143. /**
  65144. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65145. * @param data defines the data to store
  65146. */
  65147. create(data?: Nullable<DataArray>): void;
  65148. /** @hidden */
  65149. _rebuild(): void;
  65150. /**
  65151. * Update current buffer data
  65152. * @param data defines the data to store
  65153. */
  65154. update(data: DataArray): void;
  65155. /**
  65156. * Updates the data directly.
  65157. * @param data the new data
  65158. * @param offset the new offset
  65159. * @param vertexCount the vertex count (optional)
  65160. * @param useBytes set to true if the offset is in bytes
  65161. */
  65162. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65163. /**
  65164. * Release all resources
  65165. */
  65166. dispose(): void;
  65167. }
  65168. /**
  65169. * Specialized buffer used to store vertex data
  65170. */
  65171. export class VertexBuffer {
  65172. /** @hidden */
  65173. _buffer: Buffer;
  65174. private _kind;
  65175. private _size;
  65176. private _ownsBuffer;
  65177. private _instanced;
  65178. private _instanceDivisor;
  65179. /**
  65180. * The byte type.
  65181. */
  65182. static readonly BYTE: number;
  65183. /**
  65184. * The unsigned byte type.
  65185. */
  65186. static readonly UNSIGNED_BYTE: number;
  65187. /**
  65188. * The short type.
  65189. */
  65190. static readonly SHORT: number;
  65191. /**
  65192. * The unsigned short type.
  65193. */
  65194. static readonly UNSIGNED_SHORT: number;
  65195. /**
  65196. * The integer type.
  65197. */
  65198. static readonly INT: number;
  65199. /**
  65200. * The unsigned integer type.
  65201. */
  65202. static readonly UNSIGNED_INT: number;
  65203. /**
  65204. * The float type.
  65205. */
  65206. static readonly FLOAT: number;
  65207. /**
  65208. * Gets or sets the instance divisor when in instanced mode
  65209. */
  65210. instanceDivisor: number;
  65211. /**
  65212. * Gets the byte stride.
  65213. */
  65214. readonly byteStride: number;
  65215. /**
  65216. * Gets the byte offset.
  65217. */
  65218. readonly byteOffset: number;
  65219. /**
  65220. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65221. */
  65222. readonly normalized: boolean;
  65223. /**
  65224. * Gets the data type of each component in the array.
  65225. */
  65226. readonly type: number;
  65227. /**
  65228. * Constructor
  65229. * @param engine the engine
  65230. * @param data the data to use for this vertex buffer
  65231. * @param kind the vertex buffer kind
  65232. * @param updatable whether the data is updatable
  65233. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65234. * @param stride the stride (optional)
  65235. * @param instanced whether the buffer is instanced (optional)
  65236. * @param offset the offset of the data (optional)
  65237. * @param size the number of components (optional)
  65238. * @param type the type of the component (optional)
  65239. * @param normalized whether the data contains normalized data (optional)
  65240. * @param useBytes set to true if stride and offset are in bytes (optional)
  65241. */
  65242. 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);
  65243. /** @hidden */
  65244. _rebuild(): void;
  65245. /**
  65246. * Returns the kind of the VertexBuffer (string)
  65247. * @returns a string
  65248. */
  65249. getKind(): string;
  65250. /**
  65251. * Gets a boolean indicating if the VertexBuffer is updatable?
  65252. * @returns true if the buffer is updatable
  65253. */
  65254. isUpdatable(): boolean;
  65255. /**
  65256. * Gets current buffer's data
  65257. * @returns a DataArray or null
  65258. */
  65259. getData(): Nullable<DataArray>;
  65260. /**
  65261. * Gets underlying native buffer
  65262. * @returns underlying native buffer
  65263. */
  65264. getBuffer(): Nullable<WebGLBuffer>;
  65265. /**
  65266. * Gets the stride in float32 units (i.e. byte stride / 4).
  65267. * May not be an integer if the byte stride is not divisible by 4.
  65268. * DEPRECATED. Use byteStride instead.
  65269. * @returns the stride in float32 units
  65270. */
  65271. getStrideSize(): number;
  65272. /**
  65273. * Returns the offset as a multiple of the type byte length.
  65274. * DEPRECATED. Use byteOffset instead.
  65275. * @returns the offset in bytes
  65276. */
  65277. getOffset(): number;
  65278. /**
  65279. * Returns the number of components per vertex attribute (integer)
  65280. * @returns the size in float
  65281. */
  65282. getSize(): number;
  65283. /**
  65284. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65285. * @returns true if this buffer is instanced
  65286. */
  65287. getIsInstanced(): boolean;
  65288. /**
  65289. * Returns the instancing divisor, zero for non-instanced (integer).
  65290. * @returns a number
  65291. */
  65292. getInstanceDivisor(): number;
  65293. /**
  65294. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65295. * @param data defines the data to store
  65296. */
  65297. create(data?: DataArray): void;
  65298. /**
  65299. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65300. * This function will create a new buffer if the current one is not updatable
  65301. * @param data defines the data to store
  65302. */
  65303. update(data: DataArray): void;
  65304. /**
  65305. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65306. * Returns the directly updated WebGLBuffer.
  65307. * @param data the new data
  65308. * @param offset the new offset
  65309. * @param useBytes set to true if the offset is in bytes
  65310. */
  65311. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65312. /**
  65313. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65314. */
  65315. dispose(): void;
  65316. /**
  65317. * Enumerates each value of this vertex buffer as numbers.
  65318. * @param count the number of values to enumerate
  65319. * @param callback the callback function called for each value
  65320. */
  65321. forEach(count: number, callback: (value: number, index: number) => void): void;
  65322. /**
  65323. * Positions
  65324. */
  65325. static readonly PositionKind: string;
  65326. /**
  65327. * Normals
  65328. */
  65329. static readonly NormalKind: string;
  65330. /**
  65331. * Tangents
  65332. */
  65333. static readonly TangentKind: string;
  65334. /**
  65335. * Texture coordinates
  65336. */
  65337. static readonly UVKind: string;
  65338. /**
  65339. * Texture coordinates 2
  65340. */
  65341. static readonly UV2Kind: string;
  65342. /**
  65343. * Texture coordinates 3
  65344. */
  65345. static readonly UV3Kind: string;
  65346. /**
  65347. * Texture coordinates 4
  65348. */
  65349. static readonly UV4Kind: string;
  65350. /**
  65351. * Texture coordinates 5
  65352. */
  65353. static readonly UV5Kind: string;
  65354. /**
  65355. * Texture coordinates 6
  65356. */
  65357. static readonly UV6Kind: string;
  65358. /**
  65359. * Colors
  65360. */
  65361. static readonly ColorKind: string;
  65362. /**
  65363. * Matrix indices (for bones)
  65364. */
  65365. static readonly MatricesIndicesKind: string;
  65366. /**
  65367. * Matrix weights (for bones)
  65368. */
  65369. static readonly MatricesWeightsKind: string;
  65370. /**
  65371. * Additional matrix indices (for bones)
  65372. */
  65373. static readonly MatricesIndicesExtraKind: string;
  65374. /**
  65375. * Additional matrix weights (for bones)
  65376. */
  65377. static readonly MatricesWeightsExtraKind: string;
  65378. /**
  65379. * Deduces the stride given a kind.
  65380. * @param kind The kind string to deduce
  65381. * @returns The deduced stride
  65382. */
  65383. static DeduceStride(kind: string): number;
  65384. /**
  65385. * Gets the byte length of the given type.
  65386. * @param type the type
  65387. * @returns the number of bytes
  65388. */
  65389. static GetTypeByteLength(type: number): number;
  65390. /**
  65391. * Enumerates each value of the given parameters as numbers.
  65392. * @param data the data to enumerate
  65393. * @param byteOffset the byte offset of the data
  65394. * @param byteStride the byte stride of the data
  65395. * @param componentCount the number of components per element
  65396. * @param componentType the type of the component
  65397. * @param count the total number of components
  65398. * @param normalized whether the data is normalized
  65399. * @param callback the callback function called for each value
  65400. */
  65401. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65402. private static _GetFloatValue;
  65403. }
  65404. }
  65405. declare module BABYLON {
  65406. /**
  65407. * Class representing spherical polynomial coefficients to the 3rd degree
  65408. */
  65409. export class SphericalPolynomial {
  65410. /**
  65411. * The x coefficients of the spherical polynomial
  65412. */
  65413. x: Vector3;
  65414. /**
  65415. * The y coefficients of the spherical polynomial
  65416. */
  65417. y: Vector3;
  65418. /**
  65419. * The z coefficients of the spherical polynomial
  65420. */
  65421. z: Vector3;
  65422. /**
  65423. * The xx coefficients of the spherical polynomial
  65424. */
  65425. xx: Vector3;
  65426. /**
  65427. * The yy coefficients of the spherical polynomial
  65428. */
  65429. yy: Vector3;
  65430. /**
  65431. * The zz coefficients of the spherical polynomial
  65432. */
  65433. zz: Vector3;
  65434. /**
  65435. * The xy coefficients of the spherical polynomial
  65436. */
  65437. xy: Vector3;
  65438. /**
  65439. * The yz coefficients of the spherical polynomial
  65440. */
  65441. yz: Vector3;
  65442. /**
  65443. * The zx coefficients of the spherical polynomial
  65444. */
  65445. zx: Vector3;
  65446. /**
  65447. * Adds an ambient color to the spherical polynomial
  65448. * @param color the color to add
  65449. */
  65450. addAmbient(color: Color3): void;
  65451. /**
  65452. * Scales the spherical polynomial by the given amount
  65453. * @param scale the amount to scale
  65454. */
  65455. scale(scale: number): void;
  65456. /**
  65457. * Gets the spherical polynomial from harmonics
  65458. * @param harmonics the spherical harmonics
  65459. * @returns the spherical polynomial
  65460. */
  65461. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65462. /**
  65463. * Constructs a spherical polynomial from an array.
  65464. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65465. * @returns the spherical polynomial
  65466. */
  65467. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65468. }
  65469. /**
  65470. * Class representing spherical harmonics coefficients to the 3rd degree
  65471. */
  65472. export class SphericalHarmonics {
  65473. /**
  65474. * The l0,0 coefficients of the spherical harmonics
  65475. */
  65476. l00: Vector3;
  65477. /**
  65478. * The l1,-1 coefficients of the spherical harmonics
  65479. */
  65480. l1_1: Vector3;
  65481. /**
  65482. * The l1,0 coefficients of the spherical harmonics
  65483. */
  65484. l10: Vector3;
  65485. /**
  65486. * The l1,1 coefficients of the spherical harmonics
  65487. */
  65488. l11: Vector3;
  65489. /**
  65490. * The l2,-2 coefficients of the spherical harmonics
  65491. */
  65492. l2_2: Vector3;
  65493. /**
  65494. * The l2,-1 coefficients of the spherical harmonics
  65495. */
  65496. l2_1: Vector3;
  65497. /**
  65498. * The l2,0 coefficients of the spherical harmonics
  65499. */
  65500. l20: Vector3;
  65501. /**
  65502. * The l2,1 coefficients of the spherical harmonics
  65503. */
  65504. l21: Vector3;
  65505. /**
  65506. * The l2,2 coefficients of the spherical harmonics
  65507. */
  65508. lL22: Vector3;
  65509. /**
  65510. * Adds a light to the spherical harmonics
  65511. * @param direction the direction of the light
  65512. * @param color the color of the light
  65513. * @param deltaSolidAngle the delta solid angle of the light
  65514. */
  65515. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65516. /**
  65517. * Scales the spherical harmonics by the given amount
  65518. * @param scale the amount to scale
  65519. */
  65520. scale(scale: number): void;
  65521. /**
  65522. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65523. *
  65524. * ```
  65525. * E_lm = A_l * L_lm
  65526. * ```
  65527. *
  65528. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65529. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65530. * the scaling factors are given in equation 9.
  65531. */
  65532. convertIncidentRadianceToIrradiance(): void;
  65533. /**
  65534. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65535. *
  65536. * ```
  65537. * L = (1/pi) * E * rho
  65538. * ```
  65539. *
  65540. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65541. */
  65542. convertIrradianceToLambertianRadiance(): void;
  65543. /**
  65544. * Gets the spherical harmonics from polynomial
  65545. * @param polynomial the spherical polynomial
  65546. * @returns the spherical harmonics
  65547. */
  65548. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65549. /**
  65550. * Constructs a spherical harmonics from an array.
  65551. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65552. * @returns the spherical harmonics
  65553. */
  65554. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65555. }
  65556. }
  65557. declare module BABYLON {
  65558. /**
  65559. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65560. */
  65561. export interface CubeMapInfo {
  65562. /**
  65563. * The pixel array for the front face.
  65564. * This is stored in format, left to right, up to down format.
  65565. */
  65566. front: Nullable<ArrayBufferView>;
  65567. /**
  65568. * The pixel array for the back face.
  65569. * This is stored in format, left to right, up to down format.
  65570. */
  65571. back: Nullable<ArrayBufferView>;
  65572. /**
  65573. * The pixel array for the left face.
  65574. * This is stored in format, left to right, up to down format.
  65575. */
  65576. left: Nullable<ArrayBufferView>;
  65577. /**
  65578. * The pixel array for the right face.
  65579. * This is stored in format, left to right, up to down format.
  65580. */
  65581. right: Nullable<ArrayBufferView>;
  65582. /**
  65583. * The pixel array for the up face.
  65584. * This is stored in format, left to right, up to down format.
  65585. */
  65586. up: Nullable<ArrayBufferView>;
  65587. /**
  65588. * The pixel array for the down face.
  65589. * This is stored in format, left to right, up to down format.
  65590. */
  65591. down: Nullable<ArrayBufferView>;
  65592. /**
  65593. * The size of the cubemap stored.
  65594. *
  65595. * Each faces will be size * size pixels.
  65596. */
  65597. size: number;
  65598. /**
  65599. * The format of the texture.
  65600. *
  65601. * RGBA, RGB.
  65602. */
  65603. format: number;
  65604. /**
  65605. * The type of the texture data.
  65606. *
  65607. * UNSIGNED_INT, FLOAT.
  65608. */
  65609. type: number;
  65610. /**
  65611. * Specifies whether the texture is in gamma space.
  65612. */
  65613. gammaSpace: boolean;
  65614. }
  65615. /**
  65616. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65617. */
  65618. export class PanoramaToCubeMapTools {
  65619. private static FACE_FRONT;
  65620. private static FACE_BACK;
  65621. private static FACE_RIGHT;
  65622. private static FACE_LEFT;
  65623. private static FACE_DOWN;
  65624. private static FACE_UP;
  65625. /**
  65626. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65627. *
  65628. * @param float32Array The source data.
  65629. * @param inputWidth The width of the input panorama.
  65630. * @param inputHeight The height of the input panorama.
  65631. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65632. * @return The cubemap data
  65633. */
  65634. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65635. private static CreateCubemapTexture;
  65636. private static CalcProjectionSpherical;
  65637. }
  65638. }
  65639. declare module BABYLON {
  65640. /**
  65641. * Helper class dealing with the extraction of spherical polynomial dataArray
  65642. * from a cube map.
  65643. */
  65644. export class CubeMapToSphericalPolynomialTools {
  65645. private static FileFaces;
  65646. /**
  65647. * Converts a texture to the according Spherical Polynomial data.
  65648. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65649. *
  65650. * @param texture The texture to extract the information from.
  65651. * @return The Spherical Polynomial data.
  65652. */
  65653. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65654. /**
  65655. * Converts a cubemap to the according Spherical Polynomial data.
  65656. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65657. *
  65658. * @param cubeInfo The Cube map to extract the information from.
  65659. * @return The Spherical Polynomial data.
  65660. */
  65661. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65662. }
  65663. }
  65664. declare module BABYLON {
  65665. /**
  65666. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65667. * during the life time of the application.
  65668. */
  65669. export class EngineStore {
  65670. /** Gets the list of created engines */
  65671. static Instances: Engine[];
  65672. /**
  65673. * Gets the latest created engine
  65674. */
  65675. static readonly LastCreatedEngine: Nullable<Engine>;
  65676. /**
  65677. * Gets the latest created scene
  65678. */
  65679. static readonly LastCreatedScene: Nullable<Scene>;
  65680. }
  65681. }
  65682. declare module BABYLON {
  65683. /**
  65684. * Define options used to create a render target texture
  65685. */
  65686. export class RenderTargetCreationOptions {
  65687. /**
  65688. * Specifies is mipmaps must be generated
  65689. */
  65690. generateMipMaps?: boolean;
  65691. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65692. generateDepthBuffer?: boolean;
  65693. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65694. generateStencilBuffer?: boolean;
  65695. /** Defines texture type (int by default) */
  65696. type?: number;
  65697. /** Defines sampling mode (trilinear by default) */
  65698. samplingMode?: number;
  65699. /** Defines format (RGBA by default) */
  65700. format?: number;
  65701. }
  65702. }
  65703. declare module BABYLON {
  65704. /**
  65705. * @hidden
  65706. **/
  65707. export class _AlphaState {
  65708. private _isAlphaBlendDirty;
  65709. private _isBlendFunctionParametersDirty;
  65710. private _isBlendEquationParametersDirty;
  65711. private _isBlendConstantsDirty;
  65712. private _alphaBlend;
  65713. private _blendFunctionParameters;
  65714. private _blendEquationParameters;
  65715. private _blendConstants;
  65716. /**
  65717. * Initializes the state.
  65718. */
  65719. constructor();
  65720. readonly isDirty: boolean;
  65721. alphaBlend: boolean;
  65722. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65723. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65724. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65725. reset(): void;
  65726. apply(gl: WebGLRenderingContext): void;
  65727. }
  65728. }
  65729. declare module BABYLON {
  65730. /**
  65731. * @hidden
  65732. **/
  65733. export class _DepthCullingState {
  65734. private _isDepthTestDirty;
  65735. private _isDepthMaskDirty;
  65736. private _isDepthFuncDirty;
  65737. private _isCullFaceDirty;
  65738. private _isCullDirty;
  65739. private _isZOffsetDirty;
  65740. private _isFrontFaceDirty;
  65741. private _depthTest;
  65742. private _depthMask;
  65743. private _depthFunc;
  65744. private _cull;
  65745. private _cullFace;
  65746. private _zOffset;
  65747. private _frontFace;
  65748. /**
  65749. * Initializes the state.
  65750. */
  65751. constructor();
  65752. readonly isDirty: boolean;
  65753. zOffset: number;
  65754. cullFace: Nullable<number>;
  65755. cull: Nullable<boolean>;
  65756. depthFunc: Nullable<number>;
  65757. depthMask: boolean;
  65758. depthTest: boolean;
  65759. frontFace: Nullable<number>;
  65760. reset(): void;
  65761. apply(gl: WebGLRenderingContext): void;
  65762. }
  65763. }
  65764. declare module BABYLON {
  65765. /**
  65766. * @hidden
  65767. **/
  65768. export class _StencilState {
  65769. /** 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 */
  65770. static readonly ALWAYS: number;
  65771. /** Passed to stencilOperation to specify that stencil value must be kept */
  65772. static readonly KEEP: number;
  65773. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65774. static readonly REPLACE: number;
  65775. private _isStencilTestDirty;
  65776. private _isStencilMaskDirty;
  65777. private _isStencilFuncDirty;
  65778. private _isStencilOpDirty;
  65779. private _stencilTest;
  65780. private _stencilMask;
  65781. private _stencilFunc;
  65782. private _stencilFuncRef;
  65783. private _stencilFuncMask;
  65784. private _stencilOpStencilFail;
  65785. private _stencilOpDepthFail;
  65786. private _stencilOpStencilDepthPass;
  65787. readonly isDirty: boolean;
  65788. stencilFunc: number;
  65789. stencilFuncRef: number;
  65790. stencilFuncMask: number;
  65791. stencilOpStencilFail: number;
  65792. stencilOpDepthFail: number;
  65793. stencilOpStencilDepthPass: number;
  65794. stencilMask: number;
  65795. stencilTest: boolean;
  65796. constructor();
  65797. reset(): void;
  65798. apply(gl: WebGLRenderingContext): void;
  65799. }
  65800. }
  65801. declare module BABYLON {
  65802. /**
  65803. * @hidden
  65804. **/
  65805. export class _TimeToken {
  65806. _startTimeQuery: Nullable<WebGLQuery>;
  65807. _endTimeQuery: Nullable<WebGLQuery>;
  65808. _timeElapsedQuery: Nullable<WebGLQuery>;
  65809. _timeElapsedQueryEnded: boolean;
  65810. }
  65811. }
  65812. declare module BABYLON {
  65813. /**
  65814. * Class used to store data associated with WebGL texture data for the engine
  65815. * This class should not be used directly
  65816. */
  65817. export class InternalTexture {
  65818. /** hidden */
  65819. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65820. /**
  65821. * The source of the texture data is unknown
  65822. */
  65823. static DATASOURCE_UNKNOWN: number;
  65824. /**
  65825. * Texture data comes from an URL
  65826. */
  65827. static DATASOURCE_URL: number;
  65828. /**
  65829. * Texture data is only used for temporary storage
  65830. */
  65831. static DATASOURCE_TEMP: number;
  65832. /**
  65833. * Texture data comes from raw data (ArrayBuffer)
  65834. */
  65835. static DATASOURCE_RAW: number;
  65836. /**
  65837. * Texture content is dynamic (video or dynamic texture)
  65838. */
  65839. static DATASOURCE_DYNAMIC: number;
  65840. /**
  65841. * Texture content is generated by rendering to it
  65842. */
  65843. static DATASOURCE_RENDERTARGET: number;
  65844. /**
  65845. * Texture content is part of a multi render target process
  65846. */
  65847. static DATASOURCE_MULTIRENDERTARGET: number;
  65848. /**
  65849. * Texture data comes from a cube data file
  65850. */
  65851. static DATASOURCE_CUBE: number;
  65852. /**
  65853. * Texture data comes from a raw cube data
  65854. */
  65855. static DATASOURCE_CUBERAW: number;
  65856. /**
  65857. * Texture data come from a prefiltered cube data file
  65858. */
  65859. static DATASOURCE_CUBEPREFILTERED: number;
  65860. /**
  65861. * Texture content is raw 3D data
  65862. */
  65863. static DATASOURCE_RAW3D: number;
  65864. /**
  65865. * Texture content is a depth texture
  65866. */
  65867. static DATASOURCE_DEPTHTEXTURE: number;
  65868. /**
  65869. * Texture data comes from a raw cube data encoded with RGBD
  65870. */
  65871. static DATASOURCE_CUBERAW_RGBD: number;
  65872. /**
  65873. * Defines if the texture is ready
  65874. */
  65875. isReady: boolean;
  65876. /**
  65877. * Defines if the texture is a cube texture
  65878. */
  65879. isCube: boolean;
  65880. /**
  65881. * Defines if the texture contains 3D data
  65882. */
  65883. is3D: boolean;
  65884. /**
  65885. * Defines if the texture contains multiview data
  65886. */
  65887. isMultiview: boolean;
  65888. /**
  65889. * Gets the URL used to load this texture
  65890. */
  65891. url: string;
  65892. /**
  65893. * Gets the sampling mode of the texture
  65894. */
  65895. samplingMode: number;
  65896. /**
  65897. * Gets a boolean indicating if the texture needs mipmaps generation
  65898. */
  65899. generateMipMaps: boolean;
  65900. /**
  65901. * Gets the number of samples used by the texture (WebGL2+ only)
  65902. */
  65903. samples: number;
  65904. /**
  65905. * Gets the type of the texture (int, float...)
  65906. */
  65907. type: number;
  65908. /**
  65909. * Gets the format of the texture (RGB, RGBA...)
  65910. */
  65911. format: number;
  65912. /**
  65913. * Observable called when the texture is loaded
  65914. */
  65915. onLoadedObservable: Observable<InternalTexture>;
  65916. /**
  65917. * Gets the width of the texture
  65918. */
  65919. width: number;
  65920. /**
  65921. * Gets the height of the texture
  65922. */
  65923. height: number;
  65924. /**
  65925. * Gets the depth of the texture
  65926. */
  65927. depth: number;
  65928. /**
  65929. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  65930. */
  65931. baseWidth: number;
  65932. /**
  65933. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  65934. */
  65935. baseHeight: number;
  65936. /**
  65937. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  65938. */
  65939. baseDepth: number;
  65940. /**
  65941. * Gets a boolean indicating if the texture is inverted on Y axis
  65942. */
  65943. invertY: boolean;
  65944. /** @hidden */
  65945. _invertVScale: boolean;
  65946. /** @hidden */
  65947. _associatedChannel: number;
  65948. /** @hidden */
  65949. _dataSource: number;
  65950. /** @hidden */
  65951. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  65952. /** @hidden */
  65953. _bufferView: Nullable<ArrayBufferView>;
  65954. /** @hidden */
  65955. _bufferViewArray: Nullable<ArrayBufferView[]>;
  65956. /** @hidden */
  65957. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  65958. /** @hidden */
  65959. _size: number;
  65960. /** @hidden */
  65961. _extension: string;
  65962. /** @hidden */
  65963. _files: Nullable<string[]>;
  65964. /** @hidden */
  65965. _workingCanvas: Nullable<HTMLCanvasElement>;
  65966. /** @hidden */
  65967. _workingContext: Nullable<CanvasRenderingContext2D>;
  65968. /** @hidden */
  65969. _framebuffer: Nullable<WebGLFramebuffer>;
  65970. /** @hidden */
  65971. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  65972. /** @hidden */
  65973. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65974. /** @hidden */
  65975. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65976. /** @hidden */
  65977. _attachments: Nullable<number[]>;
  65978. /** @hidden */
  65979. _cachedCoordinatesMode: Nullable<number>;
  65980. /** @hidden */
  65981. _cachedWrapU: Nullable<number>;
  65982. /** @hidden */
  65983. _cachedWrapV: Nullable<number>;
  65984. /** @hidden */
  65985. _cachedWrapR: Nullable<number>;
  65986. /** @hidden */
  65987. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65988. /** @hidden */
  65989. _isDisabled: boolean;
  65990. /** @hidden */
  65991. _compression: Nullable<string>;
  65992. /** @hidden */
  65993. _generateStencilBuffer: boolean;
  65994. /** @hidden */
  65995. _generateDepthBuffer: boolean;
  65996. /** @hidden */
  65997. _comparisonFunction: number;
  65998. /** @hidden */
  65999. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66000. /** @hidden */
  66001. _lodGenerationScale: number;
  66002. /** @hidden */
  66003. _lodGenerationOffset: number;
  66004. /** @hidden */
  66005. _colorTextureArray: Nullable<WebGLTexture>;
  66006. /** @hidden */
  66007. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66008. /** @hidden */
  66009. _lodTextureHigh: Nullable<BaseTexture>;
  66010. /** @hidden */
  66011. _lodTextureMid: Nullable<BaseTexture>;
  66012. /** @hidden */
  66013. _lodTextureLow: Nullable<BaseTexture>;
  66014. /** @hidden */
  66015. _isRGBD: boolean;
  66016. /** @hidden */
  66017. _webGLTexture: Nullable<WebGLTexture>;
  66018. /** @hidden */
  66019. _references: number;
  66020. private _engine;
  66021. /**
  66022. * Gets the Engine the texture belongs to.
  66023. * @returns The babylon engine
  66024. */
  66025. getEngine(): Engine;
  66026. /**
  66027. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66028. */
  66029. readonly dataSource: number;
  66030. /**
  66031. * Creates a new InternalTexture
  66032. * @param engine defines the engine to use
  66033. * @param dataSource defines the type of data that will be used
  66034. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66035. */
  66036. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66037. /**
  66038. * Increments the number of references (ie. the number of Texture that point to it)
  66039. */
  66040. incrementReferences(): void;
  66041. /**
  66042. * Change the size of the texture (not the size of the content)
  66043. * @param width defines the new width
  66044. * @param height defines the new height
  66045. * @param depth defines the new depth (1 by default)
  66046. */
  66047. updateSize(width: int, height: int, depth?: int): void;
  66048. /** @hidden */
  66049. _rebuild(): void;
  66050. /** @hidden */
  66051. _swapAndDie(target: InternalTexture): void;
  66052. /**
  66053. * Dispose the current allocated resources
  66054. */
  66055. dispose(): void;
  66056. }
  66057. }
  66058. declare module BABYLON {
  66059. /**
  66060. * This represents the main contract an easing function should follow.
  66061. * Easing functions are used throughout the animation system.
  66062. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66063. */
  66064. export interface IEasingFunction {
  66065. /**
  66066. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66067. * of the easing function.
  66068. * The link below provides some of the most common examples of easing functions.
  66069. * @see https://easings.net/
  66070. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66071. * @returns the corresponding value on the curve defined by the easing function
  66072. */
  66073. ease(gradient: number): number;
  66074. }
  66075. /**
  66076. * Base class used for every default easing function.
  66077. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66078. */
  66079. export class EasingFunction implements IEasingFunction {
  66080. /**
  66081. * Interpolation follows the mathematical formula associated with the easing function.
  66082. */
  66083. static readonly EASINGMODE_EASEIN: number;
  66084. /**
  66085. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66086. */
  66087. static readonly EASINGMODE_EASEOUT: number;
  66088. /**
  66089. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66090. */
  66091. static readonly EASINGMODE_EASEINOUT: number;
  66092. private _easingMode;
  66093. /**
  66094. * Sets the easing mode of the current function.
  66095. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66096. */
  66097. setEasingMode(easingMode: number): void;
  66098. /**
  66099. * Gets the current easing mode.
  66100. * @returns the easing mode
  66101. */
  66102. getEasingMode(): number;
  66103. /**
  66104. * @hidden
  66105. */
  66106. easeInCore(gradient: number): number;
  66107. /**
  66108. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66109. * of the easing function.
  66110. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66111. * @returns the corresponding value on the curve defined by the easing function
  66112. */
  66113. ease(gradient: number): number;
  66114. }
  66115. /**
  66116. * Easing function with a circle shape (see link below).
  66117. * @see https://easings.net/#easeInCirc
  66118. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66119. */
  66120. export class CircleEase extends EasingFunction implements IEasingFunction {
  66121. /** @hidden */
  66122. easeInCore(gradient: number): number;
  66123. }
  66124. /**
  66125. * Easing function with a ease back shape (see link below).
  66126. * @see https://easings.net/#easeInBack
  66127. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66128. */
  66129. export class BackEase extends EasingFunction implements IEasingFunction {
  66130. /** Defines the amplitude of the function */
  66131. amplitude: number;
  66132. /**
  66133. * Instantiates a back ease easing
  66134. * @see https://easings.net/#easeInBack
  66135. * @param amplitude Defines the amplitude of the function
  66136. */
  66137. constructor(
  66138. /** Defines the amplitude of the function */
  66139. amplitude?: number);
  66140. /** @hidden */
  66141. easeInCore(gradient: number): number;
  66142. }
  66143. /**
  66144. * Easing function with a bouncing shape (see link below).
  66145. * @see https://easings.net/#easeInBounce
  66146. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66147. */
  66148. export class BounceEase extends EasingFunction implements IEasingFunction {
  66149. /** Defines the number of bounces */
  66150. bounces: number;
  66151. /** Defines the amplitude of the bounce */
  66152. bounciness: number;
  66153. /**
  66154. * Instantiates a bounce easing
  66155. * @see https://easings.net/#easeInBounce
  66156. * @param bounces Defines the number of bounces
  66157. * @param bounciness Defines the amplitude of the bounce
  66158. */
  66159. constructor(
  66160. /** Defines the number of bounces */
  66161. bounces?: number,
  66162. /** Defines the amplitude of the bounce */
  66163. bounciness?: number);
  66164. /** @hidden */
  66165. easeInCore(gradient: number): number;
  66166. }
  66167. /**
  66168. * Easing function with a power of 3 shape (see link below).
  66169. * @see https://easings.net/#easeInCubic
  66170. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66171. */
  66172. export class CubicEase extends EasingFunction implements IEasingFunction {
  66173. /** @hidden */
  66174. easeInCore(gradient: number): number;
  66175. }
  66176. /**
  66177. * Easing function with an elastic shape (see link below).
  66178. * @see https://easings.net/#easeInElastic
  66179. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66180. */
  66181. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66182. /** Defines the number of oscillations*/
  66183. oscillations: number;
  66184. /** Defines the amplitude of the oscillations*/
  66185. springiness: number;
  66186. /**
  66187. * Instantiates an elastic easing function
  66188. * @see https://easings.net/#easeInElastic
  66189. * @param oscillations Defines the number of oscillations
  66190. * @param springiness Defines the amplitude of the oscillations
  66191. */
  66192. constructor(
  66193. /** Defines the number of oscillations*/
  66194. oscillations?: number,
  66195. /** Defines the amplitude of the oscillations*/
  66196. springiness?: number);
  66197. /** @hidden */
  66198. easeInCore(gradient: number): number;
  66199. }
  66200. /**
  66201. * Easing function with an exponential shape (see link below).
  66202. * @see https://easings.net/#easeInExpo
  66203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66204. */
  66205. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66206. /** Defines the exponent of the function */
  66207. exponent: number;
  66208. /**
  66209. * Instantiates an exponential easing function
  66210. * @see https://easings.net/#easeInExpo
  66211. * @param exponent Defines the exponent of the function
  66212. */
  66213. constructor(
  66214. /** Defines the exponent of the function */
  66215. exponent?: number);
  66216. /** @hidden */
  66217. easeInCore(gradient: number): number;
  66218. }
  66219. /**
  66220. * Easing function with a power shape (see link below).
  66221. * @see https://easings.net/#easeInQuad
  66222. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66223. */
  66224. export class PowerEase extends EasingFunction implements IEasingFunction {
  66225. /** Defines the power of the function */
  66226. power: number;
  66227. /**
  66228. * Instantiates an power base easing function
  66229. * @see https://easings.net/#easeInQuad
  66230. * @param power Defines the power of the function
  66231. */
  66232. constructor(
  66233. /** Defines the power of the function */
  66234. power?: number);
  66235. /** @hidden */
  66236. easeInCore(gradient: number): number;
  66237. }
  66238. /**
  66239. * Easing function with a power of 2 shape (see link below).
  66240. * @see https://easings.net/#easeInQuad
  66241. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66242. */
  66243. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66244. /** @hidden */
  66245. easeInCore(gradient: number): number;
  66246. }
  66247. /**
  66248. * Easing function with a power of 4 shape (see link below).
  66249. * @see https://easings.net/#easeInQuart
  66250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66251. */
  66252. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66253. /** @hidden */
  66254. easeInCore(gradient: number): number;
  66255. }
  66256. /**
  66257. * Easing function with a power of 5 shape (see link below).
  66258. * @see https://easings.net/#easeInQuint
  66259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66260. */
  66261. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66262. /** @hidden */
  66263. easeInCore(gradient: number): number;
  66264. }
  66265. /**
  66266. * Easing function with a sin shape (see link below).
  66267. * @see https://easings.net/#easeInSine
  66268. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66269. */
  66270. export class SineEase extends EasingFunction implements IEasingFunction {
  66271. /** @hidden */
  66272. easeInCore(gradient: number): number;
  66273. }
  66274. /**
  66275. * Easing function with a bezier shape (see link below).
  66276. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66277. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66278. */
  66279. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66280. /** Defines the x component of the start tangent in the bezier curve */
  66281. x1: number;
  66282. /** Defines the y component of the start tangent in the bezier curve */
  66283. y1: number;
  66284. /** Defines the x component of the end tangent in the bezier curve */
  66285. x2: number;
  66286. /** Defines the y component of the end tangent in the bezier curve */
  66287. y2: number;
  66288. /**
  66289. * Instantiates a bezier function
  66290. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66291. * @param x1 Defines the x component of the start tangent in the bezier curve
  66292. * @param y1 Defines the y component of the start tangent in the bezier curve
  66293. * @param x2 Defines the x component of the end tangent in the bezier curve
  66294. * @param y2 Defines the y component of the end tangent in the bezier curve
  66295. */
  66296. constructor(
  66297. /** Defines the x component of the start tangent in the bezier curve */
  66298. x1?: number,
  66299. /** Defines the y component of the start tangent in the bezier curve */
  66300. y1?: number,
  66301. /** Defines the x component of the end tangent in the bezier curve */
  66302. x2?: number,
  66303. /** Defines the y component of the end tangent in the bezier curve */
  66304. y2?: number);
  66305. /** @hidden */
  66306. easeInCore(gradient: number): number;
  66307. }
  66308. }
  66309. declare module BABYLON {
  66310. /**
  66311. * Defines an interface which represents an animation key frame
  66312. */
  66313. export interface IAnimationKey {
  66314. /**
  66315. * Frame of the key frame
  66316. */
  66317. frame: number;
  66318. /**
  66319. * Value at the specifies key frame
  66320. */
  66321. value: any;
  66322. /**
  66323. * The input tangent for the cubic hermite spline
  66324. */
  66325. inTangent?: any;
  66326. /**
  66327. * The output tangent for the cubic hermite spline
  66328. */
  66329. outTangent?: any;
  66330. /**
  66331. * The animation interpolation type
  66332. */
  66333. interpolation?: AnimationKeyInterpolation;
  66334. }
  66335. /**
  66336. * Enum for the animation key frame interpolation type
  66337. */
  66338. export enum AnimationKeyInterpolation {
  66339. /**
  66340. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66341. */
  66342. STEP = 1
  66343. }
  66344. }
  66345. declare module BABYLON {
  66346. /**
  66347. * Represents the range of an animation
  66348. */
  66349. export class AnimationRange {
  66350. /**The name of the animation range**/
  66351. name: string;
  66352. /**The starting frame of the animation */
  66353. from: number;
  66354. /**The ending frame of the animation*/
  66355. to: number;
  66356. /**
  66357. * Initializes the range of an animation
  66358. * @param name The name of the animation range
  66359. * @param from The starting frame of the animation
  66360. * @param to The ending frame of the animation
  66361. */
  66362. constructor(
  66363. /**The name of the animation range**/
  66364. name: string,
  66365. /**The starting frame of the animation */
  66366. from: number,
  66367. /**The ending frame of the animation*/
  66368. to: number);
  66369. /**
  66370. * Makes a copy of the animation range
  66371. * @returns A copy of the animation range
  66372. */
  66373. clone(): AnimationRange;
  66374. }
  66375. }
  66376. declare module BABYLON {
  66377. /**
  66378. * Composed of a frame, and an action function
  66379. */
  66380. export class AnimationEvent {
  66381. /** The frame for which the event is triggered **/
  66382. frame: number;
  66383. /** The event to perform when triggered **/
  66384. action: (currentFrame: number) => void;
  66385. /** Specifies if the event should be triggered only once**/
  66386. onlyOnce?: boolean | undefined;
  66387. /**
  66388. * Specifies if the animation event is done
  66389. */
  66390. isDone: boolean;
  66391. /**
  66392. * Initializes the animation event
  66393. * @param frame The frame for which the event is triggered
  66394. * @param action The event to perform when triggered
  66395. * @param onlyOnce Specifies if the event should be triggered only once
  66396. */
  66397. constructor(
  66398. /** The frame for which the event is triggered **/
  66399. frame: number,
  66400. /** The event to perform when triggered **/
  66401. action: (currentFrame: number) => void,
  66402. /** Specifies if the event should be triggered only once**/
  66403. onlyOnce?: boolean | undefined);
  66404. /** @hidden */
  66405. _clone(): AnimationEvent;
  66406. }
  66407. }
  66408. declare module BABYLON {
  66409. /**
  66410. * Interface used to define a behavior
  66411. */
  66412. export interface Behavior<T> {
  66413. /** gets or sets behavior's name */
  66414. name: string;
  66415. /**
  66416. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66417. */
  66418. init(): void;
  66419. /**
  66420. * Called when the behavior is attached to a target
  66421. * @param target defines the target where the behavior is attached to
  66422. */
  66423. attach(target: T): void;
  66424. /**
  66425. * Called when the behavior is detached from its target
  66426. */
  66427. detach(): void;
  66428. }
  66429. /**
  66430. * Interface implemented by classes supporting behaviors
  66431. */
  66432. export interface IBehaviorAware<T> {
  66433. /**
  66434. * Attach a behavior
  66435. * @param behavior defines the behavior to attach
  66436. * @returns the current host
  66437. */
  66438. addBehavior(behavior: Behavior<T>): T;
  66439. /**
  66440. * Remove a behavior from the current object
  66441. * @param behavior defines the behavior to detach
  66442. * @returns the current host
  66443. */
  66444. removeBehavior(behavior: Behavior<T>): T;
  66445. /**
  66446. * Gets a behavior using its name to search
  66447. * @param name defines the name to search
  66448. * @returns the behavior or null if not found
  66449. */
  66450. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66451. }
  66452. }
  66453. declare module BABYLON {
  66454. /**
  66455. * @hidden
  66456. */
  66457. export class IntersectionInfo {
  66458. bu: Nullable<number>;
  66459. bv: Nullable<number>;
  66460. distance: number;
  66461. faceId: number;
  66462. subMeshId: number;
  66463. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66464. }
  66465. }
  66466. declare module BABYLON {
  66467. /**
  66468. * Class used to store bounding sphere information
  66469. */
  66470. export class BoundingSphere {
  66471. /**
  66472. * Gets the center of the bounding sphere in local space
  66473. */
  66474. readonly center: Vector3;
  66475. /**
  66476. * Radius of the bounding sphere in local space
  66477. */
  66478. radius: number;
  66479. /**
  66480. * Gets the center of the bounding sphere in world space
  66481. */
  66482. readonly centerWorld: Vector3;
  66483. /**
  66484. * Radius of the bounding sphere in world space
  66485. */
  66486. radiusWorld: number;
  66487. /**
  66488. * Gets the minimum vector in local space
  66489. */
  66490. readonly minimum: Vector3;
  66491. /**
  66492. * Gets the maximum vector in local space
  66493. */
  66494. readonly maximum: Vector3;
  66495. private _worldMatrix;
  66496. private static readonly TmpVector3;
  66497. /**
  66498. * Creates a new bounding sphere
  66499. * @param min defines the minimum vector (in local space)
  66500. * @param max defines the maximum vector (in local space)
  66501. * @param worldMatrix defines the new world matrix
  66502. */
  66503. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66504. /**
  66505. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66506. * @param min defines the new minimum vector (in local space)
  66507. * @param max defines the new maximum vector (in local space)
  66508. * @param worldMatrix defines the new world matrix
  66509. */
  66510. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66511. /**
  66512. * Scale the current bounding sphere by applying a scale factor
  66513. * @param factor defines the scale factor to apply
  66514. * @returns the current bounding box
  66515. */
  66516. scale(factor: number): BoundingSphere;
  66517. /**
  66518. * Gets the world matrix of the bounding box
  66519. * @returns a matrix
  66520. */
  66521. getWorldMatrix(): DeepImmutable<Matrix>;
  66522. /** @hidden */
  66523. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66524. /**
  66525. * Tests if the bounding sphere is intersecting the frustum planes
  66526. * @param frustumPlanes defines the frustum planes to test
  66527. * @returns true if there is an intersection
  66528. */
  66529. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66530. /**
  66531. * Tests if the bounding sphere center is in between the frustum planes.
  66532. * Used for optimistic fast inclusion.
  66533. * @param frustumPlanes defines the frustum planes to test
  66534. * @returns true if the sphere center is in between the frustum planes
  66535. */
  66536. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66537. /**
  66538. * Tests if a point is inside the bounding sphere
  66539. * @param point defines the point to test
  66540. * @returns true if the point is inside the bounding sphere
  66541. */
  66542. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66543. /**
  66544. * Checks if two sphere intersct
  66545. * @param sphere0 sphere 0
  66546. * @param sphere1 sphere 1
  66547. * @returns true if the speres intersect
  66548. */
  66549. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66550. }
  66551. }
  66552. declare module BABYLON {
  66553. /**
  66554. * Class used to store bounding box information
  66555. */
  66556. export class BoundingBox implements ICullable {
  66557. /**
  66558. * Gets the 8 vectors representing the bounding box in local space
  66559. */
  66560. readonly vectors: Vector3[];
  66561. /**
  66562. * Gets the center of the bounding box in local space
  66563. */
  66564. readonly center: Vector3;
  66565. /**
  66566. * Gets the center of the bounding box in world space
  66567. */
  66568. readonly centerWorld: Vector3;
  66569. /**
  66570. * Gets the extend size in local space
  66571. */
  66572. readonly extendSize: Vector3;
  66573. /**
  66574. * Gets the extend size in world space
  66575. */
  66576. readonly extendSizeWorld: Vector3;
  66577. /**
  66578. * Gets the OBB (object bounding box) directions
  66579. */
  66580. readonly directions: Vector3[];
  66581. /**
  66582. * Gets the 8 vectors representing the bounding box in world space
  66583. */
  66584. readonly vectorsWorld: Vector3[];
  66585. /**
  66586. * Gets the minimum vector in world space
  66587. */
  66588. readonly minimumWorld: Vector3;
  66589. /**
  66590. * Gets the maximum vector in world space
  66591. */
  66592. readonly maximumWorld: Vector3;
  66593. /**
  66594. * Gets the minimum vector in local space
  66595. */
  66596. readonly minimum: Vector3;
  66597. /**
  66598. * Gets the maximum vector in local space
  66599. */
  66600. readonly maximum: Vector3;
  66601. private _worldMatrix;
  66602. private static readonly TmpVector3;
  66603. /**
  66604. * @hidden
  66605. */
  66606. _tag: number;
  66607. /**
  66608. * Creates a new bounding box
  66609. * @param min defines the minimum vector (in local space)
  66610. * @param max defines the maximum vector (in local space)
  66611. * @param worldMatrix defines the new world matrix
  66612. */
  66613. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66614. /**
  66615. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66616. * @param min defines the new minimum vector (in local space)
  66617. * @param max defines the new maximum vector (in local space)
  66618. * @param worldMatrix defines the new world matrix
  66619. */
  66620. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66621. /**
  66622. * Scale the current bounding box by applying a scale factor
  66623. * @param factor defines the scale factor to apply
  66624. * @returns the current bounding box
  66625. */
  66626. scale(factor: number): BoundingBox;
  66627. /**
  66628. * Gets the world matrix of the bounding box
  66629. * @returns a matrix
  66630. */
  66631. getWorldMatrix(): DeepImmutable<Matrix>;
  66632. /** @hidden */
  66633. _update(world: DeepImmutable<Matrix>): void;
  66634. /**
  66635. * Tests if the bounding box is intersecting the frustum planes
  66636. * @param frustumPlanes defines the frustum planes to test
  66637. * @returns true if there is an intersection
  66638. */
  66639. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66640. /**
  66641. * Tests if the bounding box is entirely inside the frustum planes
  66642. * @param frustumPlanes defines the frustum planes to test
  66643. * @returns true if there is an inclusion
  66644. */
  66645. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66646. /**
  66647. * Tests if a point is inside the bounding box
  66648. * @param point defines the point to test
  66649. * @returns true if the point is inside the bounding box
  66650. */
  66651. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66652. /**
  66653. * Tests if the bounding box intersects with a bounding sphere
  66654. * @param sphere defines the sphere to test
  66655. * @returns true if there is an intersection
  66656. */
  66657. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66658. /**
  66659. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66660. * @param min defines the min vector to use
  66661. * @param max defines the max vector to use
  66662. * @returns true if there is an intersection
  66663. */
  66664. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66665. /**
  66666. * Tests if two bounding boxes are intersections
  66667. * @param box0 defines the first box to test
  66668. * @param box1 defines the second box to test
  66669. * @returns true if there is an intersection
  66670. */
  66671. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66672. /**
  66673. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66674. * @param minPoint defines the minimum vector of the bounding box
  66675. * @param maxPoint defines the maximum vector of the bounding box
  66676. * @param sphereCenter defines the sphere center
  66677. * @param sphereRadius defines the sphere radius
  66678. * @returns true if there is an intersection
  66679. */
  66680. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66681. /**
  66682. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66683. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66684. * @param frustumPlanes defines the frustum planes to test
  66685. * @return true if there is an inclusion
  66686. */
  66687. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66688. /**
  66689. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66690. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66691. * @param frustumPlanes defines the frustum planes to test
  66692. * @return true if there is an intersection
  66693. */
  66694. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66695. }
  66696. }
  66697. declare module BABYLON {
  66698. /** @hidden */
  66699. export class Collider {
  66700. /** Define if a collision was found */
  66701. collisionFound: boolean;
  66702. /**
  66703. * Define last intersection point in local space
  66704. */
  66705. intersectionPoint: Vector3;
  66706. /**
  66707. * Define last collided mesh
  66708. */
  66709. collidedMesh: Nullable<AbstractMesh>;
  66710. private _collisionPoint;
  66711. private _planeIntersectionPoint;
  66712. private _tempVector;
  66713. private _tempVector2;
  66714. private _tempVector3;
  66715. private _tempVector4;
  66716. private _edge;
  66717. private _baseToVertex;
  66718. private _destinationPoint;
  66719. private _slidePlaneNormal;
  66720. private _displacementVector;
  66721. /** @hidden */
  66722. _radius: Vector3;
  66723. /** @hidden */
  66724. _retry: number;
  66725. private _velocity;
  66726. private _basePoint;
  66727. private _epsilon;
  66728. /** @hidden */
  66729. _velocityWorldLength: number;
  66730. /** @hidden */
  66731. _basePointWorld: Vector3;
  66732. private _velocityWorld;
  66733. private _normalizedVelocity;
  66734. /** @hidden */
  66735. _initialVelocity: Vector3;
  66736. /** @hidden */
  66737. _initialPosition: Vector3;
  66738. private _nearestDistance;
  66739. private _collisionMask;
  66740. collisionMask: number;
  66741. /**
  66742. * Gets the plane normal used to compute the sliding response (in local space)
  66743. */
  66744. readonly slidePlaneNormal: Vector3;
  66745. /** @hidden */
  66746. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66747. /** @hidden */
  66748. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66749. /** @hidden */
  66750. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66751. /** @hidden */
  66752. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66753. /** @hidden */
  66754. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66755. /** @hidden */
  66756. _getResponse(pos: Vector3, vel: Vector3): void;
  66757. }
  66758. }
  66759. declare module BABYLON {
  66760. /**
  66761. * Interface for cullable objects
  66762. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66763. */
  66764. export interface ICullable {
  66765. /**
  66766. * Checks if the object or part of the object is in the frustum
  66767. * @param frustumPlanes Camera near/planes
  66768. * @returns true if the object is in frustum otherwise false
  66769. */
  66770. isInFrustum(frustumPlanes: Plane[]): boolean;
  66771. /**
  66772. * Checks if a cullable object (mesh...) is in the camera frustum
  66773. * Unlike isInFrustum this cheks the full bounding box
  66774. * @param frustumPlanes Camera near/planes
  66775. * @returns true if the object is in frustum otherwise false
  66776. */
  66777. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66778. }
  66779. /**
  66780. * Info for a bounding data of a mesh
  66781. */
  66782. export class BoundingInfo implements ICullable {
  66783. /**
  66784. * Bounding box for the mesh
  66785. */
  66786. readonly boundingBox: BoundingBox;
  66787. /**
  66788. * Bounding sphere for the mesh
  66789. */
  66790. readonly boundingSphere: BoundingSphere;
  66791. private _isLocked;
  66792. private static readonly TmpVector3;
  66793. /**
  66794. * Constructs bounding info
  66795. * @param minimum min vector of the bounding box/sphere
  66796. * @param maximum max vector of the bounding box/sphere
  66797. * @param worldMatrix defines the new world matrix
  66798. */
  66799. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66800. /**
  66801. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66802. * @param min defines the new minimum vector (in local space)
  66803. * @param max defines the new maximum vector (in local space)
  66804. * @param worldMatrix defines the new world matrix
  66805. */
  66806. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66807. /**
  66808. * min vector of the bounding box/sphere
  66809. */
  66810. readonly minimum: Vector3;
  66811. /**
  66812. * max vector of the bounding box/sphere
  66813. */
  66814. readonly maximum: Vector3;
  66815. /**
  66816. * If the info is locked and won't be updated to avoid perf overhead
  66817. */
  66818. isLocked: boolean;
  66819. /**
  66820. * Updates the bounding sphere and box
  66821. * @param world world matrix to be used to update
  66822. */
  66823. update(world: DeepImmutable<Matrix>): void;
  66824. /**
  66825. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66826. * @param center New center of the bounding info
  66827. * @param extend New extend of the bounding info
  66828. * @returns the current bounding info
  66829. */
  66830. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66831. /**
  66832. * Scale the current bounding info by applying a scale factor
  66833. * @param factor defines the scale factor to apply
  66834. * @returns the current bounding info
  66835. */
  66836. scale(factor: number): BoundingInfo;
  66837. /**
  66838. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66839. * @param frustumPlanes defines the frustum to test
  66840. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66841. * @returns true if the bounding info is in the frustum planes
  66842. */
  66843. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66844. /**
  66845. * Gets the world distance between the min and max points of the bounding box
  66846. */
  66847. readonly diagonalLength: number;
  66848. /**
  66849. * Checks if a cullable object (mesh...) is in the camera frustum
  66850. * Unlike isInFrustum this cheks the full bounding box
  66851. * @param frustumPlanes Camera near/planes
  66852. * @returns true if the object is in frustum otherwise false
  66853. */
  66854. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66855. /** @hidden */
  66856. _checkCollision(collider: Collider): boolean;
  66857. /**
  66858. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66859. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66860. * @param point the point to check intersection with
  66861. * @returns if the point intersects
  66862. */
  66863. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66864. /**
  66865. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66866. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66867. * @param boundingInfo the bounding info to check intersection with
  66868. * @param precise if the intersection should be done using OBB
  66869. * @returns if the bounding info intersects
  66870. */
  66871. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66872. }
  66873. }
  66874. declare module BABYLON {
  66875. /**
  66876. * Defines an array and its length.
  66877. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66878. */
  66879. export interface ISmartArrayLike<T> {
  66880. /**
  66881. * The data of the array.
  66882. */
  66883. data: Array<T>;
  66884. /**
  66885. * The active length of the array.
  66886. */
  66887. length: number;
  66888. }
  66889. /**
  66890. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66891. */
  66892. export class SmartArray<T> implements ISmartArrayLike<T> {
  66893. /**
  66894. * The full set of data from the array.
  66895. */
  66896. data: Array<T>;
  66897. /**
  66898. * The active length of the array.
  66899. */
  66900. length: number;
  66901. protected _id: number;
  66902. /**
  66903. * Instantiates a Smart Array.
  66904. * @param capacity defines the default capacity of the array.
  66905. */
  66906. constructor(capacity: number);
  66907. /**
  66908. * Pushes a value at the end of the active data.
  66909. * @param value defines the object to push in the array.
  66910. */
  66911. push(value: T): void;
  66912. /**
  66913. * Iterates over the active data and apply the lambda to them.
  66914. * @param func defines the action to apply on each value.
  66915. */
  66916. forEach(func: (content: T) => void): void;
  66917. /**
  66918. * Sorts the full sets of data.
  66919. * @param compareFn defines the comparison function to apply.
  66920. */
  66921. sort(compareFn: (a: T, b: T) => number): void;
  66922. /**
  66923. * Resets the active data to an empty array.
  66924. */
  66925. reset(): void;
  66926. /**
  66927. * Releases all the data from the array as well as the array.
  66928. */
  66929. dispose(): void;
  66930. /**
  66931. * Concats the active data with a given array.
  66932. * @param array defines the data to concatenate with.
  66933. */
  66934. concat(array: any): void;
  66935. /**
  66936. * Returns the position of a value in the active data.
  66937. * @param value defines the value to find the index for
  66938. * @returns the index if found in the active data otherwise -1
  66939. */
  66940. indexOf(value: T): number;
  66941. /**
  66942. * Returns whether an element is part of the active data.
  66943. * @param value defines the value to look for
  66944. * @returns true if found in the active data otherwise false
  66945. */
  66946. contains(value: T): boolean;
  66947. private static _GlobalId;
  66948. }
  66949. /**
  66950. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66951. * The data in this array can only be present once
  66952. */
  66953. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  66954. private _duplicateId;
  66955. /**
  66956. * Pushes a value at the end of the active data.
  66957. * THIS DOES NOT PREVENT DUPPLICATE DATA
  66958. * @param value defines the object to push in the array.
  66959. */
  66960. push(value: T): void;
  66961. /**
  66962. * Pushes a value at the end of the active data.
  66963. * If the data is already present, it won t be added again
  66964. * @param value defines the object to push in the array.
  66965. * @returns true if added false if it was already present
  66966. */
  66967. pushNoDuplicate(value: T): boolean;
  66968. /**
  66969. * Resets the active data to an empty array.
  66970. */
  66971. reset(): void;
  66972. /**
  66973. * Concats the active data with a given array.
  66974. * This ensures no dupplicate will be present in the result.
  66975. * @param array defines the data to concatenate with.
  66976. */
  66977. concatWithNoDuplicate(array: any): void;
  66978. }
  66979. }
  66980. declare module BABYLON {
  66981. /**
  66982. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66983. * separate meshes. This can be use to improve performances.
  66984. * @see http://doc.babylonjs.com/how_to/multi_materials
  66985. */
  66986. export class MultiMaterial extends Material {
  66987. private _subMaterials;
  66988. /**
  66989. * Gets or Sets the list of Materials used within the multi material.
  66990. * They need to be ordered according to the submeshes order in the associated mesh
  66991. */
  66992. subMaterials: Nullable<Material>[];
  66993. /**
  66994. * Function used to align with Node.getChildren()
  66995. * @returns the list of Materials used within the multi material
  66996. */
  66997. getChildren(): Nullable<Material>[];
  66998. /**
  66999. * Instantiates a new Multi Material
  67000. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67001. * separate meshes. This can be use to improve performances.
  67002. * @see http://doc.babylonjs.com/how_to/multi_materials
  67003. * @param name Define the name in the scene
  67004. * @param scene Define the scene the material belongs to
  67005. */
  67006. constructor(name: string, scene: Scene);
  67007. private _hookArray;
  67008. /**
  67009. * Get one of the submaterial by its index in the submaterials array
  67010. * @param index The index to look the sub material at
  67011. * @returns The Material if the index has been defined
  67012. */
  67013. getSubMaterial(index: number): Nullable<Material>;
  67014. /**
  67015. * Get the list of active textures for the whole sub materials list.
  67016. * @returns All the textures that will be used during the rendering
  67017. */
  67018. getActiveTextures(): BaseTexture[];
  67019. /**
  67020. * Gets the current class name of the material e.g. "MultiMaterial"
  67021. * Mainly use in serialization.
  67022. * @returns the class name
  67023. */
  67024. getClassName(): string;
  67025. /**
  67026. * Checks if the material is ready to render the requested sub mesh
  67027. * @param mesh Define the mesh the submesh belongs to
  67028. * @param subMesh Define the sub mesh to look readyness for
  67029. * @param useInstances Define whether or not the material is used with instances
  67030. * @returns true if ready, otherwise false
  67031. */
  67032. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67033. /**
  67034. * Clones the current material and its related sub materials
  67035. * @param name Define the name of the newly cloned material
  67036. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67037. * @returns the cloned material
  67038. */
  67039. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67040. /**
  67041. * Serializes the materials into a JSON representation.
  67042. * @returns the JSON representation
  67043. */
  67044. serialize(): any;
  67045. /**
  67046. * Dispose the material and release its associated resources
  67047. * @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)
  67048. * @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)
  67049. * @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)
  67050. */
  67051. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67052. /**
  67053. * Creates a MultiMaterial from parsed MultiMaterial data.
  67054. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67055. * @param scene defines the hosting scene
  67056. * @returns a new MultiMaterial
  67057. */
  67058. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67059. }
  67060. }
  67061. declare module BABYLON {
  67062. /**
  67063. * Class used to represent data loading progression
  67064. */
  67065. export class SceneLoaderFlags {
  67066. private static _ForceFullSceneLoadingForIncremental;
  67067. private static _ShowLoadingScreen;
  67068. private static _CleanBoneMatrixWeights;
  67069. private static _loggingLevel;
  67070. /**
  67071. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67072. */
  67073. static ForceFullSceneLoadingForIncremental: boolean;
  67074. /**
  67075. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67076. */
  67077. static ShowLoadingScreen: boolean;
  67078. /**
  67079. * Defines the current logging level (while loading the scene)
  67080. * @ignorenaming
  67081. */
  67082. static loggingLevel: number;
  67083. /**
  67084. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67085. */
  67086. static CleanBoneMatrixWeights: boolean;
  67087. }
  67088. }
  67089. declare module BABYLON {
  67090. /**
  67091. * 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.
  67092. * @see https://doc.babylonjs.com/how_to/transformnode
  67093. */
  67094. export class TransformNode extends Node {
  67095. /**
  67096. * Object will not rotate to face the camera
  67097. */
  67098. static BILLBOARDMODE_NONE: number;
  67099. /**
  67100. * Object will rotate to face the camera but only on the x axis
  67101. */
  67102. static BILLBOARDMODE_X: number;
  67103. /**
  67104. * Object will rotate to face the camera but only on the y axis
  67105. */
  67106. static BILLBOARDMODE_Y: number;
  67107. /**
  67108. * Object will rotate to face the camera but only on the z axis
  67109. */
  67110. static BILLBOARDMODE_Z: number;
  67111. /**
  67112. * Object will rotate to face the camera
  67113. */
  67114. static BILLBOARDMODE_ALL: number;
  67115. private _forward;
  67116. private _forwardInverted;
  67117. private _up;
  67118. private _right;
  67119. private _rightInverted;
  67120. private _position;
  67121. private _rotation;
  67122. private _rotationQuaternion;
  67123. protected _scaling: Vector3;
  67124. protected _isDirty: boolean;
  67125. private _transformToBoneReferal;
  67126. private _billboardMode;
  67127. /**
  67128. * Gets or sets the billboard mode. Default is 0.
  67129. *
  67130. * | Value | Type | Description |
  67131. * | --- | --- | --- |
  67132. * | 0 | BILLBOARDMODE_NONE | |
  67133. * | 1 | BILLBOARDMODE_X | |
  67134. * | 2 | BILLBOARDMODE_Y | |
  67135. * | 4 | BILLBOARDMODE_Z | |
  67136. * | 7 | BILLBOARDMODE_ALL | |
  67137. *
  67138. */
  67139. billboardMode: number;
  67140. private _preserveParentRotationForBillboard;
  67141. /**
  67142. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67143. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67144. */
  67145. preserveParentRotationForBillboard: boolean;
  67146. /**
  67147. * 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
  67148. */
  67149. scalingDeterminant: number;
  67150. private _infiniteDistance;
  67151. /**
  67152. * Gets or sets the distance of the object to max, often used by skybox
  67153. */
  67154. infiniteDistance: boolean;
  67155. /**
  67156. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67157. * By default the system will update normals to compensate
  67158. */
  67159. ignoreNonUniformScaling: boolean;
  67160. /**
  67161. * 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
  67162. */
  67163. reIntegrateRotationIntoRotationQuaternion: boolean;
  67164. /** @hidden */
  67165. _poseMatrix: Nullable<Matrix>;
  67166. /** @hidden */
  67167. _localMatrix: Matrix;
  67168. private _usePivotMatrix;
  67169. private _absolutePosition;
  67170. private _pivotMatrix;
  67171. private _pivotMatrixInverse;
  67172. protected _postMultiplyPivotMatrix: boolean;
  67173. protected _isWorldMatrixFrozen: boolean;
  67174. /** @hidden */
  67175. _indexInSceneTransformNodesArray: number;
  67176. /**
  67177. * An event triggered after the world matrix is updated
  67178. */
  67179. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67180. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67181. /**
  67182. * Gets a string identifying the name of the class
  67183. * @returns "TransformNode" string
  67184. */
  67185. getClassName(): string;
  67186. /**
  67187. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67188. */
  67189. position: Vector3;
  67190. /**
  67191. * 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)).
  67192. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67193. */
  67194. rotation: Vector3;
  67195. /**
  67196. * 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)).
  67197. */
  67198. scaling: Vector3;
  67199. /**
  67200. * 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).
  67201. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67202. */
  67203. rotationQuaternion: Nullable<Quaternion>;
  67204. /**
  67205. * The forward direction of that transform in world space.
  67206. */
  67207. readonly forward: Vector3;
  67208. /**
  67209. * The up direction of that transform in world space.
  67210. */
  67211. readonly up: Vector3;
  67212. /**
  67213. * The right direction of that transform in world space.
  67214. */
  67215. readonly right: Vector3;
  67216. /**
  67217. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67218. * @param matrix the matrix to copy the pose from
  67219. * @returns this TransformNode.
  67220. */
  67221. updatePoseMatrix(matrix: Matrix): TransformNode;
  67222. /**
  67223. * Returns the mesh Pose matrix.
  67224. * @returns the pose matrix
  67225. */
  67226. getPoseMatrix(): Matrix;
  67227. /** @hidden */
  67228. _isSynchronized(): boolean;
  67229. /** @hidden */
  67230. _initCache(): void;
  67231. /**
  67232. * Flag the transform node as dirty (Forcing it to update everything)
  67233. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67234. * @returns this transform node
  67235. */
  67236. markAsDirty(property: string): TransformNode;
  67237. /**
  67238. * Returns the current mesh absolute position.
  67239. * Returns a Vector3.
  67240. */
  67241. readonly absolutePosition: Vector3;
  67242. /**
  67243. * Sets a new matrix to apply before all other transformation
  67244. * @param matrix defines the transform matrix
  67245. * @returns the current TransformNode
  67246. */
  67247. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67248. /**
  67249. * Sets a new pivot matrix to the current node
  67250. * @param matrix defines the new pivot matrix to use
  67251. * @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
  67252. * @returns the current TransformNode
  67253. */
  67254. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67255. /**
  67256. * Returns the mesh pivot matrix.
  67257. * Default : Identity.
  67258. * @returns the matrix
  67259. */
  67260. getPivotMatrix(): Matrix;
  67261. /**
  67262. * Prevents the World matrix to be computed any longer.
  67263. * @returns the TransformNode.
  67264. */
  67265. freezeWorldMatrix(): TransformNode;
  67266. /**
  67267. * Allows back the World matrix computation.
  67268. * @returns the TransformNode.
  67269. */
  67270. unfreezeWorldMatrix(): this;
  67271. /**
  67272. * True if the World matrix has been frozen.
  67273. */
  67274. readonly isWorldMatrixFrozen: boolean;
  67275. /**
  67276. * Retuns the mesh absolute position in the World.
  67277. * @returns a Vector3.
  67278. */
  67279. getAbsolutePosition(): Vector3;
  67280. /**
  67281. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67282. * @param absolutePosition the absolute position to set
  67283. * @returns the TransformNode.
  67284. */
  67285. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67286. /**
  67287. * Sets the mesh position in its local space.
  67288. * @param vector3 the position to set in localspace
  67289. * @returns the TransformNode.
  67290. */
  67291. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67292. /**
  67293. * Returns the mesh position in the local space from the current World matrix values.
  67294. * @returns a new Vector3.
  67295. */
  67296. getPositionExpressedInLocalSpace(): Vector3;
  67297. /**
  67298. * Translates the mesh along the passed Vector3 in its local space.
  67299. * @param vector3 the distance to translate in localspace
  67300. * @returns the TransformNode.
  67301. */
  67302. locallyTranslate(vector3: Vector3): TransformNode;
  67303. private static _lookAtVectorCache;
  67304. /**
  67305. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67306. * @param targetPoint the position (must be in same space as current mesh) to look at
  67307. * @param yawCor optional yaw (y-axis) correction in radians
  67308. * @param pitchCor optional pitch (x-axis) correction in radians
  67309. * @param rollCor optional roll (z-axis) correction in radians
  67310. * @param space the choosen space of the target
  67311. * @returns the TransformNode.
  67312. */
  67313. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67314. /**
  67315. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67316. * This Vector3 is expressed in the World space.
  67317. * @param localAxis axis to rotate
  67318. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67319. */
  67320. getDirection(localAxis: Vector3): Vector3;
  67321. /**
  67322. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67323. * localAxis is expressed in the mesh local space.
  67324. * result is computed in the Wordl space from the mesh World matrix.
  67325. * @param localAxis axis to rotate
  67326. * @param result the resulting transformnode
  67327. * @returns this TransformNode.
  67328. */
  67329. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67330. /**
  67331. * Sets this transform node rotation to the given local axis.
  67332. * @param localAxis the axis in local space
  67333. * @param yawCor optional yaw (y-axis) correction in radians
  67334. * @param pitchCor optional pitch (x-axis) correction in radians
  67335. * @param rollCor optional roll (z-axis) correction in radians
  67336. * @returns this TransformNode
  67337. */
  67338. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67339. /**
  67340. * Sets a new pivot point to the current node
  67341. * @param point defines the new pivot point to use
  67342. * @param space defines if the point is in world or local space (local by default)
  67343. * @returns the current TransformNode
  67344. */
  67345. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67346. /**
  67347. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67348. * @returns the pivot point
  67349. */
  67350. getPivotPoint(): Vector3;
  67351. /**
  67352. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67353. * @param result the vector3 to store the result
  67354. * @returns this TransformNode.
  67355. */
  67356. getPivotPointToRef(result: Vector3): TransformNode;
  67357. /**
  67358. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67359. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67360. */
  67361. getAbsolutePivotPoint(): Vector3;
  67362. /**
  67363. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67364. * @param result vector3 to store the result
  67365. * @returns this TransformNode.
  67366. */
  67367. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67368. /**
  67369. * Defines the passed node as the parent of the current node.
  67370. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67371. * @see https://doc.babylonjs.com/how_to/parenting
  67372. * @param node the node ot set as the parent
  67373. * @returns this TransformNode.
  67374. */
  67375. setParent(node: Nullable<Node>): TransformNode;
  67376. private _nonUniformScaling;
  67377. /**
  67378. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67379. */
  67380. readonly nonUniformScaling: boolean;
  67381. /** @hidden */
  67382. _updateNonUniformScalingState(value: boolean): boolean;
  67383. /**
  67384. * Attach the current TransformNode to another TransformNode associated with a bone
  67385. * @param bone Bone affecting the TransformNode
  67386. * @param affectedTransformNode TransformNode associated with the bone
  67387. * @returns this object
  67388. */
  67389. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67390. /**
  67391. * Detach the transform node if its associated with a bone
  67392. * @returns this object
  67393. */
  67394. detachFromBone(): TransformNode;
  67395. private static _rotationAxisCache;
  67396. /**
  67397. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67398. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67399. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67400. * The passed axis is also normalized.
  67401. * @param axis the axis to rotate around
  67402. * @param amount the amount to rotate in radians
  67403. * @param space Space to rotate in (Default: local)
  67404. * @returns the TransformNode.
  67405. */
  67406. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67407. /**
  67408. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67409. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67410. * The passed axis is also normalized. .
  67411. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67412. * @param point the point to rotate around
  67413. * @param axis the axis to rotate around
  67414. * @param amount the amount to rotate in radians
  67415. * @returns the TransformNode
  67416. */
  67417. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67418. /**
  67419. * Translates the mesh along the axis vector for the passed distance in the given space.
  67420. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67421. * @param axis the axis to translate in
  67422. * @param distance the distance to translate
  67423. * @param space Space to rotate in (Default: local)
  67424. * @returns the TransformNode.
  67425. */
  67426. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67427. /**
  67428. * Adds a rotation step to the mesh current rotation.
  67429. * x, y, z are Euler angles expressed in radians.
  67430. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67431. * This means this rotation is made in the mesh local space only.
  67432. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67433. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67434. * ```javascript
  67435. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67436. * ```
  67437. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67438. * 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.
  67439. * @param x Rotation to add
  67440. * @param y Rotation to add
  67441. * @param z Rotation to add
  67442. * @returns the TransformNode.
  67443. */
  67444. addRotation(x: number, y: number, z: number): TransformNode;
  67445. /**
  67446. * @hidden
  67447. */
  67448. protected _getEffectiveParent(): Nullable<Node>;
  67449. /**
  67450. * Computes the world matrix of the node
  67451. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67452. * @returns the world matrix
  67453. */
  67454. computeWorldMatrix(force?: boolean): Matrix;
  67455. protected _afterComputeWorldMatrix(): void;
  67456. /**
  67457. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67458. * @param func callback function to add
  67459. *
  67460. * @returns the TransformNode.
  67461. */
  67462. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67463. /**
  67464. * Removes a registered callback function.
  67465. * @param func callback function to remove
  67466. * @returns the TransformNode.
  67467. */
  67468. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67469. /**
  67470. * Gets the position of the current mesh in camera space
  67471. * @param camera defines the camera to use
  67472. * @returns a position
  67473. */
  67474. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67475. /**
  67476. * Returns the distance from the mesh to the active camera
  67477. * @param camera defines the camera to use
  67478. * @returns the distance
  67479. */
  67480. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67481. /**
  67482. * Clone the current transform node
  67483. * @param name Name of the new clone
  67484. * @param newParent New parent for the clone
  67485. * @param doNotCloneChildren Do not clone children hierarchy
  67486. * @returns the new transform node
  67487. */
  67488. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67489. /**
  67490. * Serializes the objects information.
  67491. * @param currentSerializationObject defines the object to serialize in
  67492. * @returns the serialized object
  67493. */
  67494. serialize(currentSerializationObject?: any): any;
  67495. /**
  67496. * Returns a new TransformNode object parsed from the source provided.
  67497. * @param parsedTransformNode is the source.
  67498. * @param scene the scne the object belongs to
  67499. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67500. * @returns a new TransformNode object parsed from the source provided.
  67501. */
  67502. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67503. /**
  67504. * Get all child-transformNodes of this node
  67505. * @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
  67506. * @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
  67507. * @returns an array of TransformNode
  67508. */
  67509. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67510. /**
  67511. * Releases resources associated with this transform node.
  67512. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67513. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67514. */
  67515. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67516. }
  67517. }
  67518. declare module BABYLON {
  67519. /**
  67520. * Class used to override all child animations of a given target
  67521. */
  67522. export class AnimationPropertiesOverride {
  67523. /**
  67524. * Gets or sets a value indicating if animation blending must be used
  67525. */
  67526. enableBlending: boolean;
  67527. /**
  67528. * Gets or sets the blending speed to use when enableBlending is true
  67529. */
  67530. blendingSpeed: number;
  67531. /**
  67532. * Gets or sets the default loop mode to use
  67533. */
  67534. loopMode: number;
  67535. }
  67536. }
  67537. declare module BABYLON {
  67538. /**
  67539. * Class used to store bone information
  67540. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67541. */
  67542. export class Bone extends Node {
  67543. /**
  67544. * defines the bone name
  67545. */
  67546. name: string;
  67547. private static _tmpVecs;
  67548. private static _tmpQuat;
  67549. private static _tmpMats;
  67550. /**
  67551. * Gets the list of child bones
  67552. */
  67553. children: Bone[];
  67554. /** Gets the animations associated with this bone */
  67555. animations: Animation[];
  67556. /**
  67557. * Gets or sets bone length
  67558. */
  67559. length: number;
  67560. /**
  67561. * @hidden Internal only
  67562. * Set this value to map this bone to a different index in the transform matrices
  67563. * Set this value to -1 to exclude the bone from the transform matrices
  67564. */
  67565. _index: Nullable<number>;
  67566. private _skeleton;
  67567. private _localMatrix;
  67568. private _restPose;
  67569. private _baseMatrix;
  67570. private _absoluteTransform;
  67571. private _invertedAbsoluteTransform;
  67572. private _parent;
  67573. private _scalingDeterminant;
  67574. private _worldTransform;
  67575. private _localScaling;
  67576. private _localRotation;
  67577. private _localPosition;
  67578. private _needToDecompose;
  67579. private _needToCompose;
  67580. /** @hidden */
  67581. _linkedTransformNode: Nullable<TransformNode>;
  67582. /** @hidden */
  67583. /** @hidden */
  67584. _matrix: Matrix;
  67585. /**
  67586. * Create a new bone
  67587. * @param name defines the bone name
  67588. * @param skeleton defines the parent skeleton
  67589. * @param parentBone defines the parent (can be null if the bone is the root)
  67590. * @param localMatrix defines the local matrix
  67591. * @param restPose defines the rest pose matrix
  67592. * @param baseMatrix defines the base matrix
  67593. * @param index defines index of the bone in the hiearchy
  67594. */
  67595. constructor(
  67596. /**
  67597. * defines the bone name
  67598. */
  67599. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67600. /**
  67601. * Gets the current object class name.
  67602. * @return the class name
  67603. */
  67604. getClassName(): string;
  67605. /**
  67606. * Gets the parent skeleton
  67607. * @returns a skeleton
  67608. */
  67609. getSkeleton(): Skeleton;
  67610. /**
  67611. * Gets parent bone
  67612. * @returns a bone or null if the bone is the root of the bone hierarchy
  67613. */
  67614. getParent(): Nullable<Bone>;
  67615. /**
  67616. * Returns an array containing the root bones
  67617. * @returns an array containing the root bones
  67618. */
  67619. getChildren(): Array<Bone>;
  67620. /**
  67621. * Sets the parent bone
  67622. * @param parent defines the parent (can be null if the bone is the root)
  67623. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67624. */
  67625. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67626. /**
  67627. * Gets the local matrix
  67628. * @returns a matrix
  67629. */
  67630. getLocalMatrix(): Matrix;
  67631. /**
  67632. * Gets the base matrix (initial matrix which remains unchanged)
  67633. * @returns a matrix
  67634. */
  67635. getBaseMatrix(): Matrix;
  67636. /**
  67637. * Gets the rest pose matrix
  67638. * @returns a matrix
  67639. */
  67640. getRestPose(): Matrix;
  67641. /**
  67642. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67643. */
  67644. getWorldMatrix(): Matrix;
  67645. /**
  67646. * Sets the local matrix to rest pose matrix
  67647. */
  67648. returnToRest(): void;
  67649. /**
  67650. * Gets the inverse of the absolute transform matrix.
  67651. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67652. * @returns a matrix
  67653. */
  67654. getInvertedAbsoluteTransform(): Matrix;
  67655. /**
  67656. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67657. * @returns a matrix
  67658. */
  67659. getAbsoluteTransform(): Matrix;
  67660. /**
  67661. * Links with the given transform node.
  67662. * The local matrix of this bone is copied from the transform node every frame.
  67663. * @param transformNode defines the transform node to link to
  67664. */
  67665. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67666. /** Gets or sets current position (in local space) */
  67667. position: Vector3;
  67668. /** Gets or sets current rotation (in local space) */
  67669. rotation: Vector3;
  67670. /** Gets or sets current rotation quaternion (in local space) */
  67671. rotationQuaternion: Quaternion;
  67672. /** Gets or sets current scaling (in local space) */
  67673. scaling: Vector3;
  67674. /**
  67675. * Gets the animation properties override
  67676. */
  67677. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67678. private _decompose;
  67679. private _compose;
  67680. /**
  67681. * Update the base and local matrices
  67682. * @param matrix defines the new base or local matrix
  67683. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67684. * @param updateLocalMatrix defines if the local matrix should be updated
  67685. */
  67686. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67687. /** @hidden */
  67688. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67689. /**
  67690. * Flag the bone as dirty (Forcing it to update everything)
  67691. */
  67692. markAsDirty(): void;
  67693. private _markAsDirtyAndCompose;
  67694. private _markAsDirtyAndDecompose;
  67695. /**
  67696. * Translate the bone in local or world space
  67697. * @param vec The amount to translate the bone
  67698. * @param space The space that the translation is in
  67699. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67700. */
  67701. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67702. /**
  67703. * Set the postion of the bone in local or world space
  67704. * @param position The position to set the bone
  67705. * @param space The space that the position is in
  67706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67707. */
  67708. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67709. /**
  67710. * Set the absolute position of the bone (world space)
  67711. * @param position The position to set the bone
  67712. * @param mesh The mesh that this bone is attached to
  67713. */
  67714. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67715. /**
  67716. * Scale the bone on the x, y and z axes (in local space)
  67717. * @param x The amount to scale the bone on the x axis
  67718. * @param y The amount to scale the bone on the y axis
  67719. * @param z The amount to scale the bone on the z axis
  67720. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67721. */
  67722. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67723. /**
  67724. * Set the bone scaling in local space
  67725. * @param scale defines the scaling vector
  67726. */
  67727. setScale(scale: Vector3): void;
  67728. /**
  67729. * Gets the current scaling in local space
  67730. * @returns the current scaling vector
  67731. */
  67732. getScale(): Vector3;
  67733. /**
  67734. * Gets the current scaling in local space and stores it in a target vector
  67735. * @param result defines the target vector
  67736. */
  67737. getScaleToRef(result: Vector3): void;
  67738. /**
  67739. * Set the yaw, pitch, and roll of the bone in local or world space
  67740. * @param yaw The rotation of the bone on the y axis
  67741. * @param pitch The rotation of the bone on the x axis
  67742. * @param roll The rotation of the bone on the z axis
  67743. * @param space The space that the axes of rotation are in
  67744. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67745. */
  67746. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67747. /**
  67748. * Add a rotation to the bone on an axis in local or world space
  67749. * @param axis The axis to rotate the bone on
  67750. * @param amount The amount to rotate the bone
  67751. * @param space The space that the axis is in
  67752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67753. */
  67754. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67755. /**
  67756. * Set the rotation of the bone to a particular axis angle in local or world space
  67757. * @param axis The axis to rotate the bone on
  67758. * @param angle The angle that the bone should be rotated to
  67759. * @param space The space that the axis is in
  67760. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67761. */
  67762. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67763. /**
  67764. * Set the euler rotation of the bone in local of world space
  67765. * @param rotation The euler rotation that the bone should be set to
  67766. * @param space The space that the rotation is in
  67767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67768. */
  67769. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67770. /**
  67771. * Set the quaternion rotation of the bone in local of world space
  67772. * @param quat The quaternion rotation that the bone should be set to
  67773. * @param space The space that the rotation is in
  67774. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67775. */
  67776. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67777. /**
  67778. * Set the rotation matrix of the bone in local of world space
  67779. * @param rotMat The rotation matrix that the bone should be set to
  67780. * @param space The space that the rotation is in
  67781. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67782. */
  67783. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67784. private _rotateWithMatrix;
  67785. private _getNegativeRotationToRef;
  67786. /**
  67787. * Get the position of the bone in local or world space
  67788. * @param space The space that the returned position is in
  67789. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67790. * @returns The position of the bone
  67791. */
  67792. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67793. /**
  67794. * Copy the position of the bone to a vector3 in local or world space
  67795. * @param space The space that the returned position is in
  67796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67797. * @param result The vector3 to copy the position to
  67798. */
  67799. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67800. /**
  67801. * Get the absolute position of the bone (world space)
  67802. * @param mesh The mesh that this bone is attached to
  67803. * @returns The absolute position of the bone
  67804. */
  67805. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67806. /**
  67807. * Copy the absolute position of the bone (world space) to the result param
  67808. * @param mesh The mesh that this bone is attached to
  67809. * @param result The vector3 to copy the absolute position to
  67810. */
  67811. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67812. /**
  67813. * Compute the absolute transforms of this bone and its children
  67814. */
  67815. computeAbsoluteTransforms(): void;
  67816. /**
  67817. * Get the world direction from an axis that is in the local space of the bone
  67818. * @param localAxis The local direction that is used to compute the world direction
  67819. * @param mesh The mesh that this bone is attached to
  67820. * @returns The world direction
  67821. */
  67822. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67823. /**
  67824. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67825. * @param localAxis The local direction that is used to compute the world direction
  67826. * @param mesh The mesh that this bone is attached to
  67827. * @param result The vector3 that the world direction will be copied to
  67828. */
  67829. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67830. /**
  67831. * Get the euler rotation of the bone in local or world space
  67832. * @param space The space that the rotation should be in
  67833. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67834. * @returns The euler rotation
  67835. */
  67836. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67837. /**
  67838. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67839. * @param space The space that the rotation should be in
  67840. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67841. * @param result The vector3 that the rotation should be copied to
  67842. */
  67843. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67844. /**
  67845. * Get the quaternion rotation of the bone in either local or world space
  67846. * @param space The space that the rotation should be in
  67847. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67848. * @returns The quaternion rotation
  67849. */
  67850. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67851. /**
  67852. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67853. * @param space The space that the rotation should be in
  67854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67855. * @param result The quaternion that the rotation should be copied to
  67856. */
  67857. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67858. /**
  67859. * Get the rotation matrix of the bone in local or world space
  67860. * @param space The space that the rotation should be in
  67861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67862. * @returns The rotation matrix
  67863. */
  67864. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67865. /**
  67866. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67867. * @param space The space that the rotation should be in
  67868. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67869. * @param result The quaternion that the rotation should be copied to
  67870. */
  67871. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67872. /**
  67873. * Get the world position of a point that is in the local space of the bone
  67874. * @param position The local position
  67875. * @param mesh The mesh that this bone is attached to
  67876. * @returns The world position
  67877. */
  67878. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67879. /**
  67880. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  67881. * @param position The local position
  67882. * @param mesh The mesh that this bone is attached to
  67883. * @param result The vector3 that the world position should be copied to
  67884. */
  67885. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67886. /**
  67887. * Get the local position of a point that is in world space
  67888. * @param position The world position
  67889. * @param mesh The mesh that this bone is attached to
  67890. * @returns The local position
  67891. */
  67892. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67893. /**
  67894. * Get the local position of a point that is in world space and copy it to the result param
  67895. * @param position The world position
  67896. * @param mesh The mesh that this bone is attached to
  67897. * @param result The vector3 that the local position should be copied to
  67898. */
  67899. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67900. }
  67901. }
  67902. declare module BABYLON {
  67903. /**
  67904. * Enum that determines the text-wrapping mode to use.
  67905. */
  67906. export enum InspectableType {
  67907. /**
  67908. * Checkbox for booleans
  67909. */
  67910. Checkbox = 0,
  67911. /**
  67912. * Sliders for numbers
  67913. */
  67914. Slider = 1,
  67915. /**
  67916. * Vector3
  67917. */
  67918. Vector3 = 2,
  67919. /**
  67920. * Quaternions
  67921. */
  67922. Quaternion = 3,
  67923. /**
  67924. * Color3
  67925. */
  67926. Color3 = 4
  67927. }
  67928. /**
  67929. * Interface used to define custom inspectable properties.
  67930. * This interface is used by the inspector to display custom property grids
  67931. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67932. */
  67933. export interface IInspectable {
  67934. /**
  67935. * Gets the label to display
  67936. */
  67937. label: string;
  67938. /**
  67939. * Gets the name of the property to edit
  67940. */
  67941. propertyName: string;
  67942. /**
  67943. * Gets the type of the editor to use
  67944. */
  67945. type: InspectableType;
  67946. /**
  67947. * Gets the minimum value of the property when using in "slider" mode
  67948. */
  67949. min?: number;
  67950. /**
  67951. * Gets the maximum value of the property when using in "slider" mode
  67952. */
  67953. max?: number;
  67954. /**
  67955. * Gets the setp to use when using in "slider" mode
  67956. */
  67957. step?: number;
  67958. }
  67959. }
  67960. declare module BABYLON {
  67961. /**
  67962. * This represents the required contract to create a new type of texture loader.
  67963. */
  67964. export interface IInternalTextureLoader {
  67965. /**
  67966. * Defines wether the loader supports cascade loading the different faces.
  67967. */
  67968. supportCascades: boolean;
  67969. /**
  67970. * This returns if the loader support the current file information.
  67971. * @param extension defines the file extension of the file being loaded
  67972. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67973. * @param fallback defines the fallback internal texture if any
  67974. * @param isBase64 defines whether the texture is encoded as a base64
  67975. * @param isBuffer defines whether the texture data are stored as a buffer
  67976. * @returns true if the loader can load the specified file
  67977. */
  67978. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  67979. /**
  67980. * Transform the url before loading if required.
  67981. * @param rootUrl the url of the texture
  67982. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67983. * @returns the transformed texture
  67984. */
  67985. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  67986. /**
  67987. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  67988. * @param rootUrl the url of the texture
  67989. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67990. * @returns the fallback texture
  67991. */
  67992. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  67993. /**
  67994. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  67995. * @param data contains the texture data
  67996. * @param texture defines the BabylonJS internal texture
  67997. * @param createPolynomials will be true if polynomials have been requested
  67998. * @param onLoad defines the callback to trigger once the texture is ready
  67999. * @param onError defines the callback to trigger in case of error
  68000. */
  68001. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68002. /**
  68003. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68004. * @param data contains the texture data
  68005. * @param texture defines the BabylonJS internal texture
  68006. * @param callback defines the method to call once ready to upload
  68007. */
  68008. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68009. }
  68010. }
  68011. declare module BABYLON {
  68012. interface Engine {
  68013. /**
  68014. * Creates a depth stencil cube texture.
  68015. * This is only available in WebGL 2.
  68016. * @param size The size of face edge in the cube texture.
  68017. * @param options The options defining the cube texture.
  68018. * @returns The cube texture
  68019. */
  68020. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68021. /**
  68022. * Creates a cube texture
  68023. * @param rootUrl defines the url where the files to load is located
  68024. * @param scene defines the current scene
  68025. * @param files defines the list of files to load (1 per face)
  68026. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68027. * @param onLoad defines an optional callback raised when the texture is loaded
  68028. * @param onError defines an optional callback raised if there is an issue to load the texture
  68029. * @param format defines the format of the data
  68030. * @param forcedExtension defines the extension to use to pick the right loader
  68031. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68032. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68033. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68034. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68035. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68036. * @returns the cube texture as an InternalTexture
  68037. */
  68038. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  68039. /**
  68040. * Creates a cube texture
  68041. * @param rootUrl defines the url where the files to load is located
  68042. * @param scene defines the current scene
  68043. * @param files defines the list of files to load (1 per face)
  68044. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68045. * @param onLoad defines an optional callback raised when the texture is loaded
  68046. * @param onError defines an optional callback raised if there is an issue to load the texture
  68047. * @param format defines the format of the data
  68048. * @param forcedExtension defines the extension to use to pick the right loader
  68049. * @returns the cube texture as an InternalTexture
  68050. */
  68051. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  68052. /**
  68053. * Creates a cube texture
  68054. * @param rootUrl defines the url where the files to load is located
  68055. * @param scene defines the current scene
  68056. * @param files defines the list of files to load (1 per face)
  68057. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68058. * @param onLoad defines an optional callback raised when the texture is loaded
  68059. * @param onError defines an optional callback raised if there is an issue to load the texture
  68060. * @param format defines the format of the data
  68061. * @param forcedExtension defines the extension to use to pick the right loader
  68062. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68063. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68064. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68065. * @returns the cube texture as an InternalTexture
  68066. */
  68067. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  68068. /** @hidden */
  68069. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68070. /** @hidden */
  68071. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68072. /** @hidden */
  68073. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68074. /** @hidden */
  68075. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68076. }
  68077. }
  68078. declare module BABYLON {
  68079. /**
  68080. * Class for creating a cube texture
  68081. */
  68082. export class CubeTexture extends BaseTexture {
  68083. private _delayedOnLoad;
  68084. /**
  68085. * The url of the texture
  68086. */
  68087. url: string;
  68088. /**
  68089. * Gets or sets the center of the bounding box associated with the cube texture.
  68090. * It must define where the camera used to render the texture was set
  68091. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68092. */
  68093. boundingBoxPosition: Vector3;
  68094. private _boundingBoxSize;
  68095. /**
  68096. * Gets or sets the size of the bounding box associated with the cube texture
  68097. * When defined, the cubemap will switch to local mode
  68098. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68099. * @example https://www.babylonjs-playground.com/#RNASML
  68100. */
  68101. /**
  68102. * Returns the bounding box size
  68103. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68104. */
  68105. boundingBoxSize: Vector3;
  68106. protected _rotationY: number;
  68107. /**
  68108. * Sets texture matrix rotation angle around Y axis in radians.
  68109. */
  68110. /**
  68111. * Gets texture matrix rotation angle around Y axis radians.
  68112. */
  68113. rotationY: number;
  68114. /**
  68115. * Are mip maps generated for this texture or not.
  68116. */
  68117. readonly noMipmap: boolean;
  68118. private _noMipmap;
  68119. private _files;
  68120. private _extensions;
  68121. private _textureMatrix;
  68122. private _format;
  68123. private _createPolynomials;
  68124. /** @hidden */
  68125. _prefiltered: boolean;
  68126. /**
  68127. * Creates a cube texture from an array of image urls
  68128. * @param files defines an array of image urls
  68129. * @param scene defines the hosting scene
  68130. * @param noMipmap specifies if mip maps are not used
  68131. * @returns a cube texture
  68132. */
  68133. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68134. /**
  68135. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68136. * @param url defines the url of the prefiltered texture
  68137. * @param scene defines the scene the texture is attached to
  68138. * @param forcedExtension defines the extension of the file if different from the url
  68139. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68140. * @return the prefiltered texture
  68141. */
  68142. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68143. /**
  68144. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68145. * as prefiltered data.
  68146. * @param rootUrl defines the url of the texture or the root name of the six images
  68147. * @param scene defines the scene the texture is attached to
  68148. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68149. * @param noMipmap defines if mipmaps should be created or not
  68150. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68151. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68152. * @param onError defines a callback triggered in case of error during load
  68153. * @param format defines the internal format to use for the texture once loaded
  68154. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68155. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68156. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68157. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68158. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68159. * @return the cube texture
  68160. */
  68161. 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);
  68162. /**
  68163. * Get the current class name of the texture useful for serialization or dynamic coding.
  68164. * @returns "CubeTexture"
  68165. */
  68166. getClassName(): string;
  68167. /**
  68168. * Update the url (and optional buffer) of this texture if url was null during construction.
  68169. * @param url the url of the texture
  68170. * @param forcedExtension defines the extension to use
  68171. * @param onLoad callback called when the texture is loaded (defaults to null)
  68172. */
  68173. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68174. /**
  68175. * Delays loading of the cube texture
  68176. * @param forcedExtension defines the extension to use
  68177. */
  68178. delayLoad(forcedExtension?: string): void;
  68179. /**
  68180. * Returns the reflection texture matrix
  68181. * @returns the reflection texture matrix
  68182. */
  68183. getReflectionTextureMatrix(): Matrix;
  68184. /**
  68185. * Sets the reflection texture matrix
  68186. * @param value Reflection texture matrix
  68187. */
  68188. setReflectionTextureMatrix(value: Matrix): void;
  68189. /**
  68190. * Parses text to create a cube texture
  68191. * @param parsedTexture define the serialized text to read from
  68192. * @param scene defines the hosting scene
  68193. * @param rootUrl defines the root url of the cube texture
  68194. * @returns a cube texture
  68195. */
  68196. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68197. /**
  68198. * Makes a clone, or deep copy, of the cube texture
  68199. * @returns a new cube texture
  68200. */
  68201. clone(): CubeTexture;
  68202. }
  68203. }
  68204. declare module BABYLON {
  68205. /** @hidden */
  68206. export var postprocessVertexShader: {
  68207. name: string;
  68208. shader: string;
  68209. };
  68210. }
  68211. declare module BABYLON {
  68212. /**
  68213. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68214. * This is the base of the follow, arc rotate cameras and Free camera
  68215. * @see http://doc.babylonjs.com/features/cameras
  68216. */
  68217. export class TargetCamera extends Camera {
  68218. private static _RigCamTransformMatrix;
  68219. private static _TargetTransformMatrix;
  68220. private static _TargetFocalPoint;
  68221. /**
  68222. * Define the current direction the camera is moving to
  68223. */
  68224. cameraDirection: Vector3;
  68225. /**
  68226. * Define the current rotation the camera is rotating to
  68227. */
  68228. cameraRotation: Vector2;
  68229. /**
  68230. * When set, the up vector of the camera will be updated by the rotation of the camera
  68231. */
  68232. updateUpVectorFromRotation: boolean;
  68233. private _tmpQuaternion;
  68234. /**
  68235. * Define the current rotation of the camera
  68236. */
  68237. rotation: Vector3;
  68238. /**
  68239. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68240. */
  68241. rotationQuaternion: Quaternion;
  68242. /**
  68243. * Define the current speed of the camera
  68244. */
  68245. speed: number;
  68246. /**
  68247. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68248. * around all axis.
  68249. */
  68250. noRotationConstraint: boolean;
  68251. /**
  68252. * Define the current target of the camera as an object or a position.
  68253. */
  68254. lockedTarget: any;
  68255. /** @hidden */
  68256. _currentTarget: Vector3;
  68257. /** @hidden */
  68258. _initialFocalDistance: number;
  68259. /** @hidden */
  68260. _viewMatrix: Matrix;
  68261. /** @hidden */
  68262. _camMatrix: Matrix;
  68263. /** @hidden */
  68264. _cameraTransformMatrix: Matrix;
  68265. /** @hidden */
  68266. _cameraRotationMatrix: Matrix;
  68267. /** @hidden */
  68268. _referencePoint: Vector3;
  68269. /** @hidden */
  68270. _transformedReferencePoint: Vector3;
  68271. protected _globalCurrentTarget: Vector3;
  68272. protected _globalCurrentUpVector: Vector3;
  68273. /** @hidden */
  68274. _reset: () => void;
  68275. private _defaultUp;
  68276. /**
  68277. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68278. * This is the base of the follow, arc rotate cameras and Free camera
  68279. * @see http://doc.babylonjs.com/features/cameras
  68280. * @param name Defines the name of the camera in the scene
  68281. * @param position Defines the start position of the camera in the scene
  68282. * @param scene Defines the scene the camera belongs to
  68283. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68284. */
  68285. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68286. /**
  68287. * Gets the position in front of the camera at a given distance.
  68288. * @param distance The distance from the camera we want the position to be
  68289. * @returns the position
  68290. */
  68291. getFrontPosition(distance: number): Vector3;
  68292. /** @hidden */
  68293. _getLockedTargetPosition(): Nullable<Vector3>;
  68294. private _storedPosition;
  68295. private _storedRotation;
  68296. private _storedRotationQuaternion;
  68297. /**
  68298. * Store current camera state of the camera (fov, position, rotation, etc..)
  68299. * @returns the camera
  68300. */
  68301. storeState(): Camera;
  68302. /**
  68303. * Restored camera state. You must call storeState() first
  68304. * @returns whether it was successful or not
  68305. * @hidden
  68306. */
  68307. _restoreStateValues(): boolean;
  68308. /** @hidden */
  68309. _initCache(): void;
  68310. /** @hidden */
  68311. _updateCache(ignoreParentClass?: boolean): void;
  68312. /** @hidden */
  68313. _isSynchronizedViewMatrix(): boolean;
  68314. /** @hidden */
  68315. _computeLocalCameraSpeed(): number;
  68316. /**
  68317. * Defines the target the camera should look at.
  68318. * This will automatically adapt alpha beta and radius to fit within the new target.
  68319. * @param target Defines the new target as a Vector or a mesh
  68320. */
  68321. setTarget(target: Vector3): void;
  68322. /**
  68323. * Return the current target position of the camera. This value is expressed in local space.
  68324. * @returns the target position
  68325. */
  68326. getTarget(): Vector3;
  68327. /** @hidden */
  68328. _decideIfNeedsToMove(): boolean;
  68329. /** @hidden */
  68330. _updatePosition(): void;
  68331. /** @hidden */
  68332. _checkInputs(): void;
  68333. protected _updateCameraRotationMatrix(): void;
  68334. /**
  68335. * 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)
  68336. * @returns the current camera
  68337. */
  68338. private _rotateUpVectorWithCameraRotationMatrix;
  68339. private _cachedRotationZ;
  68340. private _cachedQuaternionRotationZ;
  68341. /** @hidden */
  68342. _getViewMatrix(): Matrix;
  68343. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68344. /**
  68345. * @hidden
  68346. */
  68347. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68348. /**
  68349. * @hidden
  68350. */
  68351. _updateRigCameras(): void;
  68352. private _getRigCamPositionAndTarget;
  68353. /**
  68354. * Gets the current object class name.
  68355. * @return the class name
  68356. */
  68357. getClassName(): string;
  68358. }
  68359. }
  68360. declare module BABYLON {
  68361. /**
  68362. * @ignore
  68363. * This is a list of all the different input types that are available in the application.
  68364. * Fo instance: ArcRotateCameraGamepadInput...
  68365. */
  68366. export var CameraInputTypes: {};
  68367. /**
  68368. * This is the contract to implement in order to create a new input class.
  68369. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68370. */
  68371. export interface ICameraInput<TCamera extends Camera> {
  68372. /**
  68373. * Defines the camera the input is attached to.
  68374. */
  68375. camera: Nullable<TCamera>;
  68376. /**
  68377. * Gets the class name of the current intput.
  68378. * @returns the class name
  68379. */
  68380. getClassName(): string;
  68381. /**
  68382. * Get the friendly name associated with the input class.
  68383. * @returns the input friendly name
  68384. */
  68385. getSimpleName(): string;
  68386. /**
  68387. * Attach the input controls to a specific dom element to get the input from.
  68388. * @param element Defines the element the controls should be listened from
  68389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68390. */
  68391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68392. /**
  68393. * Detach the current controls from the specified dom element.
  68394. * @param element Defines the element to stop listening the inputs from
  68395. */
  68396. detachControl(element: Nullable<HTMLElement>): void;
  68397. /**
  68398. * Update the current camera state depending on the inputs that have been used this frame.
  68399. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68400. */
  68401. checkInputs?: () => void;
  68402. }
  68403. /**
  68404. * Represents a map of input types to input instance or input index to input instance.
  68405. */
  68406. export interface CameraInputsMap<TCamera extends Camera> {
  68407. /**
  68408. * Accessor to the input by input type.
  68409. */
  68410. [name: string]: ICameraInput<TCamera>;
  68411. /**
  68412. * Accessor to the input by input index.
  68413. */
  68414. [idx: number]: ICameraInput<TCamera>;
  68415. }
  68416. /**
  68417. * This represents the input manager used within a camera.
  68418. * It helps dealing with all the different kind of input attached to a camera.
  68419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68420. */
  68421. export class CameraInputsManager<TCamera extends Camera> {
  68422. /**
  68423. * Defines the list of inputs attahed to the camera.
  68424. */
  68425. attached: CameraInputsMap<TCamera>;
  68426. /**
  68427. * Defines the dom element the camera is collecting inputs from.
  68428. * This is null if the controls have not been attached.
  68429. */
  68430. attachedElement: Nullable<HTMLElement>;
  68431. /**
  68432. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68433. */
  68434. noPreventDefault: boolean;
  68435. /**
  68436. * Defined the camera the input manager belongs to.
  68437. */
  68438. camera: TCamera;
  68439. /**
  68440. * Update the current camera state depending on the inputs that have been used this frame.
  68441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68442. */
  68443. checkInputs: () => void;
  68444. /**
  68445. * Instantiate a new Camera Input Manager.
  68446. * @param camera Defines the camera the input manager blongs to
  68447. */
  68448. constructor(camera: TCamera);
  68449. /**
  68450. * Add an input method to a camera
  68451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68452. * @param input camera input method
  68453. */
  68454. add(input: ICameraInput<TCamera>): void;
  68455. /**
  68456. * Remove a specific input method from a camera
  68457. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68458. * @param inputToRemove camera input method
  68459. */
  68460. remove(inputToRemove: ICameraInput<TCamera>): void;
  68461. /**
  68462. * Remove a specific input type from a camera
  68463. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68464. * @param inputType the type of the input to remove
  68465. */
  68466. removeByType(inputType: string): void;
  68467. private _addCheckInputs;
  68468. /**
  68469. * Attach the input controls to the currently attached dom element to listen the events from.
  68470. * @param input Defines the input to attach
  68471. */
  68472. attachInput(input: ICameraInput<TCamera>): void;
  68473. /**
  68474. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68475. * @param element Defines the dom element to collect the events from
  68476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68477. */
  68478. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68479. /**
  68480. * Detach the current manager inputs controls from a specific dom element.
  68481. * @param element Defines the dom element to collect the events from
  68482. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68483. */
  68484. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68485. /**
  68486. * Rebuild the dynamic inputCheck function from the current list of
  68487. * defined inputs in the manager.
  68488. */
  68489. rebuildInputCheck(): void;
  68490. /**
  68491. * Remove all attached input methods from a camera
  68492. */
  68493. clear(): void;
  68494. /**
  68495. * Serialize the current input manager attached to a camera.
  68496. * This ensures than once parsed,
  68497. * the input associated to the camera will be identical to the current ones
  68498. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68499. */
  68500. serialize(serializedCamera: any): void;
  68501. /**
  68502. * Parses an input manager serialized JSON to restore the previous list of inputs
  68503. * and states associated to a camera.
  68504. * @param parsedCamera Defines the JSON to parse
  68505. */
  68506. parse(parsedCamera: any): void;
  68507. }
  68508. }
  68509. declare module BABYLON {
  68510. /**
  68511. * Gather the list of keyboard event types as constants.
  68512. */
  68513. export class KeyboardEventTypes {
  68514. /**
  68515. * The keydown event is fired when a key becomes active (pressed).
  68516. */
  68517. static readonly KEYDOWN: number;
  68518. /**
  68519. * The keyup event is fired when a key has been released.
  68520. */
  68521. static readonly KEYUP: number;
  68522. }
  68523. /**
  68524. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68525. */
  68526. export class KeyboardInfo {
  68527. /**
  68528. * Defines the type of event (KeyboardEventTypes)
  68529. */
  68530. type: number;
  68531. /**
  68532. * Defines the related dom event
  68533. */
  68534. event: KeyboardEvent;
  68535. /**
  68536. * Instantiates a new keyboard info.
  68537. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68538. * @param type Defines the type of event (KeyboardEventTypes)
  68539. * @param event Defines the related dom event
  68540. */
  68541. constructor(
  68542. /**
  68543. * Defines the type of event (KeyboardEventTypes)
  68544. */
  68545. type: number,
  68546. /**
  68547. * Defines the related dom event
  68548. */
  68549. event: KeyboardEvent);
  68550. }
  68551. /**
  68552. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68553. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68554. */
  68555. export class KeyboardInfoPre extends KeyboardInfo {
  68556. /**
  68557. * Defines the type of event (KeyboardEventTypes)
  68558. */
  68559. type: number;
  68560. /**
  68561. * Defines the related dom event
  68562. */
  68563. event: KeyboardEvent;
  68564. /**
  68565. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68566. */
  68567. skipOnPointerObservable: boolean;
  68568. /**
  68569. * Instantiates a new keyboard pre info.
  68570. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68571. * @param type Defines the type of event (KeyboardEventTypes)
  68572. * @param event Defines the related dom event
  68573. */
  68574. constructor(
  68575. /**
  68576. * Defines the type of event (KeyboardEventTypes)
  68577. */
  68578. type: number,
  68579. /**
  68580. * Defines the related dom event
  68581. */
  68582. event: KeyboardEvent);
  68583. }
  68584. }
  68585. declare module BABYLON {
  68586. /**
  68587. * Manage the keyboard inputs to control the movement of a free camera.
  68588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68589. */
  68590. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68591. /**
  68592. * Defines the camera the input is attached to.
  68593. */
  68594. camera: FreeCamera;
  68595. /**
  68596. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68597. */
  68598. keysUp: number[];
  68599. /**
  68600. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68601. */
  68602. keysDown: number[];
  68603. /**
  68604. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68605. */
  68606. keysLeft: number[];
  68607. /**
  68608. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68609. */
  68610. keysRight: number[];
  68611. private _keys;
  68612. private _onCanvasBlurObserver;
  68613. private _onKeyboardObserver;
  68614. private _engine;
  68615. private _scene;
  68616. /**
  68617. * Attach the input controls to a specific dom element to get the input from.
  68618. * @param element Defines the element the controls should be listened from
  68619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68620. */
  68621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68622. /**
  68623. * Detach the current controls from the specified dom element.
  68624. * @param element Defines the element to stop listening the inputs from
  68625. */
  68626. detachControl(element: Nullable<HTMLElement>): void;
  68627. /**
  68628. * Update the current camera state depending on the inputs that have been used this frame.
  68629. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68630. */
  68631. checkInputs(): void;
  68632. /**
  68633. * Gets the class name of the current intput.
  68634. * @returns the class name
  68635. */
  68636. getClassName(): string;
  68637. /** @hidden */
  68638. _onLostFocus(): void;
  68639. /**
  68640. * Get the friendly name associated with the input class.
  68641. * @returns the input friendly name
  68642. */
  68643. getSimpleName(): string;
  68644. }
  68645. }
  68646. declare module BABYLON {
  68647. /**
  68648. * Interface describing all the common properties and methods a shadow light needs to implement.
  68649. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68650. * as well as binding the different shadow properties to the effects.
  68651. */
  68652. export interface IShadowLight extends Light {
  68653. /**
  68654. * The light id in the scene (used in scene.findLighById for instance)
  68655. */
  68656. id: string;
  68657. /**
  68658. * The position the shdow will be casted from.
  68659. */
  68660. position: Vector3;
  68661. /**
  68662. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68663. */
  68664. direction: Vector3;
  68665. /**
  68666. * The transformed position. Position of the light in world space taking parenting in account.
  68667. */
  68668. transformedPosition: Vector3;
  68669. /**
  68670. * The transformed direction. Direction of the light in world space taking parenting in account.
  68671. */
  68672. transformedDirection: Vector3;
  68673. /**
  68674. * The friendly name of the light in the scene.
  68675. */
  68676. name: string;
  68677. /**
  68678. * Defines the shadow projection clipping minimum z value.
  68679. */
  68680. shadowMinZ: number;
  68681. /**
  68682. * Defines the shadow projection clipping maximum z value.
  68683. */
  68684. shadowMaxZ: number;
  68685. /**
  68686. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68687. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68688. */
  68689. computeTransformedInformation(): boolean;
  68690. /**
  68691. * Gets the scene the light belongs to.
  68692. * @returns The scene
  68693. */
  68694. getScene(): Scene;
  68695. /**
  68696. * Callback defining a custom Projection Matrix Builder.
  68697. * This can be used to override the default projection matrix computation.
  68698. */
  68699. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68700. /**
  68701. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68702. * @param matrix The materix to updated with the projection information
  68703. * @param viewMatrix The transform matrix of the light
  68704. * @param renderList The list of mesh to render in the map
  68705. * @returns The current light
  68706. */
  68707. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68708. /**
  68709. * Gets the current depth scale used in ESM.
  68710. * @returns The scale
  68711. */
  68712. getDepthScale(): number;
  68713. /**
  68714. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68715. * @returns true if a cube texture needs to be use
  68716. */
  68717. needCube(): boolean;
  68718. /**
  68719. * Detects if the projection matrix requires to be recomputed this frame.
  68720. * @returns true if it requires to be recomputed otherwise, false.
  68721. */
  68722. needProjectionMatrixCompute(): boolean;
  68723. /**
  68724. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68725. */
  68726. forceProjectionMatrixCompute(): void;
  68727. /**
  68728. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68729. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68730. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68731. */
  68732. getShadowDirection(faceIndex?: number): Vector3;
  68733. /**
  68734. * Gets the minZ used for shadow according to both the scene and the light.
  68735. * @param activeCamera The camera we are returning the min for
  68736. * @returns the depth min z
  68737. */
  68738. getDepthMinZ(activeCamera: Camera): number;
  68739. /**
  68740. * Gets the maxZ used for shadow according to both the scene and the light.
  68741. * @param activeCamera The camera we are returning the max for
  68742. * @returns the depth max z
  68743. */
  68744. getDepthMaxZ(activeCamera: Camera): number;
  68745. }
  68746. /**
  68747. * Base implementation IShadowLight
  68748. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68749. */
  68750. export abstract class ShadowLight extends Light implements IShadowLight {
  68751. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68752. protected _position: Vector3;
  68753. protected _setPosition(value: Vector3): void;
  68754. /**
  68755. * Sets the position the shadow will be casted from. Also use as the light position for both
  68756. * point and spot lights.
  68757. */
  68758. /**
  68759. * Sets the position the shadow will be casted from. Also use as the light position for both
  68760. * point and spot lights.
  68761. */
  68762. position: Vector3;
  68763. protected _direction: Vector3;
  68764. protected _setDirection(value: Vector3): void;
  68765. /**
  68766. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68767. * Also use as the light direction on spot and directional lights.
  68768. */
  68769. /**
  68770. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68771. * Also use as the light direction on spot and directional lights.
  68772. */
  68773. direction: Vector3;
  68774. private _shadowMinZ;
  68775. /**
  68776. * Gets the shadow projection clipping minimum z value.
  68777. */
  68778. /**
  68779. * Sets the shadow projection clipping minimum z value.
  68780. */
  68781. shadowMinZ: number;
  68782. private _shadowMaxZ;
  68783. /**
  68784. * Sets the shadow projection clipping maximum z value.
  68785. */
  68786. /**
  68787. * Gets the shadow projection clipping maximum z value.
  68788. */
  68789. shadowMaxZ: number;
  68790. /**
  68791. * Callback defining a custom Projection Matrix Builder.
  68792. * This can be used to override the default projection matrix computation.
  68793. */
  68794. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68795. /**
  68796. * The transformed position. Position of the light in world space taking parenting in account.
  68797. */
  68798. transformedPosition: Vector3;
  68799. /**
  68800. * The transformed direction. Direction of the light in world space taking parenting in account.
  68801. */
  68802. transformedDirection: Vector3;
  68803. private _needProjectionMatrixCompute;
  68804. /**
  68805. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68806. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68807. */
  68808. computeTransformedInformation(): boolean;
  68809. /**
  68810. * Return the depth scale used for the shadow map.
  68811. * @returns the depth scale.
  68812. */
  68813. getDepthScale(): number;
  68814. /**
  68815. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68816. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68817. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68818. */
  68819. getShadowDirection(faceIndex?: number): Vector3;
  68820. /**
  68821. * Returns the ShadowLight absolute position in the World.
  68822. * @returns the position vector in world space
  68823. */
  68824. getAbsolutePosition(): Vector3;
  68825. /**
  68826. * Sets the ShadowLight direction toward the passed target.
  68827. * @param target The point to target in local space
  68828. * @returns the updated ShadowLight direction
  68829. */
  68830. setDirectionToTarget(target: Vector3): Vector3;
  68831. /**
  68832. * Returns the light rotation in euler definition.
  68833. * @returns the x y z rotation in local space.
  68834. */
  68835. getRotation(): Vector3;
  68836. /**
  68837. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68838. * @returns true if a cube texture needs to be use
  68839. */
  68840. needCube(): boolean;
  68841. /**
  68842. * Detects if the projection matrix requires to be recomputed this frame.
  68843. * @returns true if it requires to be recomputed otherwise, false.
  68844. */
  68845. needProjectionMatrixCompute(): boolean;
  68846. /**
  68847. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68848. */
  68849. forceProjectionMatrixCompute(): void;
  68850. /** @hidden */
  68851. _initCache(): void;
  68852. /** @hidden */
  68853. _isSynchronized(): boolean;
  68854. /**
  68855. * Computes the world matrix of the node
  68856. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68857. * @returns the world matrix
  68858. */
  68859. computeWorldMatrix(force?: boolean): Matrix;
  68860. /**
  68861. * Gets the minZ used for shadow according to both the scene and the light.
  68862. * @param activeCamera The camera we are returning the min for
  68863. * @returns the depth min z
  68864. */
  68865. getDepthMinZ(activeCamera: Camera): number;
  68866. /**
  68867. * Gets the maxZ used for shadow according to both the scene and the light.
  68868. * @param activeCamera The camera we are returning the max for
  68869. * @returns the depth max z
  68870. */
  68871. getDepthMaxZ(activeCamera: Camera): number;
  68872. /**
  68873. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68874. * @param matrix The materix to updated with the projection information
  68875. * @param viewMatrix The transform matrix of the light
  68876. * @param renderList The list of mesh to render in the map
  68877. * @returns The current light
  68878. */
  68879. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68880. }
  68881. }
  68882. declare module BABYLON {
  68883. /**
  68884. * "Static Class" containing the most commonly used helper while dealing with material for
  68885. * rendering purpose.
  68886. *
  68887. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68888. *
  68889. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68890. */
  68891. export class MaterialHelper {
  68892. /**
  68893. * Bind the current view position to an effect.
  68894. * @param effect The effect to be bound
  68895. * @param scene The scene the eyes position is used from
  68896. */
  68897. static BindEyePosition(effect: Effect, scene: Scene): void;
  68898. /**
  68899. * Helps preparing the defines values about the UVs in used in the effect.
  68900. * UVs are shared as much as we can accross channels in the shaders.
  68901. * @param texture The texture we are preparing the UVs for
  68902. * @param defines The defines to update
  68903. * @param key The channel key "diffuse", "specular"... used in the shader
  68904. */
  68905. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68906. /**
  68907. * Binds a texture matrix value to its corrsponding uniform
  68908. * @param texture The texture to bind the matrix for
  68909. * @param uniformBuffer The uniform buffer receivin the data
  68910. * @param key The channel key "diffuse", "specular"... used in the shader
  68911. */
  68912. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  68913. /**
  68914. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68915. * @param mesh defines the current mesh
  68916. * @param scene defines the current scene
  68917. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68918. * @param pointsCloud defines if point cloud rendering has to be turned on
  68919. * @param fogEnabled defines if fog has to be turned on
  68920. * @param alphaTest defines if alpha testing has to be turned on
  68921. * @param defines defines the current list of defines
  68922. */
  68923. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  68924. /**
  68925. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68926. * @param scene defines the current scene
  68927. * @param engine defines the current engine
  68928. * @param defines specifies the list of active defines
  68929. * @param useInstances defines if instances have to be turned on
  68930. * @param useClipPlane defines if clip plane have to be turned on
  68931. */
  68932. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  68933. /**
  68934. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68935. * @param mesh The mesh containing the geometry data we will draw
  68936. * @param defines The defines to update
  68937. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68938. * @param useBones Precise whether bones should be used or not (override mesh info)
  68939. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68940. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68941. * @returns false if defines are considered not dirty and have not been checked
  68942. */
  68943. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  68944. /**
  68945. * Prepares the defines related to multiview
  68946. * @param scene The scene we are intending to draw
  68947. * @param defines The defines to update
  68948. */
  68949. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  68950. /**
  68951. * Prepares the defines related to the light information passed in parameter
  68952. * @param scene The scene we are intending to draw
  68953. * @param mesh The mesh the effect is compiling for
  68954. * @param defines The defines to update
  68955. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68956. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68957. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68958. * @returns true if normals will be required for the rest of the effect
  68959. */
  68960. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  68961. /**
  68962. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68963. * that won t be acctive due to defines being turned off.
  68964. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68965. * @param samplersList The samplers list
  68966. * @param defines The defines helping in the list generation
  68967. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68968. */
  68969. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  68970. /**
  68971. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68972. * @param defines The defines to update while falling back
  68973. * @param fallbacks The authorized effect fallbacks
  68974. * @param maxSimultaneousLights The maximum number of lights allowed
  68975. * @param rank the current rank of the Effect
  68976. * @returns The newly affected rank
  68977. */
  68978. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  68979. /**
  68980. * Prepares the list of attributes required for morph targets according to the effect defines.
  68981. * @param attribs The current list of supported attribs
  68982. * @param mesh The mesh to prepare the morph targets attributes for
  68983. * @param defines The current Defines of the effect
  68984. */
  68985. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  68986. /**
  68987. * Prepares the list of attributes required for bones according to the effect defines.
  68988. * @param attribs The current list of supported attribs
  68989. * @param mesh The mesh to prepare the bones attributes for
  68990. * @param defines The current Defines of the effect
  68991. * @param fallbacks The current efffect fallback strategy
  68992. */
  68993. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  68994. /**
  68995. * Prepares the list of attributes required for instances according to the effect defines.
  68996. * @param attribs The current list of supported attribs
  68997. * @param defines The current Defines of the effect
  68998. */
  68999. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69000. /**
  69001. * Binds the light shadow information to the effect for the given mesh.
  69002. * @param light The light containing the generator
  69003. * @param scene The scene the lights belongs to
  69004. * @param mesh The mesh we are binding the information to render
  69005. * @param lightIndex The light index in the effect used to render the mesh
  69006. * @param effect The effect we are binding the data to
  69007. */
  69008. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69009. /**
  69010. * Binds the light information to the effect.
  69011. * @param light The light containing the generator
  69012. * @param effect The effect we are binding the data to
  69013. * @param lightIndex The light index in the effect used to render
  69014. */
  69015. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69016. /**
  69017. * Binds the lights information from the scene to the effect for the given mesh.
  69018. * @param scene The scene the lights belongs to
  69019. * @param mesh The mesh we are binding the information to render
  69020. * @param effect The effect we are binding the data to
  69021. * @param defines The generated defines for the effect
  69022. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69023. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69024. */
  69025. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69026. private static _tempFogColor;
  69027. /**
  69028. * Binds the fog information from the scene to the effect for the given mesh.
  69029. * @param scene The scene the lights belongs to
  69030. * @param mesh The mesh we are binding the information to render
  69031. * @param effect The effect we are binding the data to
  69032. * @param linearSpace Defines if the fog effect is applied in linear space
  69033. */
  69034. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69035. /**
  69036. * Binds the bones information from the mesh to the effect.
  69037. * @param mesh The mesh we are binding the information to render
  69038. * @param effect The effect we are binding the data to
  69039. */
  69040. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69041. /**
  69042. * Binds the morph targets information from the mesh to the effect.
  69043. * @param abstractMesh The mesh we are binding the information to render
  69044. * @param effect The effect we are binding the data to
  69045. */
  69046. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69047. /**
  69048. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69049. * @param defines The generated defines used in the effect
  69050. * @param effect The effect we are binding the data to
  69051. * @param scene The scene we are willing to render with logarithmic scale for
  69052. */
  69053. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69054. /**
  69055. * Binds the clip plane information from the scene to the effect.
  69056. * @param scene The scene the clip plane information are extracted from
  69057. * @param effect The effect we are binding the data to
  69058. */
  69059. static BindClipPlane(effect: Effect, scene: Scene): void;
  69060. }
  69061. }
  69062. declare module BABYLON {
  69063. /** @hidden */
  69064. export var kernelBlurVaryingDeclaration: {
  69065. name: string;
  69066. shader: string;
  69067. };
  69068. }
  69069. declare module BABYLON {
  69070. /** @hidden */
  69071. export var kernelBlurFragment: {
  69072. name: string;
  69073. shader: string;
  69074. };
  69075. }
  69076. declare module BABYLON {
  69077. /** @hidden */
  69078. export var kernelBlurFragment2: {
  69079. name: string;
  69080. shader: string;
  69081. };
  69082. }
  69083. declare module BABYLON {
  69084. /** @hidden */
  69085. export var kernelBlurPixelShader: {
  69086. name: string;
  69087. shader: string;
  69088. };
  69089. }
  69090. declare module BABYLON {
  69091. /** @hidden */
  69092. export var kernelBlurVertex: {
  69093. name: string;
  69094. shader: string;
  69095. };
  69096. }
  69097. declare module BABYLON {
  69098. /** @hidden */
  69099. export var kernelBlurVertexShader: {
  69100. name: string;
  69101. shader: string;
  69102. };
  69103. }
  69104. declare module BABYLON {
  69105. /**
  69106. * The Blur Post Process which blurs an image based on a kernel and direction.
  69107. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69108. */
  69109. export class BlurPostProcess extends PostProcess {
  69110. /** The direction in which to blur the image. */
  69111. direction: Vector2;
  69112. private blockCompilation;
  69113. protected _kernel: number;
  69114. protected _idealKernel: number;
  69115. protected _packedFloat: boolean;
  69116. private _staticDefines;
  69117. /**
  69118. * Sets the length in pixels of the blur sample region
  69119. */
  69120. /**
  69121. * Gets the length in pixels of the blur sample region
  69122. */
  69123. kernel: number;
  69124. /**
  69125. * Sets wether or not the blur needs to unpack/repack floats
  69126. */
  69127. /**
  69128. * Gets wether or not the blur is unpacking/repacking floats
  69129. */
  69130. packedFloat: boolean;
  69131. /**
  69132. * Creates a new instance BlurPostProcess
  69133. * @param name The name of the effect.
  69134. * @param direction The direction in which to blur the image.
  69135. * @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.
  69136. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69137. * @param camera The camera to apply the render pass to.
  69138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69139. * @param engine The engine which the post process will be applied. (default: current engine)
  69140. * @param reusable If the post process can be reused on the same frame. (default: false)
  69141. * @param textureType Type of textures used when performing the post process. (default: 0)
  69142. * @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)
  69143. */
  69144. constructor(name: string,
  69145. /** The direction in which to blur the image. */
  69146. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69147. /**
  69148. * Updates the effect with the current post process compile time values and recompiles the shader.
  69149. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69150. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69151. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69152. * @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
  69153. * @param onCompiled Called when the shader has been compiled.
  69154. * @param onError Called if there is an error when compiling a shader.
  69155. */
  69156. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69157. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69158. /**
  69159. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69160. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69161. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69162. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69163. * The gaps between physical kernels are compensated for in the weighting of the samples
  69164. * @param idealKernel Ideal blur kernel.
  69165. * @return Nearest best kernel.
  69166. */
  69167. protected _nearestBestKernel(idealKernel: number): number;
  69168. /**
  69169. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69170. * @param x The point on the Gaussian distribution to sample.
  69171. * @return the value of the Gaussian function at x.
  69172. */
  69173. protected _gaussianWeight(x: number): number;
  69174. /**
  69175. * Generates a string that can be used as a floating point number in GLSL.
  69176. * @param x Value to print.
  69177. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69178. * @return GLSL float string.
  69179. */
  69180. protected _glslFloat(x: number, decimalFigures?: number): string;
  69181. }
  69182. }
  69183. declare module BABYLON {
  69184. /** @hidden */
  69185. export var shadowMapPixelShader: {
  69186. name: string;
  69187. shader: string;
  69188. };
  69189. }
  69190. declare module BABYLON {
  69191. /** @hidden */
  69192. export var bonesDeclaration: {
  69193. name: string;
  69194. shader: string;
  69195. };
  69196. }
  69197. declare module BABYLON {
  69198. /** @hidden */
  69199. export var morphTargetsVertexGlobalDeclaration: {
  69200. name: string;
  69201. shader: string;
  69202. };
  69203. }
  69204. declare module BABYLON {
  69205. /** @hidden */
  69206. export var morphTargetsVertexDeclaration: {
  69207. name: string;
  69208. shader: string;
  69209. };
  69210. }
  69211. declare module BABYLON {
  69212. /** @hidden */
  69213. export var instancesDeclaration: {
  69214. name: string;
  69215. shader: string;
  69216. };
  69217. }
  69218. declare module BABYLON {
  69219. /** @hidden */
  69220. export var helperFunctions: {
  69221. name: string;
  69222. shader: string;
  69223. };
  69224. }
  69225. declare module BABYLON {
  69226. /** @hidden */
  69227. export var morphTargetsVertex: {
  69228. name: string;
  69229. shader: string;
  69230. };
  69231. }
  69232. declare module BABYLON {
  69233. /** @hidden */
  69234. export var instancesVertex: {
  69235. name: string;
  69236. shader: string;
  69237. };
  69238. }
  69239. declare module BABYLON {
  69240. /** @hidden */
  69241. export var bonesVertex: {
  69242. name: string;
  69243. shader: string;
  69244. };
  69245. }
  69246. declare module BABYLON {
  69247. /** @hidden */
  69248. export var shadowMapVertexShader: {
  69249. name: string;
  69250. shader: string;
  69251. };
  69252. }
  69253. declare module BABYLON {
  69254. /** @hidden */
  69255. export var depthBoxBlurPixelShader: {
  69256. name: string;
  69257. shader: string;
  69258. };
  69259. }
  69260. declare module BABYLON {
  69261. /**
  69262. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69263. */
  69264. export interface ICustomShaderOptions {
  69265. /**
  69266. * Gets or sets the custom shader name to use
  69267. */
  69268. shaderName: string;
  69269. /**
  69270. * The list of attribute names used in the shader
  69271. */
  69272. attributes?: string[];
  69273. /**
  69274. * The list of unifrom names used in the shader
  69275. */
  69276. uniforms?: string[];
  69277. /**
  69278. * The list of sampler names used in the shader
  69279. */
  69280. samplers?: string[];
  69281. /**
  69282. * The list of defines used in the shader
  69283. */
  69284. defines?: string[];
  69285. }
  69286. /**
  69287. * Interface to implement to create a shadow generator compatible with BJS.
  69288. */
  69289. export interface IShadowGenerator {
  69290. /**
  69291. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69292. * @returns The render target texture if present otherwise, null
  69293. */
  69294. getShadowMap(): Nullable<RenderTargetTexture>;
  69295. /**
  69296. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69297. * @returns The render target texture if the shadow map is present otherwise, null
  69298. */
  69299. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69300. /**
  69301. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69302. * @param subMesh The submesh we want to render in the shadow map
  69303. * @param useInstances Defines wether will draw in the map using instances
  69304. * @returns true if ready otherwise, false
  69305. */
  69306. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69307. /**
  69308. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69309. * @param defines Defines of the material we want to update
  69310. * @param lightIndex Index of the light in the enabled light list of the material
  69311. */
  69312. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69313. /**
  69314. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69315. * defined in the generator but impacting the effect).
  69316. * It implies the unifroms available on the materials are the standard BJS ones.
  69317. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69318. * @param effect The effect we are binfing the information for
  69319. */
  69320. bindShadowLight(lightIndex: string, effect: Effect): void;
  69321. /**
  69322. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69323. * (eq to shadow prjection matrix * light transform matrix)
  69324. * @returns The transform matrix used to create the shadow map
  69325. */
  69326. getTransformMatrix(): Matrix;
  69327. /**
  69328. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69329. * Cube and 2D textures for instance.
  69330. */
  69331. recreateShadowMap(): void;
  69332. /**
  69333. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69334. * @param onCompiled Callback triggered at the and of the effects compilation
  69335. * @param options Sets of optional options forcing the compilation with different modes
  69336. */
  69337. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69338. useInstances: boolean;
  69339. }>): void;
  69340. /**
  69341. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69342. * @param options Sets of optional options forcing the compilation with different modes
  69343. * @returns A promise that resolves when the compilation completes
  69344. */
  69345. forceCompilationAsync(options?: Partial<{
  69346. useInstances: boolean;
  69347. }>): Promise<void>;
  69348. /**
  69349. * Serializes the shadow generator setup to a json object.
  69350. * @returns The serialized JSON object
  69351. */
  69352. serialize(): any;
  69353. /**
  69354. * Disposes the Shadow map and related Textures and effects.
  69355. */
  69356. dispose(): void;
  69357. }
  69358. /**
  69359. * Default implementation IShadowGenerator.
  69360. * This is the main object responsible of generating shadows in the framework.
  69361. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69362. */
  69363. export class ShadowGenerator implements IShadowGenerator {
  69364. /**
  69365. * Shadow generator mode None: no filtering applied.
  69366. */
  69367. static readonly FILTER_NONE: number;
  69368. /**
  69369. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69370. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69371. */
  69372. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69373. /**
  69374. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69375. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69376. */
  69377. static readonly FILTER_POISSONSAMPLING: number;
  69378. /**
  69379. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69380. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69381. */
  69382. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69383. /**
  69384. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69385. * edge artifacts on steep falloff.
  69386. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69387. */
  69388. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69389. /**
  69390. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69391. * edge artifacts on steep falloff.
  69392. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69393. */
  69394. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69395. /**
  69396. * Shadow generator mode PCF: Percentage Closer Filtering
  69397. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69398. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69399. */
  69400. static readonly FILTER_PCF: number;
  69401. /**
  69402. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69403. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69404. * Contact Hardening
  69405. */
  69406. static readonly FILTER_PCSS: number;
  69407. /**
  69408. * Reserved for PCF and PCSS
  69409. * Highest Quality.
  69410. *
  69411. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69412. *
  69413. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69414. */
  69415. static readonly QUALITY_HIGH: number;
  69416. /**
  69417. * Reserved for PCF and PCSS
  69418. * Good tradeoff for quality/perf cross devices
  69419. *
  69420. * Execute PCF on a 3*3 kernel.
  69421. *
  69422. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69423. */
  69424. static readonly QUALITY_MEDIUM: number;
  69425. /**
  69426. * Reserved for PCF and PCSS
  69427. * The lowest quality but the fastest.
  69428. *
  69429. * Execute PCF on a 1*1 kernel.
  69430. *
  69431. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69432. */
  69433. static readonly QUALITY_LOW: number;
  69434. /** Gets or sets the custom shader name to use */
  69435. customShaderOptions: ICustomShaderOptions;
  69436. /**
  69437. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69438. */
  69439. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69440. /**
  69441. * Observable triggered before a mesh is rendered in the shadow map.
  69442. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69443. */
  69444. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69445. private _bias;
  69446. /**
  69447. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69448. */
  69449. /**
  69450. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69451. */
  69452. bias: number;
  69453. private _normalBias;
  69454. /**
  69455. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69456. */
  69457. /**
  69458. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69459. */
  69460. normalBias: number;
  69461. private _blurBoxOffset;
  69462. /**
  69463. * Gets the blur box offset: offset applied during the blur pass.
  69464. * Only useful if useKernelBlur = false
  69465. */
  69466. /**
  69467. * Sets the blur box offset: offset applied during the blur pass.
  69468. * Only useful if useKernelBlur = false
  69469. */
  69470. blurBoxOffset: number;
  69471. private _blurScale;
  69472. /**
  69473. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69474. * 2 means half of the size.
  69475. */
  69476. /**
  69477. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69478. * 2 means half of the size.
  69479. */
  69480. blurScale: number;
  69481. private _blurKernel;
  69482. /**
  69483. * Gets the blur kernel: kernel size of the blur pass.
  69484. * Only useful if useKernelBlur = true
  69485. */
  69486. /**
  69487. * Sets the blur kernel: kernel size of the blur pass.
  69488. * Only useful if useKernelBlur = true
  69489. */
  69490. blurKernel: number;
  69491. private _useKernelBlur;
  69492. /**
  69493. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69494. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69495. */
  69496. /**
  69497. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69498. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69499. */
  69500. useKernelBlur: boolean;
  69501. private _depthScale;
  69502. /**
  69503. * Gets the depth scale used in ESM mode.
  69504. */
  69505. /**
  69506. * Sets the depth scale used in ESM mode.
  69507. * This can override the scale stored on the light.
  69508. */
  69509. depthScale: number;
  69510. private _filter;
  69511. /**
  69512. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69513. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69514. */
  69515. /**
  69516. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69517. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69518. */
  69519. filter: number;
  69520. /**
  69521. * Gets if the current filter is set to Poisson Sampling.
  69522. */
  69523. /**
  69524. * Sets the current filter to Poisson Sampling.
  69525. */
  69526. usePoissonSampling: boolean;
  69527. /**
  69528. * Gets if the current filter is set to ESM.
  69529. */
  69530. /**
  69531. * Sets the current filter is to ESM.
  69532. */
  69533. useExponentialShadowMap: boolean;
  69534. /**
  69535. * Gets if the current filter is set to filtered ESM.
  69536. */
  69537. /**
  69538. * Gets if the current filter is set to filtered ESM.
  69539. */
  69540. useBlurExponentialShadowMap: boolean;
  69541. /**
  69542. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69543. * exponential to prevent steep falloff artifacts).
  69544. */
  69545. /**
  69546. * Sets the current filter to "close ESM" (using the inverse of the
  69547. * exponential to prevent steep falloff artifacts).
  69548. */
  69549. useCloseExponentialShadowMap: boolean;
  69550. /**
  69551. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69552. * exponential to prevent steep falloff artifacts).
  69553. */
  69554. /**
  69555. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69556. * exponential to prevent steep falloff artifacts).
  69557. */
  69558. useBlurCloseExponentialShadowMap: boolean;
  69559. /**
  69560. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69561. */
  69562. /**
  69563. * Sets the current filter to "PCF" (percentage closer filtering).
  69564. */
  69565. usePercentageCloserFiltering: boolean;
  69566. private _filteringQuality;
  69567. /**
  69568. * Gets the PCF or PCSS Quality.
  69569. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69570. */
  69571. /**
  69572. * Sets the PCF or PCSS Quality.
  69573. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69574. */
  69575. filteringQuality: number;
  69576. /**
  69577. * Gets if the current filter is set to "PCSS" (contact hardening).
  69578. */
  69579. /**
  69580. * Sets the current filter to "PCSS" (contact hardening).
  69581. */
  69582. useContactHardeningShadow: boolean;
  69583. private _contactHardeningLightSizeUVRatio;
  69584. /**
  69585. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69586. * Using a ratio helps keeping shape stability independently of the map size.
  69587. *
  69588. * It does not account for the light projection as it was having too much
  69589. * instability during the light setup or during light position changes.
  69590. *
  69591. * Only valid if useContactHardeningShadow is true.
  69592. */
  69593. /**
  69594. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69595. * Using a ratio helps keeping shape stability independently of the map size.
  69596. *
  69597. * It does not account for the light projection as it was having too much
  69598. * instability during the light setup or during light position changes.
  69599. *
  69600. * Only valid if useContactHardeningShadow is true.
  69601. */
  69602. contactHardeningLightSizeUVRatio: number;
  69603. private _darkness;
  69604. /**
  69605. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69606. * 0 means strongest and 1 would means no shadow.
  69607. * @returns the darkness.
  69608. */
  69609. getDarkness(): number;
  69610. /**
  69611. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69612. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69613. * @returns the shadow generator allowing fluent coding.
  69614. */
  69615. setDarkness(darkness: number): ShadowGenerator;
  69616. private _transparencyShadow;
  69617. /**
  69618. * Sets the ability to have transparent shadow (boolean).
  69619. * @param transparent True if transparent else False
  69620. * @returns the shadow generator allowing fluent coding
  69621. */
  69622. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69623. private _shadowMap;
  69624. private _shadowMap2;
  69625. /**
  69626. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69627. * @returns The render target texture if present otherwise, null
  69628. */
  69629. getShadowMap(): Nullable<RenderTargetTexture>;
  69630. /**
  69631. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69632. * @returns The render target texture if the shadow map is present otherwise, null
  69633. */
  69634. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69635. /**
  69636. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69637. * @param mesh Mesh to add
  69638. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69639. * @returns the Shadow Generator itself
  69640. */
  69641. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69642. /**
  69643. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69644. * @param mesh Mesh to remove
  69645. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69646. * @returns the Shadow Generator itself
  69647. */
  69648. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69649. /**
  69650. * Controls the extent to which the shadows fade out at the edge of the frustum
  69651. * Used only by directionals and spots
  69652. */
  69653. frustumEdgeFalloff: number;
  69654. private _light;
  69655. /**
  69656. * Returns the associated light object.
  69657. * @returns the light generating the shadow
  69658. */
  69659. getLight(): IShadowLight;
  69660. /**
  69661. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69662. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69663. * It might on the other hand introduce peter panning.
  69664. */
  69665. forceBackFacesOnly: boolean;
  69666. private _scene;
  69667. private _lightDirection;
  69668. private _effect;
  69669. private _viewMatrix;
  69670. private _projectionMatrix;
  69671. private _transformMatrix;
  69672. private _cachedPosition;
  69673. private _cachedDirection;
  69674. private _cachedDefines;
  69675. private _currentRenderID;
  69676. private _boxBlurPostprocess;
  69677. private _kernelBlurXPostprocess;
  69678. private _kernelBlurYPostprocess;
  69679. private _blurPostProcesses;
  69680. private _mapSize;
  69681. private _currentFaceIndex;
  69682. private _currentFaceIndexCache;
  69683. private _textureType;
  69684. private _defaultTextureMatrix;
  69685. /** @hidden */
  69686. static _SceneComponentInitialization: (scene: Scene) => void;
  69687. /**
  69688. * Creates a ShadowGenerator object.
  69689. * A ShadowGenerator is the required tool to use the shadows.
  69690. * Each light casting shadows needs to use its own ShadowGenerator.
  69691. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69692. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69693. * @param light The light object generating the shadows.
  69694. * @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.
  69695. */
  69696. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69697. private _initializeGenerator;
  69698. private _initializeShadowMap;
  69699. private _initializeBlurRTTAndPostProcesses;
  69700. private _renderForShadowMap;
  69701. private _renderSubMeshForShadowMap;
  69702. private _applyFilterValues;
  69703. /**
  69704. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69705. * @param onCompiled Callback triggered at the and of the effects compilation
  69706. * @param options Sets of optional options forcing the compilation with different modes
  69707. */
  69708. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69709. useInstances: boolean;
  69710. }>): void;
  69711. /**
  69712. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69713. * @param options Sets of optional options forcing the compilation with different modes
  69714. * @returns A promise that resolves when the compilation completes
  69715. */
  69716. forceCompilationAsync(options?: Partial<{
  69717. useInstances: boolean;
  69718. }>): Promise<void>;
  69719. /**
  69720. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69721. * @param subMesh The submesh we want to render in the shadow map
  69722. * @param useInstances Defines wether will draw in the map using instances
  69723. * @returns true if ready otherwise, false
  69724. */
  69725. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69726. /**
  69727. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69728. * @param defines Defines of the material we want to update
  69729. * @param lightIndex Index of the light in the enabled light list of the material
  69730. */
  69731. prepareDefines(defines: any, lightIndex: number): void;
  69732. /**
  69733. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69734. * defined in the generator but impacting the effect).
  69735. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69736. * @param effect The effect we are binfing the information for
  69737. */
  69738. bindShadowLight(lightIndex: string, effect: Effect): void;
  69739. /**
  69740. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69741. * (eq to shadow prjection matrix * light transform matrix)
  69742. * @returns The transform matrix used to create the shadow map
  69743. */
  69744. getTransformMatrix(): Matrix;
  69745. /**
  69746. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69747. * Cube and 2D textures for instance.
  69748. */
  69749. recreateShadowMap(): void;
  69750. private _disposeBlurPostProcesses;
  69751. private _disposeRTTandPostProcesses;
  69752. /**
  69753. * Disposes the ShadowGenerator.
  69754. * Returns nothing.
  69755. */
  69756. dispose(): void;
  69757. /**
  69758. * Serializes the shadow generator setup to a json object.
  69759. * @returns The serialized JSON object
  69760. */
  69761. serialize(): any;
  69762. /**
  69763. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69764. * @param parsedShadowGenerator The JSON object to parse
  69765. * @param scene The scene to create the shadow map for
  69766. * @returns The parsed shadow generator
  69767. */
  69768. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69769. }
  69770. }
  69771. declare module BABYLON {
  69772. /**
  69773. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69774. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69775. * 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.
  69776. */
  69777. export abstract class Light extends Node {
  69778. /**
  69779. * Falloff Default: light is falling off following the material specification:
  69780. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69781. */
  69782. static readonly FALLOFF_DEFAULT: number;
  69783. /**
  69784. * Falloff Physical: light is falling off following the inverse squared distance law.
  69785. */
  69786. static readonly FALLOFF_PHYSICAL: number;
  69787. /**
  69788. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69789. * to enhance interoperability with other engines.
  69790. */
  69791. static readonly FALLOFF_GLTF: number;
  69792. /**
  69793. * Falloff Standard: light is falling off like in the standard material
  69794. * to enhance interoperability with other materials.
  69795. */
  69796. static readonly FALLOFF_STANDARD: number;
  69797. /**
  69798. * If every light affecting the material is in this lightmapMode,
  69799. * material.lightmapTexture adds or multiplies
  69800. * (depends on material.useLightmapAsShadowmap)
  69801. * after every other light calculations.
  69802. */
  69803. static readonly LIGHTMAP_DEFAULT: number;
  69804. /**
  69805. * material.lightmapTexture as only diffuse lighting from this light
  69806. * adds only specular lighting from this light
  69807. * adds dynamic shadows
  69808. */
  69809. static readonly LIGHTMAP_SPECULAR: number;
  69810. /**
  69811. * material.lightmapTexture as only lighting
  69812. * no light calculation from this light
  69813. * only adds dynamic shadows from this light
  69814. */
  69815. static readonly LIGHTMAP_SHADOWSONLY: number;
  69816. /**
  69817. * Each light type uses the default quantity according to its type:
  69818. * point/spot lights use luminous intensity
  69819. * directional lights use illuminance
  69820. */
  69821. static readonly INTENSITYMODE_AUTOMATIC: number;
  69822. /**
  69823. * lumen (lm)
  69824. */
  69825. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69826. /**
  69827. * candela (lm/sr)
  69828. */
  69829. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69830. /**
  69831. * lux (lm/m^2)
  69832. */
  69833. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69834. /**
  69835. * nit (cd/m^2)
  69836. */
  69837. static readonly INTENSITYMODE_LUMINANCE: number;
  69838. /**
  69839. * Light type const id of the point light.
  69840. */
  69841. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69842. /**
  69843. * Light type const id of the directional light.
  69844. */
  69845. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69846. /**
  69847. * Light type const id of the spot light.
  69848. */
  69849. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69850. /**
  69851. * Light type const id of the hemispheric light.
  69852. */
  69853. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69854. /**
  69855. * Diffuse gives the basic color to an object.
  69856. */
  69857. diffuse: Color3;
  69858. /**
  69859. * Specular produces a highlight color on an object.
  69860. * Note: This is note affecting PBR materials.
  69861. */
  69862. specular: Color3;
  69863. /**
  69864. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69865. * falling off base on range or angle.
  69866. * This can be set to any values in Light.FALLOFF_x.
  69867. *
  69868. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69869. * other types of materials.
  69870. */
  69871. falloffType: number;
  69872. /**
  69873. * Strength of the light.
  69874. * Note: By default it is define in the framework own unit.
  69875. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69876. */
  69877. intensity: number;
  69878. private _range;
  69879. protected _inverseSquaredRange: number;
  69880. /**
  69881. * Defines how far from the source the light is impacting in scene units.
  69882. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69883. */
  69884. /**
  69885. * Defines how far from the source the light is impacting in scene units.
  69886. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69887. */
  69888. range: number;
  69889. /**
  69890. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  69891. * of light.
  69892. */
  69893. private _photometricScale;
  69894. private _intensityMode;
  69895. /**
  69896. * Gets the photometric scale used to interpret the intensity.
  69897. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69898. */
  69899. /**
  69900. * Sets the photometric scale used to interpret the intensity.
  69901. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69902. */
  69903. intensityMode: number;
  69904. private _radius;
  69905. /**
  69906. * Gets the light radius used by PBR Materials to simulate soft area lights.
  69907. */
  69908. /**
  69909. * sets the light radius used by PBR Materials to simulate soft area lights.
  69910. */
  69911. radius: number;
  69912. private _renderPriority;
  69913. /**
  69914. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  69915. * exceeding the number allowed of the materials.
  69916. */
  69917. renderPriority: number;
  69918. private _shadowEnabled;
  69919. /**
  69920. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69921. * the current shadow generator.
  69922. */
  69923. /**
  69924. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69925. * the current shadow generator.
  69926. */
  69927. shadowEnabled: boolean;
  69928. private _includedOnlyMeshes;
  69929. /**
  69930. * Gets the only meshes impacted by this light.
  69931. */
  69932. /**
  69933. * Sets the only meshes impacted by this light.
  69934. */
  69935. includedOnlyMeshes: AbstractMesh[];
  69936. private _excludedMeshes;
  69937. /**
  69938. * Gets the meshes not impacted by this light.
  69939. */
  69940. /**
  69941. * Sets the meshes not impacted by this light.
  69942. */
  69943. excludedMeshes: AbstractMesh[];
  69944. private _excludeWithLayerMask;
  69945. /**
  69946. * Gets the layer id use to find what meshes are not impacted by the light.
  69947. * Inactive if 0
  69948. */
  69949. /**
  69950. * Sets the layer id use to find what meshes are not impacted by the light.
  69951. * Inactive if 0
  69952. */
  69953. excludeWithLayerMask: number;
  69954. private _includeOnlyWithLayerMask;
  69955. /**
  69956. * Gets the layer id use to find what meshes are impacted by the light.
  69957. * Inactive if 0
  69958. */
  69959. /**
  69960. * Sets the layer id use to find what meshes are impacted by the light.
  69961. * Inactive if 0
  69962. */
  69963. includeOnlyWithLayerMask: number;
  69964. private _lightmapMode;
  69965. /**
  69966. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69967. */
  69968. /**
  69969. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69970. */
  69971. lightmapMode: number;
  69972. /**
  69973. * Shadow generator associted to the light.
  69974. * @hidden Internal use only.
  69975. */
  69976. _shadowGenerator: Nullable<IShadowGenerator>;
  69977. /**
  69978. * @hidden Internal use only.
  69979. */
  69980. _excludedMeshesIds: string[];
  69981. /**
  69982. * @hidden Internal use only.
  69983. */
  69984. _includedOnlyMeshesIds: string[];
  69985. /**
  69986. * The current light unifom buffer.
  69987. * @hidden Internal use only.
  69988. */
  69989. _uniformBuffer: UniformBuffer;
  69990. /**
  69991. * Creates a Light object in the scene.
  69992. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69993. * @param name The firendly name of the light
  69994. * @param scene The scene the light belongs too
  69995. */
  69996. constructor(name: string, scene: Scene);
  69997. protected abstract _buildUniformLayout(): void;
  69998. /**
  69999. * Sets the passed Effect "effect" with the Light information.
  70000. * @param effect The effect to update
  70001. * @param lightIndex The index of the light in the effect to update
  70002. * @returns The light
  70003. */
  70004. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70005. /**
  70006. * Returns the string "Light".
  70007. * @returns the class name
  70008. */
  70009. getClassName(): string;
  70010. /** @hidden */
  70011. readonly _isLight: boolean;
  70012. /**
  70013. * Converts the light information to a readable string for debug purpose.
  70014. * @param fullDetails Supports for multiple levels of logging within scene loading
  70015. * @returns the human readable light info
  70016. */
  70017. toString(fullDetails?: boolean): string;
  70018. /** @hidden */
  70019. protected _syncParentEnabledState(): void;
  70020. /**
  70021. * Set the enabled state of this node.
  70022. * @param value - the new enabled state
  70023. */
  70024. setEnabled(value: boolean): void;
  70025. /**
  70026. * Returns the Light associated shadow generator if any.
  70027. * @return the associated shadow generator.
  70028. */
  70029. getShadowGenerator(): Nullable<IShadowGenerator>;
  70030. /**
  70031. * Returns a Vector3, the absolute light position in the World.
  70032. * @returns the world space position of the light
  70033. */
  70034. getAbsolutePosition(): Vector3;
  70035. /**
  70036. * Specifies if the light will affect the passed mesh.
  70037. * @param mesh The mesh to test against the light
  70038. * @return true the mesh is affected otherwise, false.
  70039. */
  70040. canAffectMesh(mesh: AbstractMesh): boolean;
  70041. /**
  70042. * Sort function to order lights for rendering.
  70043. * @param a First Light object to compare to second.
  70044. * @param b Second Light object to compare first.
  70045. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70046. */
  70047. static CompareLightsPriority(a: Light, b: Light): number;
  70048. /**
  70049. * Releases resources associated with this node.
  70050. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70051. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70052. */
  70053. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70054. /**
  70055. * Returns the light type ID (integer).
  70056. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70057. */
  70058. getTypeID(): number;
  70059. /**
  70060. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70061. * @returns the scaled intensity in intensity mode unit
  70062. */
  70063. getScaledIntensity(): number;
  70064. /**
  70065. * Returns a new Light object, named "name", from the current one.
  70066. * @param name The name of the cloned light
  70067. * @returns the new created light
  70068. */
  70069. clone(name: string): Nullable<Light>;
  70070. /**
  70071. * Serializes the current light into a Serialization object.
  70072. * @returns the serialized object.
  70073. */
  70074. serialize(): any;
  70075. /**
  70076. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70077. * This new light is named "name" and added to the passed scene.
  70078. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70079. * @param name The friendly name of the light
  70080. * @param scene The scene the new light will belong to
  70081. * @returns the constructor function
  70082. */
  70083. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70084. /**
  70085. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70086. * @param parsedLight The JSON representation of the light
  70087. * @param scene The scene to create the parsed light in
  70088. * @returns the created light after parsing
  70089. */
  70090. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70091. private _hookArrayForExcluded;
  70092. private _hookArrayForIncludedOnly;
  70093. private _resyncMeshes;
  70094. /**
  70095. * Forces the meshes to update their light related information in their rendering used effects
  70096. * @hidden Internal Use Only
  70097. */
  70098. _markMeshesAsLightDirty(): void;
  70099. /**
  70100. * Recomputes the cached photometric scale if needed.
  70101. */
  70102. private _computePhotometricScale;
  70103. /**
  70104. * Returns the Photometric Scale according to the light type and intensity mode.
  70105. */
  70106. private _getPhotometricScale;
  70107. /**
  70108. * Reorder the light in the scene according to their defined priority.
  70109. * @hidden Internal Use Only
  70110. */
  70111. _reorderLightsInScene(): void;
  70112. /**
  70113. * Prepares the list of defines specific to the light type.
  70114. * @param defines the list of defines
  70115. * @param lightIndex defines the index of the light for the effect
  70116. */
  70117. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70118. }
  70119. }
  70120. declare module BABYLON {
  70121. /**
  70122. * Interface used to define Action
  70123. */
  70124. export interface IAction {
  70125. /**
  70126. * Trigger for the action
  70127. */
  70128. trigger: number;
  70129. /** Options of the trigger */
  70130. triggerOptions: any;
  70131. /**
  70132. * Gets the trigger parameters
  70133. * @returns the trigger parameters
  70134. */
  70135. getTriggerParameter(): any;
  70136. /**
  70137. * Internal only - executes current action event
  70138. * @hidden
  70139. */
  70140. _executeCurrent(evt?: ActionEvent): void;
  70141. /**
  70142. * Serialize placeholder for child classes
  70143. * @param parent of child
  70144. * @returns the serialized object
  70145. */
  70146. serialize(parent: any): any;
  70147. /**
  70148. * Internal only
  70149. * @hidden
  70150. */
  70151. _prepare(): void;
  70152. /**
  70153. * Internal only - manager for action
  70154. * @hidden
  70155. */
  70156. _actionManager: AbstractActionManager;
  70157. }
  70158. /**
  70159. * The action to be carried out following a trigger
  70160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70161. */
  70162. export class Action implements IAction {
  70163. /** the trigger, with or without parameters, for the action */
  70164. triggerOptions: any;
  70165. /**
  70166. * Trigger for the action
  70167. */
  70168. trigger: number;
  70169. /**
  70170. * Internal only - manager for action
  70171. * @hidden
  70172. */
  70173. _actionManager: ActionManager;
  70174. private _nextActiveAction;
  70175. private _child;
  70176. private _condition?;
  70177. private _triggerParameter;
  70178. /**
  70179. * An event triggered prior to action being executed.
  70180. */
  70181. onBeforeExecuteObservable: Observable<Action>;
  70182. /**
  70183. * Creates a new Action
  70184. * @param triggerOptions the trigger, with or without parameters, for the action
  70185. * @param condition an optional determinant of action
  70186. */
  70187. constructor(
  70188. /** the trigger, with or without parameters, for the action */
  70189. triggerOptions: any, condition?: Condition);
  70190. /**
  70191. * Internal only
  70192. * @hidden
  70193. */
  70194. _prepare(): void;
  70195. /**
  70196. * Gets the trigger parameters
  70197. * @returns the trigger parameters
  70198. */
  70199. getTriggerParameter(): any;
  70200. /**
  70201. * Internal only - executes current action event
  70202. * @hidden
  70203. */
  70204. _executeCurrent(evt?: ActionEvent): void;
  70205. /**
  70206. * Execute placeholder for child classes
  70207. * @param evt optional action event
  70208. */
  70209. execute(evt?: ActionEvent): void;
  70210. /**
  70211. * Skips to next active action
  70212. */
  70213. skipToNextActiveAction(): void;
  70214. /**
  70215. * Adds action to chain of actions, may be a DoNothingAction
  70216. * @param action defines the next action to execute
  70217. * @returns The action passed in
  70218. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70219. */
  70220. then(action: Action): Action;
  70221. /**
  70222. * Internal only
  70223. * @hidden
  70224. */
  70225. _getProperty(propertyPath: string): string;
  70226. /**
  70227. * Internal only
  70228. * @hidden
  70229. */
  70230. _getEffectiveTarget(target: any, propertyPath: string): any;
  70231. /**
  70232. * Serialize placeholder for child classes
  70233. * @param parent of child
  70234. * @returns the serialized object
  70235. */
  70236. serialize(parent: any): any;
  70237. /**
  70238. * Internal only called by serialize
  70239. * @hidden
  70240. */
  70241. protected _serialize(serializedAction: any, parent?: any): any;
  70242. /**
  70243. * Internal only
  70244. * @hidden
  70245. */
  70246. static _SerializeValueAsString: (value: any) => string;
  70247. /**
  70248. * Internal only
  70249. * @hidden
  70250. */
  70251. static _GetTargetProperty: (target: Scene | Node) => {
  70252. name: string;
  70253. targetType: string;
  70254. value: string;
  70255. };
  70256. }
  70257. }
  70258. declare module BABYLON {
  70259. /**
  70260. * A Condition applied to an Action
  70261. */
  70262. export class Condition {
  70263. /**
  70264. * Internal only - manager for action
  70265. * @hidden
  70266. */
  70267. _actionManager: ActionManager;
  70268. /**
  70269. * Internal only
  70270. * @hidden
  70271. */
  70272. _evaluationId: number;
  70273. /**
  70274. * Internal only
  70275. * @hidden
  70276. */
  70277. _currentResult: boolean;
  70278. /**
  70279. * Creates a new Condition
  70280. * @param actionManager the manager of the action the condition is applied to
  70281. */
  70282. constructor(actionManager: ActionManager);
  70283. /**
  70284. * Check if the current condition is valid
  70285. * @returns a boolean
  70286. */
  70287. isValid(): boolean;
  70288. /**
  70289. * Internal only
  70290. * @hidden
  70291. */
  70292. _getProperty(propertyPath: string): string;
  70293. /**
  70294. * Internal only
  70295. * @hidden
  70296. */
  70297. _getEffectiveTarget(target: any, propertyPath: string): any;
  70298. /**
  70299. * Serialize placeholder for child classes
  70300. * @returns the serialized object
  70301. */
  70302. serialize(): any;
  70303. /**
  70304. * Internal only
  70305. * @hidden
  70306. */
  70307. protected _serialize(serializedCondition: any): any;
  70308. }
  70309. /**
  70310. * Defines specific conditional operators as extensions of Condition
  70311. */
  70312. export class ValueCondition extends Condition {
  70313. /** path to specify the property of the target the conditional operator uses */
  70314. propertyPath: string;
  70315. /** the value compared by the conditional operator against the current value of the property */
  70316. value: any;
  70317. /** the conditional operator, default ValueCondition.IsEqual */
  70318. operator: number;
  70319. /**
  70320. * Internal only
  70321. * @hidden
  70322. */
  70323. private static _IsEqual;
  70324. /**
  70325. * Internal only
  70326. * @hidden
  70327. */
  70328. private static _IsDifferent;
  70329. /**
  70330. * Internal only
  70331. * @hidden
  70332. */
  70333. private static _IsGreater;
  70334. /**
  70335. * Internal only
  70336. * @hidden
  70337. */
  70338. private static _IsLesser;
  70339. /**
  70340. * returns the number for IsEqual
  70341. */
  70342. static readonly IsEqual: number;
  70343. /**
  70344. * Returns the number for IsDifferent
  70345. */
  70346. static readonly IsDifferent: number;
  70347. /**
  70348. * Returns the number for IsGreater
  70349. */
  70350. static readonly IsGreater: number;
  70351. /**
  70352. * Returns the number for IsLesser
  70353. */
  70354. static readonly IsLesser: number;
  70355. /**
  70356. * Internal only The action manager for the condition
  70357. * @hidden
  70358. */
  70359. _actionManager: ActionManager;
  70360. /**
  70361. * Internal only
  70362. * @hidden
  70363. */
  70364. private _target;
  70365. /**
  70366. * Internal only
  70367. * @hidden
  70368. */
  70369. private _effectiveTarget;
  70370. /**
  70371. * Internal only
  70372. * @hidden
  70373. */
  70374. private _property;
  70375. /**
  70376. * Creates a new ValueCondition
  70377. * @param actionManager manager for the action the condition applies to
  70378. * @param target for the action
  70379. * @param propertyPath path to specify the property of the target the conditional operator uses
  70380. * @param value the value compared by the conditional operator against the current value of the property
  70381. * @param operator the conditional operator, default ValueCondition.IsEqual
  70382. */
  70383. constructor(actionManager: ActionManager, target: any,
  70384. /** path to specify the property of the target the conditional operator uses */
  70385. propertyPath: string,
  70386. /** the value compared by the conditional operator against the current value of the property */
  70387. value: any,
  70388. /** the conditional operator, default ValueCondition.IsEqual */
  70389. operator?: number);
  70390. /**
  70391. * Compares the given value with the property value for the specified conditional operator
  70392. * @returns the result of the comparison
  70393. */
  70394. isValid(): boolean;
  70395. /**
  70396. * Serialize the ValueCondition into a JSON compatible object
  70397. * @returns serialization object
  70398. */
  70399. serialize(): any;
  70400. /**
  70401. * Gets the name of the conditional operator for the ValueCondition
  70402. * @param operator the conditional operator
  70403. * @returns the name
  70404. */
  70405. static GetOperatorName(operator: number): string;
  70406. }
  70407. /**
  70408. * Defines a predicate condition as an extension of Condition
  70409. */
  70410. export class PredicateCondition extends Condition {
  70411. /** defines the predicate function used to validate the condition */
  70412. predicate: () => boolean;
  70413. /**
  70414. * Internal only - manager for action
  70415. * @hidden
  70416. */
  70417. _actionManager: ActionManager;
  70418. /**
  70419. * Creates a new PredicateCondition
  70420. * @param actionManager manager for the action the condition applies to
  70421. * @param predicate defines the predicate function used to validate the condition
  70422. */
  70423. constructor(actionManager: ActionManager,
  70424. /** defines the predicate function used to validate the condition */
  70425. predicate: () => boolean);
  70426. /**
  70427. * @returns the validity of the predicate condition
  70428. */
  70429. isValid(): boolean;
  70430. }
  70431. /**
  70432. * Defines a state condition as an extension of Condition
  70433. */
  70434. export class StateCondition extends Condition {
  70435. /** Value to compare with target state */
  70436. value: string;
  70437. /**
  70438. * Internal only - manager for action
  70439. * @hidden
  70440. */
  70441. _actionManager: ActionManager;
  70442. /**
  70443. * Internal only
  70444. * @hidden
  70445. */
  70446. private _target;
  70447. /**
  70448. * Creates a new StateCondition
  70449. * @param actionManager manager for the action the condition applies to
  70450. * @param target of the condition
  70451. * @param value to compare with target state
  70452. */
  70453. constructor(actionManager: ActionManager, target: any,
  70454. /** Value to compare with target state */
  70455. value: string);
  70456. /**
  70457. * Gets a boolean indicating if the current condition is met
  70458. * @returns the validity of the state
  70459. */
  70460. isValid(): boolean;
  70461. /**
  70462. * Serialize the StateCondition into a JSON compatible object
  70463. * @returns serialization object
  70464. */
  70465. serialize(): any;
  70466. }
  70467. }
  70468. declare module BABYLON {
  70469. /**
  70470. * This defines an action responsible to toggle a boolean once triggered.
  70471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70472. */
  70473. export class SwitchBooleanAction extends Action {
  70474. /**
  70475. * The path to the boolean property in the target object
  70476. */
  70477. propertyPath: string;
  70478. private _target;
  70479. private _effectiveTarget;
  70480. private _property;
  70481. /**
  70482. * Instantiate the action
  70483. * @param triggerOptions defines the trigger options
  70484. * @param target defines the object containing the boolean
  70485. * @param propertyPath defines the path to the boolean property in the target object
  70486. * @param condition defines the trigger related conditions
  70487. */
  70488. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70489. /** @hidden */
  70490. _prepare(): void;
  70491. /**
  70492. * Execute the action toggle the boolean value.
  70493. */
  70494. execute(): void;
  70495. /**
  70496. * Serializes the actions and its related information.
  70497. * @param parent defines the object to serialize in
  70498. * @returns the serialized object
  70499. */
  70500. serialize(parent: any): any;
  70501. }
  70502. /**
  70503. * This defines an action responsible to set a the state field of the target
  70504. * to a desired value once triggered.
  70505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70506. */
  70507. export class SetStateAction extends Action {
  70508. /**
  70509. * The value to store in the state field.
  70510. */
  70511. value: string;
  70512. private _target;
  70513. /**
  70514. * Instantiate the action
  70515. * @param triggerOptions defines the trigger options
  70516. * @param target defines the object containing the state property
  70517. * @param value defines the value to store in the state field
  70518. * @param condition defines the trigger related conditions
  70519. */
  70520. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70521. /**
  70522. * Execute the action and store the value on the target state property.
  70523. */
  70524. execute(): 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 set a property of the target
  70534. * to a desired value once triggered.
  70535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70536. */
  70537. export class SetValueAction extends Action {
  70538. /**
  70539. * The path of the property to set in the target.
  70540. */
  70541. propertyPath: string;
  70542. /**
  70543. * The value to set in the property
  70544. */
  70545. value: any;
  70546. private _target;
  70547. private _effectiveTarget;
  70548. private _property;
  70549. /**
  70550. * Instantiate the action
  70551. * @param triggerOptions defines the trigger options
  70552. * @param target defines the object containing the property
  70553. * @param propertyPath defines the path of the property to set in the target
  70554. * @param value defines the value to set in the property
  70555. * @param condition defines the trigger related conditions
  70556. */
  70557. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70558. /** @hidden */
  70559. _prepare(): void;
  70560. /**
  70561. * Execute the action and set the targetted property to the desired value.
  70562. */
  70563. execute(): void;
  70564. /**
  70565. * Serializes the actions and its related information.
  70566. * @param parent defines the object to serialize in
  70567. * @returns the serialized object
  70568. */
  70569. serialize(parent: any): any;
  70570. }
  70571. /**
  70572. * This defines an action responsible to increment the target value
  70573. * to a desired value once triggered.
  70574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70575. */
  70576. export class IncrementValueAction extends Action {
  70577. /**
  70578. * The path of the property to increment in the target.
  70579. */
  70580. propertyPath: string;
  70581. /**
  70582. * The value we should increment the property by.
  70583. */
  70584. value: any;
  70585. private _target;
  70586. private _effectiveTarget;
  70587. private _property;
  70588. /**
  70589. * Instantiate the action
  70590. * @param triggerOptions defines the trigger options
  70591. * @param target defines the object containing the property
  70592. * @param propertyPath defines the path of the property to increment in the target
  70593. * @param value defines the value value we should increment the property by
  70594. * @param condition defines the trigger related conditions
  70595. */
  70596. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70597. /** @hidden */
  70598. _prepare(): void;
  70599. /**
  70600. * Execute the action and increment the target of the value amount.
  70601. */
  70602. execute(): void;
  70603. /**
  70604. * Serializes the actions and its related information.
  70605. * @param parent defines the object to serialize in
  70606. * @returns the serialized object
  70607. */
  70608. serialize(parent: any): any;
  70609. }
  70610. /**
  70611. * This defines an action responsible to start an animation once triggered.
  70612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70613. */
  70614. export class PlayAnimationAction extends Action {
  70615. /**
  70616. * Where the animation should start (animation frame)
  70617. */
  70618. from: number;
  70619. /**
  70620. * Where the animation should stop (animation frame)
  70621. */
  70622. to: number;
  70623. /**
  70624. * Define if the animation should loop or stop after the first play.
  70625. */
  70626. loop?: boolean;
  70627. private _target;
  70628. /**
  70629. * Instantiate the action
  70630. * @param triggerOptions defines the trigger options
  70631. * @param target defines the target animation or animation name
  70632. * @param from defines from where the animation should start (animation frame)
  70633. * @param end defines where the animation should stop (animation frame)
  70634. * @param loop defines if the animation should loop or stop after the first play
  70635. * @param condition defines the trigger related conditions
  70636. */
  70637. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70638. /** @hidden */
  70639. _prepare(): void;
  70640. /**
  70641. * Execute the action and play the animation.
  70642. */
  70643. execute(): void;
  70644. /**
  70645. * Serializes the actions and its related information.
  70646. * @param parent defines the object to serialize in
  70647. * @returns the serialized object
  70648. */
  70649. serialize(parent: any): any;
  70650. }
  70651. /**
  70652. * This defines an action responsible to stop an animation once triggered.
  70653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70654. */
  70655. export class StopAnimationAction extends Action {
  70656. private _target;
  70657. /**
  70658. * Instantiate the action
  70659. * @param triggerOptions defines the trigger options
  70660. * @param target defines the target animation or animation name
  70661. * @param condition defines the trigger related conditions
  70662. */
  70663. constructor(triggerOptions: any, target: any, condition?: Condition);
  70664. /** @hidden */
  70665. _prepare(): void;
  70666. /**
  70667. * Execute the action and stop the animation.
  70668. */
  70669. execute(): void;
  70670. /**
  70671. * Serializes the actions and its related information.
  70672. * @param parent defines the object to serialize in
  70673. * @returns the serialized object
  70674. */
  70675. serialize(parent: any): any;
  70676. }
  70677. /**
  70678. * This defines an action responsible that does nothing once triggered.
  70679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70680. */
  70681. export class DoNothingAction extends Action {
  70682. /**
  70683. * Instantiate the action
  70684. * @param triggerOptions defines the trigger options
  70685. * @param condition defines the trigger related conditions
  70686. */
  70687. constructor(triggerOptions?: any, condition?: Condition);
  70688. /**
  70689. * Execute the action and do nothing.
  70690. */
  70691. execute(): void;
  70692. /**
  70693. * Serializes the actions and its related information.
  70694. * @param parent defines the object to serialize in
  70695. * @returns the serialized object
  70696. */
  70697. serialize(parent: any): any;
  70698. }
  70699. /**
  70700. * This defines an action responsible to trigger several actions once triggered.
  70701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70702. */
  70703. export class CombineAction extends Action {
  70704. /**
  70705. * The list of aggregated animations to run.
  70706. */
  70707. children: Action[];
  70708. /**
  70709. * Instantiate the action
  70710. * @param triggerOptions defines the trigger options
  70711. * @param children defines the list of aggregated animations to run
  70712. * @param condition defines the trigger related conditions
  70713. */
  70714. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70715. /** @hidden */
  70716. _prepare(): void;
  70717. /**
  70718. * Execute the action and executes all the aggregated actions.
  70719. */
  70720. execute(evt: ActionEvent): void;
  70721. /**
  70722. * Serializes the actions and its related information.
  70723. * @param parent defines the object to serialize in
  70724. * @returns the serialized object
  70725. */
  70726. serialize(parent: any): any;
  70727. }
  70728. /**
  70729. * This defines an action responsible to run code (external event) once triggered.
  70730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70731. */
  70732. export class ExecuteCodeAction extends Action {
  70733. /**
  70734. * The callback function to run.
  70735. */
  70736. func: (evt: ActionEvent) => void;
  70737. /**
  70738. * Instantiate the action
  70739. * @param triggerOptions defines the trigger options
  70740. * @param func defines the callback function to run
  70741. * @param condition defines the trigger related conditions
  70742. */
  70743. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70744. /**
  70745. * Execute the action and run the attached code.
  70746. */
  70747. execute(evt: ActionEvent): void;
  70748. }
  70749. /**
  70750. * This defines an action responsible to set the parent property of the target once triggered.
  70751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70752. */
  70753. export class SetParentAction extends Action {
  70754. private _parent;
  70755. private _target;
  70756. /**
  70757. * Instantiate the action
  70758. * @param triggerOptions defines the trigger options
  70759. * @param target defines the target containing the parent property
  70760. * @param parent defines from where the animation should start (animation frame)
  70761. * @param condition defines the trigger related conditions
  70762. */
  70763. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70764. /** @hidden */
  70765. _prepare(): void;
  70766. /**
  70767. * Execute the action and set the parent property.
  70768. */
  70769. execute(): void;
  70770. /**
  70771. * Serializes the actions and its related information.
  70772. * @param parent defines the object to serialize in
  70773. * @returns the serialized object
  70774. */
  70775. serialize(parent: any): any;
  70776. }
  70777. }
  70778. declare module BABYLON {
  70779. /**
  70780. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70781. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70783. */
  70784. export class ActionManager extends AbstractActionManager {
  70785. /**
  70786. * Nothing
  70787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70788. */
  70789. static readonly NothingTrigger: number;
  70790. /**
  70791. * On pick
  70792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70793. */
  70794. static readonly OnPickTrigger: number;
  70795. /**
  70796. * On left pick
  70797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70798. */
  70799. static readonly OnLeftPickTrigger: number;
  70800. /**
  70801. * On right pick
  70802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70803. */
  70804. static readonly OnRightPickTrigger: number;
  70805. /**
  70806. * On center pick
  70807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70808. */
  70809. static readonly OnCenterPickTrigger: number;
  70810. /**
  70811. * On pick down
  70812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70813. */
  70814. static readonly OnPickDownTrigger: number;
  70815. /**
  70816. * On double pick
  70817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70818. */
  70819. static readonly OnDoublePickTrigger: number;
  70820. /**
  70821. * On pick up
  70822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70823. */
  70824. static readonly OnPickUpTrigger: number;
  70825. /**
  70826. * On pick out.
  70827. * This trigger will only be raised if you also declared a OnPickDown
  70828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70829. */
  70830. static readonly OnPickOutTrigger: number;
  70831. /**
  70832. * On long press
  70833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70834. */
  70835. static readonly OnLongPressTrigger: number;
  70836. /**
  70837. * On pointer over
  70838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70839. */
  70840. static readonly OnPointerOverTrigger: number;
  70841. /**
  70842. * On pointer out
  70843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70844. */
  70845. static readonly OnPointerOutTrigger: number;
  70846. /**
  70847. * On every frame
  70848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70849. */
  70850. static readonly OnEveryFrameTrigger: number;
  70851. /**
  70852. * On intersection enter
  70853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70854. */
  70855. static readonly OnIntersectionEnterTrigger: number;
  70856. /**
  70857. * On intersection exit
  70858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70859. */
  70860. static readonly OnIntersectionExitTrigger: number;
  70861. /**
  70862. * On key down
  70863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70864. */
  70865. static readonly OnKeyDownTrigger: number;
  70866. /**
  70867. * On key up
  70868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70869. */
  70870. static readonly OnKeyUpTrigger: number;
  70871. private _scene;
  70872. /**
  70873. * Creates a new action manager
  70874. * @param scene defines the hosting scene
  70875. */
  70876. constructor(scene: Scene);
  70877. /**
  70878. * Releases all associated resources
  70879. */
  70880. dispose(): void;
  70881. /**
  70882. * Gets hosting scene
  70883. * @returns the hosting scene
  70884. */
  70885. getScene(): Scene;
  70886. /**
  70887. * Does this action manager handles actions of any of the given triggers
  70888. * @param triggers defines the triggers to be tested
  70889. * @return a boolean indicating whether one (or more) of the triggers is handled
  70890. */
  70891. hasSpecificTriggers(triggers: number[]): boolean;
  70892. /**
  70893. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  70894. * speed.
  70895. * @param triggerA defines the trigger to be tested
  70896. * @param triggerB defines the trigger to be tested
  70897. * @return a boolean indicating whether one (or more) of the triggers is handled
  70898. */
  70899. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  70900. /**
  70901. * Does this action manager handles actions of a given trigger
  70902. * @param trigger defines the trigger to be tested
  70903. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  70904. * @return whether the trigger is handled
  70905. */
  70906. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  70907. /**
  70908. * Does this action manager has pointer triggers
  70909. */
  70910. readonly hasPointerTriggers: boolean;
  70911. /**
  70912. * Does this action manager has pick triggers
  70913. */
  70914. readonly hasPickTriggers: boolean;
  70915. /**
  70916. * Registers an action to this action manager
  70917. * @param action defines the action to be registered
  70918. * @return the action amended (prepared) after registration
  70919. */
  70920. registerAction(action: IAction): Nullable<IAction>;
  70921. /**
  70922. * Unregisters an action to this action manager
  70923. * @param action defines the action to be unregistered
  70924. * @return a boolean indicating whether the action has been unregistered
  70925. */
  70926. unregisterAction(action: IAction): Boolean;
  70927. /**
  70928. * Process a specific trigger
  70929. * @param trigger defines the trigger to process
  70930. * @param evt defines the event details to be processed
  70931. */
  70932. processTrigger(trigger: number, evt?: IActionEvent): void;
  70933. /** @hidden */
  70934. _getEffectiveTarget(target: any, propertyPath: string): any;
  70935. /** @hidden */
  70936. _getProperty(propertyPath: string): string;
  70937. /**
  70938. * Serialize this manager to a JSON object
  70939. * @param name defines the property name to store this manager
  70940. * @returns a JSON representation of this manager
  70941. */
  70942. serialize(name: string): any;
  70943. /**
  70944. * Creates a new ActionManager from a JSON data
  70945. * @param parsedActions defines the JSON data to read from
  70946. * @param object defines the hosting mesh
  70947. * @param scene defines the hosting scene
  70948. */
  70949. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  70950. /**
  70951. * Get a trigger name by index
  70952. * @param trigger defines the trigger index
  70953. * @returns a trigger name
  70954. */
  70955. static GetTriggerName(trigger: number): string;
  70956. }
  70957. }
  70958. declare module BABYLON {
  70959. /**
  70960. * Class representing a ray with position and direction
  70961. */
  70962. export class Ray {
  70963. /** origin point */
  70964. origin: Vector3;
  70965. /** direction */
  70966. direction: Vector3;
  70967. /** length of the ray */
  70968. length: number;
  70969. private static readonly TmpVector3;
  70970. private _tmpRay;
  70971. /**
  70972. * Creates a new ray
  70973. * @param origin origin point
  70974. * @param direction direction
  70975. * @param length length of the ray
  70976. */
  70977. constructor(
  70978. /** origin point */
  70979. origin: Vector3,
  70980. /** direction */
  70981. direction: Vector3,
  70982. /** length of the ray */
  70983. length?: number);
  70984. /**
  70985. * Checks if the ray intersects a box
  70986. * @param minimum bound of the box
  70987. * @param maximum bound of the box
  70988. * @param intersectionTreshold extra extend to be added to the box in all direction
  70989. * @returns if the box was hit
  70990. */
  70991. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  70992. /**
  70993. * Checks if the ray intersects a box
  70994. * @param box the bounding box to check
  70995. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  70996. * @returns if the box was hit
  70997. */
  70998. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  70999. /**
  71000. * If the ray hits a sphere
  71001. * @param sphere the bounding sphere to check
  71002. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71003. * @returns true if it hits the sphere
  71004. */
  71005. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71006. /**
  71007. * If the ray hits a triange
  71008. * @param vertex0 triangle vertex
  71009. * @param vertex1 triangle vertex
  71010. * @param vertex2 triangle vertex
  71011. * @returns intersection information if hit
  71012. */
  71013. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71014. /**
  71015. * Checks if ray intersects a plane
  71016. * @param plane the plane to check
  71017. * @returns the distance away it was hit
  71018. */
  71019. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71020. /**
  71021. * Checks if ray intersects a mesh
  71022. * @param mesh the mesh to check
  71023. * @param fastCheck if only the bounding box should checked
  71024. * @returns picking info of the intersecton
  71025. */
  71026. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71027. /**
  71028. * Checks if ray intersects a mesh
  71029. * @param meshes the meshes to check
  71030. * @param fastCheck if only the bounding box should checked
  71031. * @param results array to store result in
  71032. * @returns Array of picking infos
  71033. */
  71034. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71035. private _comparePickingInfo;
  71036. private static smallnum;
  71037. private static rayl;
  71038. /**
  71039. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71040. * @param sega the first point of the segment to test the intersection against
  71041. * @param segb the second point of the segment to test the intersection against
  71042. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71043. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71044. */
  71045. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71046. /**
  71047. * Update the ray from viewport position
  71048. * @param x position
  71049. * @param y y position
  71050. * @param viewportWidth viewport width
  71051. * @param viewportHeight viewport height
  71052. * @param world world matrix
  71053. * @param view view matrix
  71054. * @param projection projection matrix
  71055. * @returns this ray updated
  71056. */
  71057. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71058. /**
  71059. * Creates a ray with origin and direction of 0,0,0
  71060. * @returns the new ray
  71061. */
  71062. static Zero(): Ray;
  71063. /**
  71064. * Creates a new ray from screen space and viewport
  71065. * @param x position
  71066. * @param y y position
  71067. * @param viewportWidth viewport width
  71068. * @param viewportHeight viewport height
  71069. * @param world world matrix
  71070. * @param view view matrix
  71071. * @param projection projection matrix
  71072. * @returns new ray
  71073. */
  71074. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71075. /**
  71076. * 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
  71077. * transformed to the given world matrix.
  71078. * @param origin The origin point
  71079. * @param end The end point
  71080. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71081. * @returns the new ray
  71082. */
  71083. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71084. /**
  71085. * Transforms a ray by a matrix
  71086. * @param ray ray to transform
  71087. * @param matrix matrix to apply
  71088. * @returns the resulting new ray
  71089. */
  71090. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71091. /**
  71092. * Transforms a ray by a matrix
  71093. * @param ray ray to transform
  71094. * @param matrix matrix to apply
  71095. * @param result ray to store result in
  71096. */
  71097. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71098. /**
  71099. * Unproject a ray from screen space to object space
  71100. * @param sourceX defines the screen space x coordinate to use
  71101. * @param sourceY defines the screen space y coordinate to use
  71102. * @param viewportWidth defines the current width of the viewport
  71103. * @param viewportHeight defines the current height of the viewport
  71104. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71105. * @param view defines the view matrix to use
  71106. * @param projection defines the projection matrix to use
  71107. */
  71108. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71109. }
  71110. /**
  71111. * Type used to define predicate used to select faces when a mesh intersection is detected
  71112. */
  71113. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71114. interface Scene {
  71115. /** @hidden */
  71116. _tempPickingRay: Nullable<Ray>;
  71117. /** @hidden */
  71118. _cachedRayForTransform: Ray;
  71119. /** @hidden */
  71120. _pickWithRayInverseMatrix: Matrix;
  71121. /** @hidden */
  71122. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71123. /** @hidden */
  71124. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71125. }
  71126. }
  71127. declare module BABYLON {
  71128. /**
  71129. * Groups all the scene component constants in one place to ease maintenance.
  71130. * @hidden
  71131. */
  71132. export class SceneComponentConstants {
  71133. static readonly NAME_EFFECTLAYER: string;
  71134. static readonly NAME_LAYER: string;
  71135. static readonly NAME_LENSFLARESYSTEM: string;
  71136. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71137. static readonly NAME_PARTICLESYSTEM: string;
  71138. static readonly NAME_GAMEPAD: string;
  71139. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71140. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71141. static readonly NAME_DEPTHRENDERER: string;
  71142. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71143. static readonly NAME_SPRITE: string;
  71144. static readonly NAME_OUTLINERENDERER: string;
  71145. static readonly NAME_PROCEDURALTEXTURE: string;
  71146. static readonly NAME_SHADOWGENERATOR: string;
  71147. static readonly NAME_OCTREE: string;
  71148. static readonly NAME_PHYSICSENGINE: string;
  71149. static readonly NAME_AUDIO: string;
  71150. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71151. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71152. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71153. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71154. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71155. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71156. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71157. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71158. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71159. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71160. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71161. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71162. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71163. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71164. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71165. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71166. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71167. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71168. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71169. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71170. static readonly STEP_AFTERRENDER_AUDIO: number;
  71171. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71172. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71173. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71174. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71175. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71176. static readonly STEP_POINTERMOVE_SPRITE: number;
  71177. static readonly STEP_POINTERDOWN_SPRITE: number;
  71178. static readonly STEP_POINTERUP_SPRITE: number;
  71179. }
  71180. /**
  71181. * This represents a scene component.
  71182. *
  71183. * This is used to decouple the dependency the scene is having on the different workloads like
  71184. * layers, post processes...
  71185. */
  71186. export interface ISceneComponent {
  71187. /**
  71188. * The name of the component. Each component must have a unique name.
  71189. */
  71190. name: string;
  71191. /**
  71192. * The scene the component belongs to.
  71193. */
  71194. scene: Scene;
  71195. /**
  71196. * Register the component to one instance of a scene.
  71197. */
  71198. register(): void;
  71199. /**
  71200. * Rebuilds the elements related to this component in case of
  71201. * context lost for instance.
  71202. */
  71203. rebuild(): void;
  71204. /**
  71205. * Disposes the component and the associated ressources.
  71206. */
  71207. dispose(): void;
  71208. }
  71209. /**
  71210. * This represents a SERIALIZABLE scene component.
  71211. *
  71212. * This extends Scene Component to add Serialization methods on top.
  71213. */
  71214. export interface ISceneSerializableComponent extends ISceneComponent {
  71215. /**
  71216. * Adds all the element from the container to the scene
  71217. * @param container the container holding the elements
  71218. */
  71219. addFromContainer(container: AbstractScene): void;
  71220. /**
  71221. * Removes all the elements in the container from the scene
  71222. * @param container contains the elements to remove
  71223. * @param dispose if the removed element should be disposed (default: false)
  71224. */
  71225. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71226. /**
  71227. * Serializes the component data to the specified json object
  71228. * @param serializationObject The object to serialize to
  71229. */
  71230. serialize(serializationObject: any): void;
  71231. }
  71232. /**
  71233. * Strong typing of a Mesh related stage step action
  71234. */
  71235. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71236. /**
  71237. * Strong typing of a Evaluate Sub Mesh related stage step action
  71238. */
  71239. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71240. /**
  71241. * Strong typing of a Active Mesh related stage step action
  71242. */
  71243. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71244. /**
  71245. * Strong typing of a Camera related stage step action
  71246. */
  71247. export type CameraStageAction = (camera: Camera) => void;
  71248. /**
  71249. * Strong typing of a Camera Frame buffer related stage step action
  71250. */
  71251. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71252. /**
  71253. * Strong typing of a Render Target related stage step action
  71254. */
  71255. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71256. /**
  71257. * Strong typing of a RenderingGroup related stage step action
  71258. */
  71259. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71260. /**
  71261. * Strong typing of a Mesh Render related stage step action
  71262. */
  71263. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71264. /**
  71265. * Strong typing of a simple stage step action
  71266. */
  71267. export type SimpleStageAction = () => void;
  71268. /**
  71269. * Strong typing of a render target action.
  71270. */
  71271. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71272. /**
  71273. * Strong typing of a pointer move action.
  71274. */
  71275. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71276. /**
  71277. * Strong typing of a pointer up/down action.
  71278. */
  71279. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71280. /**
  71281. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71282. * @hidden
  71283. */
  71284. export class Stage<T extends Function> extends Array<{
  71285. index: number;
  71286. component: ISceneComponent;
  71287. action: T;
  71288. }> {
  71289. /**
  71290. * Hide ctor from the rest of the world.
  71291. * @param items The items to add.
  71292. */
  71293. private constructor();
  71294. /**
  71295. * Creates a new Stage.
  71296. * @returns A new instance of a Stage
  71297. */
  71298. static Create<T extends Function>(): Stage<T>;
  71299. /**
  71300. * Registers a step in an ordered way in the targeted stage.
  71301. * @param index Defines the position to register the step in
  71302. * @param component Defines the component attached to the step
  71303. * @param action Defines the action to launch during the step
  71304. */
  71305. registerStep(index: number, component: ISceneComponent, action: T): void;
  71306. /**
  71307. * Clears all the steps from the stage.
  71308. */
  71309. clear(): void;
  71310. }
  71311. }
  71312. declare module BABYLON {
  71313. interface Scene {
  71314. /** @hidden */
  71315. _pointerOverSprite: Nullable<Sprite>;
  71316. /** @hidden */
  71317. _pickedDownSprite: Nullable<Sprite>;
  71318. /** @hidden */
  71319. _tempSpritePickingRay: Nullable<Ray>;
  71320. /**
  71321. * All of the sprite managers added to this scene
  71322. * @see http://doc.babylonjs.com/babylon101/sprites
  71323. */
  71324. spriteManagers: Array<ISpriteManager>;
  71325. /**
  71326. * An event triggered when sprites rendering is about to start
  71327. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71328. */
  71329. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71330. /**
  71331. * An event triggered when sprites rendering is done
  71332. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71333. */
  71334. onAfterSpritesRenderingObservable: Observable<Scene>;
  71335. /** @hidden */
  71336. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71337. /** Launch a ray to try to pick a sprite in the scene
  71338. * @param x position on screen
  71339. * @param y position on screen
  71340. * @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
  71341. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71342. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71343. * @returns a PickingInfo
  71344. */
  71345. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71346. /** Use the given ray to pick a sprite in the scene
  71347. * @param ray The ray (in world space) to use to pick meshes
  71348. * @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
  71349. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71350. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71351. * @returns a PickingInfo
  71352. */
  71353. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71354. /**
  71355. * Force the sprite under the pointer
  71356. * @param sprite defines the sprite to use
  71357. */
  71358. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71359. /**
  71360. * Gets the sprite under the pointer
  71361. * @returns a Sprite or null if no sprite is under the pointer
  71362. */
  71363. getPointerOverSprite(): Nullable<Sprite>;
  71364. }
  71365. /**
  71366. * Defines the sprite scene component responsible to manage sprites
  71367. * in a given scene.
  71368. */
  71369. export class SpriteSceneComponent implements ISceneComponent {
  71370. /**
  71371. * The component name helpfull to identify the component in the list of scene components.
  71372. */
  71373. readonly name: string;
  71374. /**
  71375. * The scene the component belongs to.
  71376. */
  71377. scene: Scene;
  71378. /** @hidden */
  71379. private _spritePredicate;
  71380. /**
  71381. * Creates a new instance of the component for the given scene
  71382. * @param scene Defines the scene to register the component in
  71383. */
  71384. constructor(scene: Scene);
  71385. /**
  71386. * Registers the component in a given scene
  71387. */
  71388. register(): void;
  71389. /**
  71390. * Rebuilds the elements related to this component in case of
  71391. * context lost for instance.
  71392. */
  71393. rebuild(): void;
  71394. /**
  71395. * Disposes the component and the associated ressources.
  71396. */
  71397. dispose(): void;
  71398. private _pickSpriteButKeepRay;
  71399. private _pointerMove;
  71400. private _pointerDown;
  71401. private _pointerUp;
  71402. }
  71403. }
  71404. declare module BABYLON {
  71405. /** @hidden */
  71406. export var fogFragmentDeclaration: {
  71407. name: string;
  71408. shader: string;
  71409. };
  71410. }
  71411. declare module BABYLON {
  71412. /** @hidden */
  71413. export var fogFragment: {
  71414. name: string;
  71415. shader: string;
  71416. };
  71417. }
  71418. declare module BABYLON {
  71419. /** @hidden */
  71420. export var spritesPixelShader: {
  71421. name: string;
  71422. shader: string;
  71423. };
  71424. }
  71425. declare module BABYLON {
  71426. /** @hidden */
  71427. export var fogVertexDeclaration: {
  71428. name: string;
  71429. shader: string;
  71430. };
  71431. }
  71432. declare module BABYLON {
  71433. /** @hidden */
  71434. export var spritesVertexShader: {
  71435. name: string;
  71436. shader: string;
  71437. };
  71438. }
  71439. declare module BABYLON {
  71440. /**
  71441. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71442. */
  71443. export interface ISpriteManager extends IDisposable {
  71444. /**
  71445. * Restricts the camera to viewing objects with the same layerMask.
  71446. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71447. */
  71448. layerMask: number;
  71449. /**
  71450. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71451. */
  71452. isPickable: boolean;
  71453. /**
  71454. * Specifies the rendering group id for this mesh (0 by default)
  71455. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71456. */
  71457. renderingGroupId: number;
  71458. /**
  71459. * Defines the list of sprites managed by the manager.
  71460. */
  71461. sprites: Array<Sprite>;
  71462. /**
  71463. * Tests the intersection of a sprite with a specific ray.
  71464. * @param ray The ray we are sending to test the collision
  71465. * @param camera The camera space we are sending rays in
  71466. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71467. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71468. * @returns picking info or null.
  71469. */
  71470. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71471. /**
  71472. * Renders the list of sprites on screen.
  71473. */
  71474. render(): void;
  71475. }
  71476. /**
  71477. * Class used to manage multiple sprites on the same spritesheet
  71478. * @see http://doc.babylonjs.com/babylon101/sprites
  71479. */
  71480. export class SpriteManager implements ISpriteManager {
  71481. /** defines the manager's name */
  71482. name: string;
  71483. /** Gets the list of sprites */
  71484. sprites: Sprite[];
  71485. /** Gets or sets the rendering group id (0 by default) */
  71486. renderingGroupId: number;
  71487. /** Gets or sets camera layer mask */
  71488. layerMask: number;
  71489. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71490. fogEnabled: boolean;
  71491. /** Gets or sets a boolean indicating if the sprites are pickable */
  71492. isPickable: boolean;
  71493. /** Defines the default width of a cell in the spritesheet */
  71494. cellWidth: number;
  71495. /** Defines the default height of a cell in the spritesheet */
  71496. cellHeight: number;
  71497. /**
  71498. * An event triggered when the manager is disposed.
  71499. */
  71500. onDisposeObservable: Observable<SpriteManager>;
  71501. private _onDisposeObserver;
  71502. /**
  71503. * Callback called when the manager is disposed
  71504. */
  71505. onDispose: () => void;
  71506. private _capacity;
  71507. private _spriteTexture;
  71508. private _epsilon;
  71509. private _scene;
  71510. private _vertexData;
  71511. private _buffer;
  71512. private _vertexBuffers;
  71513. private _indexBuffer;
  71514. private _effectBase;
  71515. private _effectFog;
  71516. /**
  71517. * Gets or sets the spritesheet texture
  71518. */
  71519. texture: Texture;
  71520. /**
  71521. * Creates a new sprite manager
  71522. * @param name defines the manager's name
  71523. * @param imgUrl defines the sprite sheet url
  71524. * @param capacity defines the maximum allowed number of sprites
  71525. * @param cellSize defines the size of a sprite cell
  71526. * @param scene defines the hosting scene
  71527. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71528. * @param samplingMode defines the smapling mode to use with spritesheet
  71529. */
  71530. constructor(
  71531. /** defines the manager's name */
  71532. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71533. private _appendSpriteVertex;
  71534. /**
  71535. * Intersects the sprites with a ray
  71536. * @param ray defines the ray to intersect with
  71537. * @param camera defines the current active camera
  71538. * @param predicate defines a predicate used to select candidate sprites
  71539. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71540. * @returns null if no hit or a PickingInfo
  71541. */
  71542. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71543. /**
  71544. * Render all child sprites
  71545. */
  71546. render(): void;
  71547. /**
  71548. * Release associated resources
  71549. */
  71550. dispose(): void;
  71551. }
  71552. }
  71553. declare module BABYLON {
  71554. /**
  71555. * Class used to represent a sprite
  71556. * @see http://doc.babylonjs.com/babylon101/sprites
  71557. */
  71558. export class Sprite {
  71559. /** defines the name */
  71560. name: string;
  71561. /** Gets or sets the current world position */
  71562. position: Vector3;
  71563. /** Gets or sets the main color */
  71564. color: Color4;
  71565. /** Gets or sets the width */
  71566. width: number;
  71567. /** Gets or sets the height */
  71568. height: number;
  71569. /** Gets or sets rotation angle */
  71570. angle: number;
  71571. /** Gets or sets the cell index in the sprite sheet */
  71572. cellIndex: number;
  71573. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71574. invertU: number;
  71575. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71576. invertV: number;
  71577. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71578. disposeWhenFinishedAnimating: boolean;
  71579. /** Gets the list of attached animations */
  71580. animations: Animation[];
  71581. /** Gets or sets a boolean indicating if the sprite can be picked */
  71582. isPickable: boolean;
  71583. /**
  71584. * Gets or sets the associated action manager
  71585. */
  71586. actionManager: Nullable<ActionManager>;
  71587. private _animationStarted;
  71588. private _loopAnimation;
  71589. private _fromIndex;
  71590. private _toIndex;
  71591. private _delay;
  71592. private _direction;
  71593. private _manager;
  71594. private _time;
  71595. private _onAnimationEnd;
  71596. /**
  71597. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71598. */
  71599. isVisible: boolean;
  71600. /**
  71601. * Gets or sets the sprite size
  71602. */
  71603. size: number;
  71604. /**
  71605. * Creates a new Sprite
  71606. * @param name defines the name
  71607. * @param manager defines the manager
  71608. */
  71609. constructor(
  71610. /** defines the name */
  71611. name: string, manager: ISpriteManager);
  71612. /**
  71613. * Starts an animation
  71614. * @param from defines the initial key
  71615. * @param to defines the end key
  71616. * @param loop defines if the animation must loop
  71617. * @param delay defines the start delay (in ms)
  71618. * @param onAnimationEnd defines a callback to call when animation ends
  71619. */
  71620. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71621. /** Stops current animation (if any) */
  71622. stopAnimation(): void;
  71623. /** @hidden */
  71624. _animate(deltaTime: number): void;
  71625. /** Release associated resources */
  71626. dispose(): void;
  71627. }
  71628. }
  71629. declare module BABYLON {
  71630. /**
  71631. * Information about the result of picking within a scene
  71632. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71633. */
  71634. export class PickingInfo {
  71635. /** @hidden */
  71636. _pickingUnavailable: boolean;
  71637. /**
  71638. * If the pick collided with an object
  71639. */
  71640. hit: boolean;
  71641. /**
  71642. * Distance away where the pick collided
  71643. */
  71644. distance: number;
  71645. /**
  71646. * The location of pick collision
  71647. */
  71648. pickedPoint: Nullable<Vector3>;
  71649. /**
  71650. * The mesh corresponding the the pick collision
  71651. */
  71652. pickedMesh: Nullable<AbstractMesh>;
  71653. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71654. bu: number;
  71655. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71656. bv: number;
  71657. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71658. faceId: number;
  71659. /** Id of the the submesh that was picked */
  71660. subMeshId: number;
  71661. /** If a sprite was picked, this will be the sprite the pick collided with */
  71662. pickedSprite: Nullable<Sprite>;
  71663. /**
  71664. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71665. */
  71666. originMesh: Nullable<AbstractMesh>;
  71667. /**
  71668. * The ray that was used to perform the picking.
  71669. */
  71670. ray: Nullable<Ray>;
  71671. /**
  71672. * Gets the normal correspodning to the face the pick collided with
  71673. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71674. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71675. * @returns The normal correspodning to the face the pick collided with
  71676. */
  71677. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71678. /**
  71679. * Gets the texture coordinates of where the pick occured
  71680. * @returns the vector containing the coordnates of the texture
  71681. */
  71682. getTextureCoordinates(): Nullable<Vector2>;
  71683. }
  71684. }
  71685. declare module BABYLON {
  71686. /**
  71687. * Gather the list of pointer event types as constants.
  71688. */
  71689. export class PointerEventTypes {
  71690. /**
  71691. * 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.
  71692. */
  71693. static readonly POINTERDOWN: number;
  71694. /**
  71695. * The pointerup event is fired when a pointer is no longer active.
  71696. */
  71697. static readonly POINTERUP: number;
  71698. /**
  71699. * The pointermove event is fired when a pointer changes coordinates.
  71700. */
  71701. static readonly POINTERMOVE: number;
  71702. /**
  71703. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71704. */
  71705. static readonly POINTERWHEEL: number;
  71706. /**
  71707. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71708. */
  71709. static readonly POINTERPICK: number;
  71710. /**
  71711. * The pointertap event is fired when a the object has been touched and released without drag.
  71712. */
  71713. static readonly POINTERTAP: number;
  71714. /**
  71715. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71716. */
  71717. static readonly POINTERDOUBLETAP: number;
  71718. }
  71719. /**
  71720. * Base class of pointer info types.
  71721. */
  71722. export class PointerInfoBase {
  71723. /**
  71724. * Defines the type of event (PointerEventTypes)
  71725. */
  71726. type: number;
  71727. /**
  71728. * Defines the related dom event
  71729. */
  71730. event: PointerEvent | MouseWheelEvent;
  71731. /**
  71732. * Instantiates the base class of pointers info.
  71733. * @param type Defines the type of event (PointerEventTypes)
  71734. * @param event Defines the related dom event
  71735. */
  71736. constructor(
  71737. /**
  71738. * Defines the type of event (PointerEventTypes)
  71739. */
  71740. type: number,
  71741. /**
  71742. * Defines the related dom event
  71743. */
  71744. event: PointerEvent | MouseWheelEvent);
  71745. }
  71746. /**
  71747. * This class is used to store pointer related info for the onPrePointerObservable event.
  71748. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71749. */
  71750. export class PointerInfoPre extends PointerInfoBase {
  71751. /**
  71752. * Ray from a pointer if availible (eg. 6dof controller)
  71753. */
  71754. ray: Nullable<Ray>;
  71755. /**
  71756. * Defines the local position of the pointer on the canvas.
  71757. */
  71758. localPosition: Vector2;
  71759. /**
  71760. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71761. */
  71762. skipOnPointerObservable: boolean;
  71763. /**
  71764. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71765. * @param type Defines the type of event (PointerEventTypes)
  71766. * @param event Defines the related dom event
  71767. * @param localX Defines the local x coordinates of the pointer when the event occured
  71768. * @param localY Defines the local y coordinates of the pointer when the event occured
  71769. */
  71770. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71771. }
  71772. /**
  71773. * This type contains all the data related to a pointer event in Babylon.js.
  71774. * 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.
  71775. */
  71776. export class PointerInfo extends PointerInfoBase {
  71777. /**
  71778. * Defines the picking info associated to the info (if any)\
  71779. */
  71780. pickInfo: Nullable<PickingInfo>;
  71781. /**
  71782. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71783. * @param type Defines the type of event (PointerEventTypes)
  71784. * @param event Defines the related dom event
  71785. * @param pickInfo Defines the picking info associated to the info (if any)\
  71786. */
  71787. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71788. /**
  71789. * Defines the picking info associated to the info (if any)\
  71790. */
  71791. pickInfo: Nullable<PickingInfo>);
  71792. }
  71793. /**
  71794. * Data relating to a touch event on the screen.
  71795. */
  71796. export interface PointerTouch {
  71797. /**
  71798. * X coordinate of touch.
  71799. */
  71800. x: number;
  71801. /**
  71802. * Y coordinate of touch.
  71803. */
  71804. y: number;
  71805. /**
  71806. * Id of touch. Unique for each finger.
  71807. */
  71808. pointerId: number;
  71809. /**
  71810. * Event type passed from DOM.
  71811. */
  71812. type: any;
  71813. }
  71814. }
  71815. declare module BABYLON {
  71816. /**
  71817. * Manage the mouse inputs to control the movement of a free camera.
  71818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71819. */
  71820. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71821. /**
  71822. * Define if touch is enabled in the mouse input
  71823. */
  71824. touchEnabled: boolean;
  71825. /**
  71826. * Defines the camera the input is attached to.
  71827. */
  71828. camera: FreeCamera;
  71829. /**
  71830. * Defines the buttons associated with the input to handle camera move.
  71831. */
  71832. buttons: number[];
  71833. /**
  71834. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71835. */
  71836. angularSensibility: number;
  71837. private _pointerInput;
  71838. private _onMouseMove;
  71839. private _observer;
  71840. private previousPosition;
  71841. /**
  71842. * Observable for when a pointer move event occurs containing the move offset
  71843. */
  71844. onPointerMovedObservable: Observable<{
  71845. offsetX: number;
  71846. offsetY: number;
  71847. }>;
  71848. /**
  71849. * @hidden
  71850. * If the camera should be rotated automatically based on pointer movement
  71851. */
  71852. _allowCameraRotation: boolean;
  71853. /**
  71854. * Manage the mouse inputs to control the movement of a free camera.
  71855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71856. * @param touchEnabled Defines if touch is enabled or not
  71857. */
  71858. constructor(
  71859. /**
  71860. * Define if touch is enabled in the mouse input
  71861. */
  71862. touchEnabled?: boolean);
  71863. /**
  71864. * Attach the input controls to a specific dom element to get the input from.
  71865. * @param element Defines the element the controls should be listened from
  71866. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71867. */
  71868. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71869. /**
  71870. * Called on JS contextmenu event.
  71871. * Override this method to provide functionality.
  71872. */
  71873. protected onContextMenu(evt: PointerEvent): void;
  71874. /**
  71875. * Detach the current controls from the specified dom element.
  71876. * @param element Defines the element to stop listening the inputs from
  71877. */
  71878. detachControl(element: Nullable<HTMLElement>): void;
  71879. /**
  71880. * Gets the class name of the current intput.
  71881. * @returns the class name
  71882. */
  71883. getClassName(): string;
  71884. /**
  71885. * Get the friendly name associated with the input class.
  71886. * @returns the input friendly name
  71887. */
  71888. getSimpleName(): string;
  71889. }
  71890. }
  71891. declare module BABYLON {
  71892. /**
  71893. * Manage the touch inputs to control the movement of a free camera.
  71894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71895. */
  71896. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  71897. /**
  71898. * Defines the camera the input is attached to.
  71899. */
  71900. camera: FreeCamera;
  71901. /**
  71902. * Defines the touch sensibility for rotation.
  71903. * The higher the faster.
  71904. */
  71905. touchAngularSensibility: number;
  71906. /**
  71907. * Defines the touch sensibility for move.
  71908. * The higher the faster.
  71909. */
  71910. touchMoveSensibility: number;
  71911. private _offsetX;
  71912. private _offsetY;
  71913. private _pointerPressed;
  71914. private _pointerInput;
  71915. private _observer;
  71916. private _onLostFocus;
  71917. /**
  71918. * Attach the input controls to a specific dom element to get the input from.
  71919. * @param element Defines the element the controls should be listened from
  71920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71921. */
  71922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71923. /**
  71924. * Detach the current controls from the specified dom element.
  71925. * @param element Defines the element to stop listening the inputs from
  71926. */
  71927. detachControl(element: Nullable<HTMLElement>): void;
  71928. /**
  71929. * Update the current camera state depending on the inputs that have been used this frame.
  71930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71931. */
  71932. checkInputs(): void;
  71933. /**
  71934. * Gets the class name of the current intput.
  71935. * @returns the class name
  71936. */
  71937. getClassName(): string;
  71938. /**
  71939. * Get the friendly name associated with the input class.
  71940. * @returns the input friendly name
  71941. */
  71942. getSimpleName(): string;
  71943. }
  71944. }
  71945. declare module BABYLON {
  71946. /**
  71947. * Default Inputs manager for the FreeCamera.
  71948. * It groups all the default supported inputs for ease of use.
  71949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71950. */
  71951. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  71952. /**
  71953. * @hidden
  71954. */
  71955. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  71956. /**
  71957. * @hidden
  71958. */
  71959. _mouseInput: Nullable<FreeCameraMouseInput>;
  71960. /**
  71961. * Instantiates a new FreeCameraInputsManager.
  71962. * @param camera Defines the camera the inputs belong to
  71963. */
  71964. constructor(camera: FreeCamera);
  71965. /**
  71966. * Add keyboard input support to the input manager.
  71967. * @returns the current input manager
  71968. */
  71969. addKeyboard(): FreeCameraInputsManager;
  71970. /**
  71971. * Add mouse input support to the input manager.
  71972. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  71973. * @returns the current input manager
  71974. */
  71975. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  71976. /**
  71977. * Removes the mouse input support from the manager
  71978. * @returns the current input manager
  71979. */
  71980. removeMouse(): FreeCameraInputsManager;
  71981. /**
  71982. * Add touch input support to the input manager.
  71983. * @returns the current input manager
  71984. */
  71985. addTouch(): FreeCameraInputsManager;
  71986. }
  71987. }
  71988. declare module BABYLON {
  71989. /**
  71990. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71991. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  71992. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71993. */
  71994. export class FreeCamera extends TargetCamera {
  71995. /**
  71996. * Define the collision ellipsoid of the camera.
  71997. * This is helpful to simulate a camera body like the player body around the camera
  71998. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  71999. */
  72000. ellipsoid: Vector3;
  72001. /**
  72002. * Define an offset for the position of the ellipsoid around the camera.
  72003. * This can be helpful to determine the center of the body near the gravity center of the body
  72004. * instead of its head.
  72005. */
  72006. ellipsoidOffset: Vector3;
  72007. /**
  72008. * Enable or disable collisions of the camera with the rest of the scene objects.
  72009. */
  72010. checkCollisions: boolean;
  72011. /**
  72012. * Enable or disable gravity on the camera.
  72013. */
  72014. applyGravity: boolean;
  72015. /**
  72016. * Define the input manager associated to the camera.
  72017. */
  72018. inputs: FreeCameraInputsManager;
  72019. /**
  72020. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72021. * Higher values reduce sensitivity.
  72022. */
  72023. /**
  72024. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72025. * Higher values reduce sensitivity.
  72026. */
  72027. angularSensibility: number;
  72028. /**
  72029. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72030. */
  72031. keysUp: number[];
  72032. /**
  72033. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72034. */
  72035. keysDown: number[];
  72036. /**
  72037. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72038. */
  72039. keysLeft: number[];
  72040. /**
  72041. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72042. */
  72043. keysRight: number[];
  72044. /**
  72045. * Event raised when the camera collide with a mesh in the scene.
  72046. */
  72047. onCollide: (collidedMesh: AbstractMesh) => void;
  72048. private _collider;
  72049. private _needMoveForGravity;
  72050. private _oldPosition;
  72051. private _diffPosition;
  72052. private _newPosition;
  72053. /** @hidden */
  72054. _localDirection: Vector3;
  72055. /** @hidden */
  72056. _transformedDirection: Vector3;
  72057. /**
  72058. * Instantiates a Free Camera.
  72059. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72060. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72061. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72062. * @param name Define the name of the camera in the scene
  72063. * @param position Define the start position of the camera in the scene
  72064. * @param scene Define the scene the camera belongs to
  72065. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72066. */
  72067. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72068. /**
  72069. * Attached controls to the current camera.
  72070. * @param element Defines the element the controls should be listened from
  72071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72072. */
  72073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72074. /**
  72075. * Detach the current controls from the camera.
  72076. * The camera will stop reacting to inputs.
  72077. * @param element Defines the element to stop listening the inputs from
  72078. */
  72079. detachControl(element: HTMLElement): void;
  72080. private _collisionMask;
  72081. /**
  72082. * Define a collision mask to limit the list of object the camera can collide with
  72083. */
  72084. collisionMask: number;
  72085. /** @hidden */
  72086. _collideWithWorld(displacement: Vector3): void;
  72087. private _onCollisionPositionChange;
  72088. /** @hidden */
  72089. _checkInputs(): void;
  72090. /** @hidden */
  72091. _decideIfNeedsToMove(): boolean;
  72092. /** @hidden */
  72093. _updatePosition(): void;
  72094. /**
  72095. * Destroy the camera and release the current resources hold by it.
  72096. */
  72097. dispose(): void;
  72098. /**
  72099. * Gets the current object class name.
  72100. * @return the class name
  72101. */
  72102. getClassName(): string;
  72103. }
  72104. }
  72105. declare module BABYLON {
  72106. /**
  72107. * Represents a gamepad control stick position
  72108. */
  72109. export class StickValues {
  72110. /**
  72111. * The x component of the control stick
  72112. */
  72113. x: number;
  72114. /**
  72115. * The y component of the control stick
  72116. */
  72117. y: number;
  72118. /**
  72119. * Initializes the gamepad x and y control stick values
  72120. * @param x The x component of the gamepad control stick value
  72121. * @param y The y component of the gamepad control stick value
  72122. */
  72123. constructor(
  72124. /**
  72125. * The x component of the control stick
  72126. */
  72127. x: number,
  72128. /**
  72129. * The y component of the control stick
  72130. */
  72131. y: number);
  72132. }
  72133. /**
  72134. * An interface which manages callbacks for gamepad button changes
  72135. */
  72136. export interface GamepadButtonChanges {
  72137. /**
  72138. * Called when a gamepad has been changed
  72139. */
  72140. changed: boolean;
  72141. /**
  72142. * Called when a gamepad press event has been triggered
  72143. */
  72144. pressChanged: boolean;
  72145. /**
  72146. * Called when a touch event has been triggered
  72147. */
  72148. touchChanged: boolean;
  72149. /**
  72150. * Called when a value has changed
  72151. */
  72152. valueChanged: boolean;
  72153. }
  72154. /**
  72155. * Represents a gamepad
  72156. */
  72157. export class Gamepad {
  72158. /**
  72159. * The id of the gamepad
  72160. */
  72161. id: string;
  72162. /**
  72163. * The index of the gamepad
  72164. */
  72165. index: number;
  72166. /**
  72167. * The browser gamepad
  72168. */
  72169. browserGamepad: any;
  72170. /**
  72171. * Specifies what type of gamepad this represents
  72172. */
  72173. type: number;
  72174. private _leftStick;
  72175. private _rightStick;
  72176. /** @hidden */
  72177. _isConnected: boolean;
  72178. private _leftStickAxisX;
  72179. private _leftStickAxisY;
  72180. private _rightStickAxisX;
  72181. private _rightStickAxisY;
  72182. /**
  72183. * Triggered when the left control stick has been changed
  72184. */
  72185. private _onleftstickchanged;
  72186. /**
  72187. * Triggered when the right control stick has been changed
  72188. */
  72189. private _onrightstickchanged;
  72190. /**
  72191. * Represents a gamepad controller
  72192. */
  72193. static GAMEPAD: number;
  72194. /**
  72195. * Represents a generic controller
  72196. */
  72197. static GENERIC: number;
  72198. /**
  72199. * Represents an XBox controller
  72200. */
  72201. static XBOX: number;
  72202. /**
  72203. * Represents a pose-enabled controller
  72204. */
  72205. static POSE_ENABLED: number;
  72206. /**
  72207. * Specifies whether the left control stick should be Y-inverted
  72208. */
  72209. protected _invertLeftStickY: boolean;
  72210. /**
  72211. * Specifies if the gamepad has been connected
  72212. */
  72213. readonly isConnected: boolean;
  72214. /**
  72215. * Initializes the gamepad
  72216. * @param id The id of the gamepad
  72217. * @param index The index of the gamepad
  72218. * @param browserGamepad The browser gamepad
  72219. * @param leftStickX The x component of the left joystick
  72220. * @param leftStickY The y component of the left joystick
  72221. * @param rightStickX The x component of the right joystick
  72222. * @param rightStickY The y component of the right joystick
  72223. */
  72224. constructor(
  72225. /**
  72226. * The id of the gamepad
  72227. */
  72228. id: string,
  72229. /**
  72230. * The index of the gamepad
  72231. */
  72232. index: number,
  72233. /**
  72234. * The browser gamepad
  72235. */
  72236. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72237. /**
  72238. * Callback triggered when the left joystick has changed
  72239. * @param callback
  72240. */
  72241. onleftstickchanged(callback: (values: StickValues) => void): void;
  72242. /**
  72243. * Callback triggered when the right joystick has changed
  72244. * @param callback
  72245. */
  72246. onrightstickchanged(callback: (values: StickValues) => void): void;
  72247. /**
  72248. * Gets the left joystick
  72249. */
  72250. /**
  72251. * Sets the left joystick values
  72252. */
  72253. leftStick: StickValues;
  72254. /**
  72255. * Gets the right joystick
  72256. */
  72257. /**
  72258. * Sets the right joystick value
  72259. */
  72260. rightStick: StickValues;
  72261. /**
  72262. * Updates the gamepad joystick positions
  72263. */
  72264. update(): void;
  72265. /**
  72266. * Disposes the gamepad
  72267. */
  72268. dispose(): void;
  72269. }
  72270. /**
  72271. * Represents a generic gamepad
  72272. */
  72273. export class GenericPad extends Gamepad {
  72274. private _buttons;
  72275. private _onbuttondown;
  72276. private _onbuttonup;
  72277. /**
  72278. * Observable triggered when a button has been pressed
  72279. */
  72280. onButtonDownObservable: Observable<number>;
  72281. /**
  72282. * Observable triggered when a button has been released
  72283. */
  72284. onButtonUpObservable: Observable<number>;
  72285. /**
  72286. * Callback triggered when a button has been pressed
  72287. * @param callback Called when a button has been pressed
  72288. */
  72289. onbuttondown(callback: (buttonPressed: number) => void): void;
  72290. /**
  72291. * Callback triggered when a button has been released
  72292. * @param callback Called when a button has been released
  72293. */
  72294. onbuttonup(callback: (buttonReleased: number) => void): void;
  72295. /**
  72296. * Initializes the generic gamepad
  72297. * @param id The id of the generic gamepad
  72298. * @param index The index of the generic gamepad
  72299. * @param browserGamepad The browser gamepad
  72300. */
  72301. constructor(id: string, index: number, browserGamepad: any);
  72302. private _setButtonValue;
  72303. /**
  72304. * Updates the generic gamepad
  72305. */
  72306. update(): void;
  72307. /**
  72308. * Disposes the generic gamepad
  72309. */
  72310. dispose(): void;
  72311. }
  72312. }
  72313. declare module BABYLON {
  72314. /**
  72315. * Defines the types of pose enabled controllers that are supported
  72316. */
  72317. export enum PoseEnabledControllerType {
  72318. /**
  72319. * HTC Vive
  72320. */
  72321. VIVE = 0,
  72322. /**
  72323. * Oculus Rift
  72324. */
  72325. OCULUS = 1,
  72326. /**
  72327. * Windows mixed reality
  72328. */
  72329. WINDOWS = 2,
  72330. /**
  72331. * Samsung gear VR
  72332. */
  72333. GEAR_VR = 3,
  72334. /**
  72335. * Google Daydream
  72336. */
  72337. DAYDREAM = 4,
  72338. /**
  72339. * Generic
  72340. */
  72341. GENERIC = 5
  72342. }
  72343. /**
  72344. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72345. */
  72346. export interface MutableGamepadButton {
  72347. /**
  72348. * Value of the button/trigger
  72349. */
  72350. value: number;
  72351. /**
  72352. * If the button/trigger is currently touched
  72353. */
  72354. touched: boolean;
  72355. /**
  72356. * If the button/trigger is currently pressed
  72357. */
  72358. pressed: boolean;
  72359. }
  72360. /**
  72361. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72362. * @hidden
  72363. */
  72364. export interface ExtendedGamepadButton extends GamepadButton {
  72365. /**
  72366. * If the button/trigger is currently pressed
  72367. */
  72368. readonly pressed: boolean;
  72369. /**
  72370. * If the button/trigger is currently touched
  72371. */
  72372. readonly touched: boolean;
  72373. /**
  72374. * Value of the button/trigger
  72375. */
  72376. readonly value: number;
  72377. }
  72378. /** @hidden */
  72379. export interface _GamePadFactory {
  72380. /**
  72381. * Returns wether or not the current gamepad can be created for this type of controller.
  72382. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72383. * @returns true if it can be created, otherwise false
  72384. */
  72385. canCreate(gamepadInfo: any): boolean;
  72386. /**
  72387. * Creates a new instance of the Gamepad.
  72388. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72389. * @returns the new gamepad instance
  72390. */
  72391. create(gamepadInfo: any): Gamepad;
  72392. }
  72393. /**
  72394. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72395. */
  72396. export class PoseEnabledControllerHelper {
  72397. /** @hidden */
  72398. static _ControllerFactories: _GamePadFactory[];
  72399. /** @hidden */
  72400. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72401. /**
  72402. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72403. * @param vrGamepad the gamepad to initialized
  72404. * @returns a vr controller of the type the gamepad identified as
  72405. */
  72406. static InitiateController(vrGamepad: any): Gamepad;
  72407. }
  72408. /**
  72409. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72410. */
  72411. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72412. private _deviceRoomPosition;
  72413. private _deviceRoomRotationQuaternion;
  72414. /**
  72415. * The device position in babylon space
  72416. */
  72417. devicePosition: Vector3;
  72418. /**
  72419. * The device rotation in babylon space
  72420. */
  72421. deviceRotationQuaternion: Quaternion;
  72422. /**
  72423. * The scale factor of the device in babylon space
  72424. */
  72425. deviceScaleFactor: number;
  72426. /**
  72427. * (Likely devicePosition should be used instead) The device position in its room space
  72428. */
  72429. position: Vector3;
  72430. /**
  72431. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72432. */
  72433. rotationQuaternion: Quaternion;
  72434. /**
  72435. * The type of controller (Eg. Windows mixed reality)
  72436. */
  72437. controllerType: PoseEnabledControllerType;
  72438. protected _calculatedPosition: Vector3;
  72439. private _calculatedRotation;
  72440. /**
  72441. * The raw pose from the device
  72442. */
  72443. rawPose: DevicePose;
  72444. private _trackPosition;
  72445. private _maxRotationDistFromHeadset;
  72446. private _draggedRoomRotation;
  72447. /**
  72448. * @hidden
  72449. */
  72450. _disableTrackPosition(fixedPosition: Vector3): void;
  72451. /**
  72452. * Internal, the mesh attached to the controller
  72453. * @hidden
  72454. */
  72455. _mesh: Nullable<AbstractMesh>;
  72456. private _poseControlledCamera;
  72457. private _leftHandSystemQuaternion;
  72458. /**
  72459. * Internal, matrix used to convert room space to babylon space
  72460. * @hidden
  72461. */
  72462. _deviceToWorld: Matrix;
  72463. /**
  72464. * Node to be used when casting a ray from the controller
  72465. * @hidden
  72466. */
  72467. _pointingPoseNode: Nullable<TransformNode>;
  72468. /**
  72469. * Name of the child mesh that can be used to cast a ray from the controller
  72470. */
  72471. static readonly POINTING_POSE: string;
  72472. /**
  72473. * Creates a new PoseEnabledController from a gamepad
  72474. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72475. */
  72476. constructor(browserGamepad: any);
  72477. private _workingMatrix;
  72478. /**
  72479. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72480. */
  72481. update(): void;
  72482. /**
  72483. * Updates only the pose device and mesh without doing any button event checking
  72484. */
  72485. protected _updatePoseAndMesh(): void;
  72486. /**
  72487. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72488. * @param poseData raw pose fromthe device
  72489. */
  72490. updateFromDevice(poseData: DevicePose): void;
  72491. /**
  72492. * @hidden
  72493. */
  72494. _meshAttachedObservable: Observable<AbstractMesh>;
  72495. /**
  72496. * Attaches a mesh to the controller
  72497. * @param mesh the mesh to be attached
  72498. */
  72499. attachToMesh(mesh: AbstractMesh): void;
  72500. /**
  72501. * Attaches the controllers mesh to a camera
  72502. * @param camera the camera the mesh should be attached to
  72503. */
  72504. attachToPoseControlledCamera(camera: TargetCamera): void;
  72505. /**
  72506. * Disposes of the controller
  72507. */
  72508. dispose(): void;
  72509. /**
  72510. * The mesh that is attached to the controller
  72511. */
  72512. readonly mesh: Nullable<AbstractMesh>;
  72513. /**
  72514. * Gets the ray of the controller in the direction the controller is pointing
  72515. * @param length the length the resulting ray should be
  72516. * @returns a ray in the direction the controller is pointing
  72517. */
  72518. getForwardRay(length?: number): Ray;
  72519. }
  72520. }
  72521. declare module BABYLON {
  72522. /**
  72523. * Defines the WebVRController object that represents controllers tracked in 3D space
  72524. */
  72525. export abstract class WebVRController extends PoseEnabledController {
  72526. /**
  72527. * Internal, the default controller model for the controller
  72528. */
  72529. protected _defaultModel: AbstractMesh;
  72530. /**
  72531. * Fired when the trigger state has changed
  72532. */
  72533. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72534. /**
  72535. * Fired when the main button state has changed
  72536. */
  72537. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72538. /**
  72539. * Fired when the secondary button state has changed
  72540. */
  72541. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72542. /**
  72543. * Fired when the pad state has changed
  72544. */
  72545. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72546. /**
  72547. * Fired when controllers stick values have changed
  72548. */
  72549. onPadValuesChangedObservable: Observable<StickValues>;
  72550. /**
  72551. * Array of button availible on the controller
  72552. */
  72553. protected _buttons: Array<MutableGamepadButton>;
  72554. private _onButtonStateChange;
  72555. /**
  72556. * Fired when a controller button's state has changed
  72557. * @param callback the callback containing the button that was modified
  72558. */
  72559. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72560. /**
  72561. * X and Y axis corrisponding to the controllers joystick
  72562. */
  72563. pad: StickValues;
  72564. /**
  72565. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72566. */
  72567. hand: string;
  72568. /**
  72569. * The default controller model for the controller
  72570. */
  72571. readonly defaultModel: AbstractMesh;
  72572. /**
  72573. * Creates a new WebVRController from a gamepad
  72574. * @param vrGamepad the gamepad that the WebVRController should be created from
  72575. */
  72576. constructor(vrGamepad: any);
  72577. /**
  72578. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72579. */
  72580. update(): void;
  72581. /**
  72582. * Function to be called when a button is modified
  72583. */
  72584. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72585. /**
  72586. * Loads a mesh and attaches it to the controller
  72587. * @param scene the scene the mesh should be added to
  72588. * @param meshLoaded callback for when the mesh has been loaded
  72589. */
  72590. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72591. private _setButtonValue;
  72592. private _changes;
  72593. private _checkChanges;
  72594. /**
  72595. * Disposes of th webVRCOntroller
  72596. */
  72597. dispose(): void;
  72598. }
  72599. }
  72600. declare module BABYLON {
  72601. /**
  72602. * The HemisphericLight simulates the ambient environment light,
  72603. * so the passed direction is the light reflection direction, not the incoming direction.
  72604. */
  72605. export class HemisphericLight extends Light {
  72606. /**
  72607. * The groundColor is the light in the opposite direction to the one specified during creation.
  72608. * 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.
  72609. */
  72610. groundColor: Color3;
  72611. /**
  72612. * The light reflection direction, not the incoming direction.
  72613. */
  72614. direction: Vector3;
  72615. /**
  72616. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72617. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72618. * The HemisphericLight can't cast shadows.
  72619. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72620. * @param name The friendly name of the light
  72621. * @param direction The direction of the light reflection
  72622. * @param scene The scene the light belongs to
  72623. */
  72624. constructor(name: string, direction: Vector3, scene: Scene);
  72625. protected _buildUniformLayout(): void;
  72626. /**
  72627. * Returns the string "HemisphericLight".
  72628. * @return The class name
  72629. */
  72630. getClassName(): string;
  72631. /**
  72632. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72633. * Returns the updated direction.
  72634. * @param target The target the direction should point to
  72635. * @return The computed direction
  72636. */
  72637. setDirectionToTarget(target: Vector3): Vector3;
  72638. /**
  72639. * Returns the shadow generator associated to the light.
  72640. * @returns Always null for hemispheric lights because it does not support shadows.
  72641. */
  72642. getShadowGenerator(): Nullable<IShadowGenerator>;
  72643. /**
  72644. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72645. * @param effect The effect to update
  72646. * @param lightIndex The index of the light in the effect to update
  72647. * @returns The hemispheric light
  72648. */
  72649. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72650. /**
  72651. * Computes the world matrix of the node
  72652. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72653. * @param useWasUpdatedFlag defines a reserved property
  72654. * @returns the world matrix
  72655. */
  72656. computeWorldMatrix(): Matrix;
  72657. /**
  72658. * Returns the integer 3.
  72659. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72660. */
  72661. getTypeID(): number;
  72662. /**
  72663. * Prepares the list of defines specific to the light type.
  72664. * @param defines the list of defines
  72665. * @param lightIndex defines the index of the light for the effect
  72666. */
  72667. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72668. }
  72669. }
  72670. declare module BABYLON {
  72671. /** @hidden */
  72672. export var vrMultiviewToSingleviewPixelShader: {
  72673. name: string;
  72674. shader: string;
  72675. };
  72676. }
  72677. declare module BABYLON {
  72678. /**
  72679. * Renders to multiple views with a single draw call
  72680. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72681. */
  72682. export class MultiviewRenderTarget extends RenderTargetTexture {
  72683. /**
  72684. * Creates a multiview render target
  72685. * @param scene scene used with the render target
  72686. * @param size the size of the render target (used for each view)
  72687. */
  72688. constructor(scene: Scene, size?: number | {
  72689. width: number;
  72690. height: number;
  72691. } | {
  72692. ratio: number;
  72693. });
  72694. /**
  72695. * @hidden
  72696. * @param faceIndex the face index, if its a cube texture
  72697. */
  72698. _bindFrameBuffer(faceIndex?: number): void;
  72699. /**
  72700. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72701. * @returns the view count
  72702. */
  72703. getViewCount(): number;
  72704. }
  72705. }
  72706. declare module BABYLON {
  72707. interface Engine {
  72708. /**
  72709. * Creates a new multiview render target
  72710. * @param width defines the width of the texture
  72711. * @param height defines the height of the texture
  72712. * @returns the created multiview texture
  72713. */
  72714. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72715. /**
  72716. * Binds a multiview framebuffer to be drawn to
  72717. * @param multiviewTexture texture to bind
  72718. */
  72719. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72720. }
  72721. interface Camera {
  72722. /**
  72723. * @hidden
  72724. * 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)
  72725. */
  72726. _useMultiviewToSingleView: boolean;
  72727. /**
  72728. * @hidden
  72729. * 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)
  72730. */
  72731. _multiviewTexture: Nullable<RenderTargetTexture>;
  72732. /**
  72733. * @hidden
  72734. * ensures the multiview texture of the camera exists and has the specified width/height
  72735. * @param width height to set on the multiview texture
  72736. * @param height width to set on the multiview texture
  72737. */
  72738. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72739. }
  72740. interface Scene {
  72741. /** @hidden */
  72742. _transformMatrixR: Matrix;
  72743. /** @hidden */
  72744. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72745. /** @hidden */
  72746. _createMultiviewUbo(): void;
  72747. /** @hidden */
  72748. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72749. /** @hidden */
  72750. _renderMultiviewToSingleView(camera: Camera): void;
  72751. }
  72752. }
  72753. declare module BABYLON {
  72754. /**
  72755. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72756. * This will not be used for webXR as it supports displaying texture arrays directly
  72757. */
  72758. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72759. /**
  72760. * Initializes a VRMultiviewToSingleview
  72761. * @param name name of the post process
  72762. * @param camera camera to be applied to
  72763. * @param scaleFactor scaling factor to the size of the output texture
  72764. */
  72765. constructor(name: string, camera: Camera, scaleFactor: number);
  72766. }
  72767. }
  72768. declare module BABYLON {
  72769. /**
  72770. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72771. * IMPORTANT!! The data is right-hand data.
  72772. * @export
  72773. * @interface DevicePose
  72774. */
  72775. export interface DevicePose {
  72776. /**
  72777. * The position of the device, values in array are [x,y,z].
  72778. */
  72779. readonly position: Nullable<Float32Array>;
  72780. /**
  72781. * The linearVelocity of the device, values in array are [x,y,z].
  72782. */
  72783. readonly linearVelocity: Nullable<Float32Array>;
  72784. /**
  72785. * The linearAcceleration of the device, values in array are [x,y,z].
  72786. */
  72787. readonly linearAcceleration: Nullable<Float32Array>;
  72788. /**
  72789. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72790. */
  72791. readonly orientation: Nullable<Float32Array>;
  72792. /**
  72793. * The angularVelocity of the device, values in array are [x,y,z].
  72794. */
  72795. readonly angularVelocity: Nullable<Float32Array>;
  72796. /**
  72797. * The angularAcceleration of the device, values in array are [x,y,z].
  72798. */
  72799. readonly angularAcceleration: Nullable<Float32Array>;
  72800. }
  72801. /**
  72802. * Interface representing a pose controlled object in Babylon.
  72803. * A pose controlled object has both regular pose values as well as pose values
  72804. * from an external device such as a VR head mounted display
  72805. */
  72806. export interface PoseControlled {
  72807. /**
  72808. * The position of the object in babylon space.
  72809. */
  72810. position: Vector3;
  72811. /**
  72812. * The rotation quaternion of the object in babylon space.
  72813. */
  72814. rotationQuaternion: Quaternion;
  72815. /**
  72816. * The position of the device in babylon space.
  72817. */
  72818. devicePosition?: Vector3;
  72819. /**
  72820. * The rotation quaternion of the device in babylon space.
  72821. */
  72822. deviceRotationQuaternion: Quaternion;
  72823. /**
  72824. * The raw pose coming from the device.
  72825. */
  72826. rawPose: Nullable<DevicePose>;
  72827. /**
  72828. * The scale of the device to be used when translating from device space to babylon space.
  72829. */
  72830. deviceScaleFactor: number;
  72831. /**
  72832. * Updates the poseControlled values based on the input device pose.
  72833. * @param poseData the pose data to update the object with
  72834. */
  72835. updateFromDevice(poseData: DevicePose): void;
  72836. }
  72837. /**
  72838. * Set of options to customize the webVRCamera
  72839. */
  72840. export interface WebVROptions {
  72841. /**
  72842. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72843. */
  72844. trackPosition?: boolean;
  72845. /**
  72846. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72847. */
  72848. positionScale?: number;
  72849. /**
  72850. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72851. */
  72852. displayName?: string;
  72853. /**
  72854. * Should the native controller meshes be initialized. (default: true)
  72855. */
  72856. controllerMeshes?: boolean;
  72857. /**
  72858. * Creating a default HemiLight only on controllers. (default: true)
  72859. */
  72860. defaultLightingOnControllers?: boolean;
  72861. /**
  72862. * If you don't want to use the default VR button of the helper. (default: false)
  72863. */
  72864. useCustomVRButton?: boolean;
  72865. /**
  72866. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72867. */
  72868. customVRButton?: HTMLButtonElement;
  72869. /**
  72870. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72871. */
  72872. rayLength?: number;
  72873. /**
  72874. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72875. */
  72876. defaultHeight?: number;
  72877. /**
  72878. * If multiview should be used if availible (default: false)
  72879. */
  72880. useMultiview?: boolean;
  72881. }
  72882. /**
  72883. * This represents a WebVR camera.
  72884. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  72885. * @example http://doc.babylonjs.com/how_to/webvr_camera
  72886. */
  72887. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  72888. private webVROptions;
  72889. /**
  72890. * @hidden
  72891. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  72892. */
  72893. _vrDevice: any;
  72894. /**
  72895. * The rawPose of the vrDevice.
  72896. */
  72897. rawPose: Nullable<DevicePose>;
  72898. private _onVREnabled;
  72899. private _specsVersion;
  72900. private _attached;
  72901. private _frameData;
  72902. protected _descendants: Array<Node>;
  72903. private _deviceRoomPosition;
  72904. /** @hidden */
  72905. _deviceRoomRotationQuaternion: Quaternion;
  72906. private _standingMatrix;
  72907. /**
  72908. * Represents device position in babylon space.
  72909. */
  72910. devicePosition: Vector3;
  72911. /**
  72912. * Represents device rotation in babylon space.
  72913. */
  72914. deviceRotationQuaternion: Quaternion;
  72915. /**
  72916. * The scale of the device to be used when translating from device space to babylon space.
  72917. */
  72918. deviceScaleFactor: number;
  72919. private _deviceToWorld;
  72920. private _worldToDevice;
  72921. /**
  72922. * References to the webVR controllers for the vrDevice.
  72923. */
  72924. controllers: Array<WebVRController>;
  72925. /**
  72926. * Emits an event when a controller is attached.
  72927. */
  72928. onControllersAttachedObservable: Observable<WebVRController[]>;
  72929. /**
  72930. * Emits an event when a controller's mesh has been loaded;
  72931. */
  72932. onControllerMeshLoadedObservable: Observable<WebVRController>;
  72933. /**
  72934. * Emits an event when the HMD's pose has been updated.
  72935. */
  72936. onPoseUpdatedFromDeviceObservable: Observable<any>;
  72937. private _poseSet;
  72938. /**
  72939. * If the rig cameras be used as parent instead of this camera.
  72940. */
  72941. rigParenting: boolean;
  72942. private _lightOnControllers;
  72943. private _defaultHeight?;
  72944. /**
  72945. * Instantiates a WebVRFreeCamera.
  72946. * @param name The name of the WebVRFreeCamera
  72947. * @param position The starting anchor position for the camera
  72948. * @param scene The scene the camera belongs to
  72949. * @param webVROptions a set of customizable options for the webVRCamera
  72950. */
  72951. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  72952. /**
  72953. * Gets the device distance from the ground in meters.
  72954. * @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.
  72955. */
  72956. deviceDistanceToRoomGround(): number;
  72957. /**
  72958. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72959. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  72960. */
  72961. useStandingMatrix(callback?: (bool: boolean) => void): void;
  72962. /**
  72963. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72964. * @returns A promise with a boolean set to if the standing matrix is supported.
  72965. */
  72966. useStandingMatrixAsync(): Promise<boolean>;
  72967. /**
  72968. * Disposes the camera
  72969. */
  72970. dispose(): void;
  72971. /**
  72972. * Gets a vrController by name.
  72973. * @param name The name of the controller to retreive
  72974. * @returns the controller matching the name specified or null if not found
  72975. */
  72976. getControllerByName(name: string): Nullable<WebVRController>;
  72977. private _leftController;
  72978. /**
  72979. * The controller corrisponding to the users left hand.
  72980. */
  72981. readonly leftController: Nullable<WebVRController>;
  72982. private _rightController;
  72983. /**
  72984. * The controller corrisponding to the users right hand.
  72985. */
  72986. readonly rightController: Nullable<WebVRController>;
  72987. /**
  72988. * Casts a ray forward from the vrCamera's gaze.
  72989. * @param length Length of the ray (default: 100)
  72990. * @returns the ray corrisponding to the gaze
  72991. */
  72992. getForwardRay(length?: number): Ray;
  72993. /**
  72994. * @hidden
  72995. * Updates the camera based on device's frame data
  72996. */
  72997. _checkInputs(): void;
  72998. /**
  72999. * Updates the poseControlled values based on the input device pose.
  73000. * @param poseData Pose coming from the device
  73001. */
  73002. updateFromDevice(poseData: DevicePose): void;
  73003. private _htmlElementAttached;
  73004. private _detachIfAttached;
  73005. /**
  73006. * WebVR's attach control will start broadcasting frames to the device.
  73007. * Note that in certain browsers (chrome for example) this function must be called
  73008. * within a user-interaction callback. Example:
  73009. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73010. *
  73011. * @param element html element to attach the vrDevice to
  73012. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73013. */
  73014. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73015. /**
  73016. * Detaches the camera from the html element and disables VR
  73017. *
  73018. * @param element html element to detach from
  73019. */
  73020. detachControl(element: HTMLElement): void;
  73021. /**
  73022. * @returns the name of this class
  73023. */
  73024. getClassName(): string;
  73025. /**
  73026. * Calls resetPose on the vrDisplay
  73027. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73028. */
  73029. resetToCurrentRotation(): void;
  73030. /**
  73031. * @hidden
  73032. * Updates the rig cameras (left and right eye)
  73033. */
  73034. _updateRigCameras(): void;
  73035. private _workingVector;
  73036. private _oneVector;
  73037. private _workingMatrix;
  73038. private updateCacheCalled;
  73039. private _correctPositionIfNotTrackPosition;
  73040. /**
  73041. * @hidden
  73042. * Updates the cached values of the camera
  73043. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73044. */
  73045. _updateCache(ignoreParentClass?: boolean): void;
  73046. /**
  73047. * @hidden
  73048. * Get current device position in babylon world
  73049. */
  73050. _computeDevicePosition(): void;
  73051. /**
  73052. * Updates the current device position and rotation in the babylon world
  73053. */
  73054. update(): void;
  73055. /**
  73056. * @hidden
  73057. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73058. * @returns an identity matrix
  73059. */
  73060. _getViewMatrix(): Matrix;
  73061. private _tmpMatrix;
  73062. /**
  73063. * This function is called by the two RIG cameras.
  73064. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73065. * @hidden
  73066. */
  73067. _getWebVRViewMatrix(): Matrix;
  73068. /** @hidden */
  73069. _getWebVRProjectionMatrix(): Matrix;
  73070. private _onGamepadConnectedObserver;
  73071. private _onGamepadDisconnectedObserver;
  73072. private _updateCacheWhenTrackingDisabledObserver;
  73073. /**
  73074. * Initializes the controllers and their meshes
  73075. */
  73076. initControllers(): void;
  73077. }
  73078. }
  73079. declare module BABYLON {
  73080. /**
  73081. * Size options for a post process
  73082. */
  73083. export type PostProcessOptions = {
  73084. width: number;
  73085. height: number;
  73086. };
  73087. /**
  73088. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73089. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73090. */
  73091. export class PostProcess {
  73092. /** Name of the PostProcess. */
  73093. name: string;
  73094. /**
  73095. * Gets or sets the unique id of the post process
  73096. */
  73097. uniqueId: number;
  73098. /**
  73099. * Width of the texture to apply the post process on
  73100. */
  73101. width: number;
  73102. /**
  73103. * Height of the texture to apply the post process on
  73104. */
  73105. height: number;
  73106. /**
  73107. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73108. * @hidden
  73109. */
  73110. _outputTexture: Nullable<InternalTexture>;
  73111. /**
  73112. * Sampling mode used by the shader
  73113. * See https://doc.babylonjs.com/classes/3.1/texture
  73114. */
  73115. renderTargetSamplingMode: number;
  73116. /**
  73117. * Clear color to use when screen clearing
  73118. */
  73119. clearColor: Color4;
  73120. /**
  73121. * If the buffer needs to be cleared before applying the post process. (default: true)
  73122. * Should be set to false if shader will overwrite all previous pixels.
  73123. */
  73124. autoClear: boolean;
  73125. /**
  73126. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73127. */
  73128. alphaMode: number;
  73129. /**
  73130. * Sets the setAlphaBlendConstants of the babylon engine
  73131. */
  73132. alphaConstants: Color4;
  73133. /**
  73134. * Animations to be used for the post processing
  73135. */
  73136. animations: Animation[];
  73137. /**
  73138. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73139. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73140. */
  73141. enablePixelPerfectMode: boolean;
  73142. /**
  73143. * Force the postprocess to be applied without taking in account viewport
  73144. */
  73145. forceFullscreenViewport: boolean;
  73146. /**
  73147. * List of inspectable custom properties (used by the Inspector)
  73148. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73149. */
  73150. inspectableCustomProperties: IInspectable[];
  73151. /**
  73152. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73153. *
  73154. * | Value | Type | Description |
  73155. * | ----- | ----------------------------------- | ----------- |
  73156. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73157. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73158. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73159. *
  73160. */
  73161. scaleMode: number;
  73162. /**
  73163. * Force textures to be a power of two (default: false)
  73164. */
  73165. alwaysForcePOT: boolean;
  73166. private _samples;
  73167. /**
  73168. * Number of sample textures (default: 1)
  73169. */
  73170. samples: number;
  73171. /**
  73172. * Modify the scale of the post process to be the same as the viewport (default: false)
  73173. */
  73174. adaptScaleToCurrentViewport: boolean;
  73175. private _camera;
  73176. private _scene;
  73177. private _engine;
  73178. private _options;
  73179. private _reusable;
  73180. private _textureType;
  73181. /**
  73182. * Smart array of input and output textures for the post process.
  73183. * @hidden
  73184. */
  73185. _textures: SmartArray<InternalTexture>;
  73186. /**
  73187. * The index in _textures that corresponds to the output texture.
  73188. * @hidden
  73189. */
  73190. _currentRenderTextureInd: number;
  73191. private _effect;
  73192. private _samplers;
  73193. private _fragmentUrl;
  73194. private _vertexUrl;
  73195. private _parameters;
  73196. private _scaleRatio;
  73197. protected _indexParameters: any;
  73198. private _shareOutputWithPostProcess;
  73199. private _texelSize;
  73200. private _forcedOutputTexture;
  73201. /**
  73202. * Returns the fragment url or shader name used in the post process.
  73203. * @returns the fragment url or name in the shader store.
  73204. */
  73205. getEffectName(): string;
  73206. /**
  73207. * An event triggered when the postprocess is activated.
  73208. */
  73209. onActivateObservable: Observable<Camera>;
  73210. private _onActivateObserver;
  73211. /**
  73212. * A function that is added to the onActivateObservable
  73213. */
  73214. onActivate: Nullable<(camera: Camera) => void>;
  73215. /**
  73216. * An event triggered when the postprocess changes its size.
  73217. */
  73218. onSizeChangedObservable: Observable<PostProcess>;
  73219. private _onSizeChangedObserver;
  73220. /**
  73221. * A function that is added to the onSizeChangedObservable
  73222. */
  73223. onSizeChanged: (postProcess: PostProcess) => void;
  73224. /**
  73225. * An event triggered when the postprocess applies its effect.
  73226. */
  73227. onApplyObservable: Observable<Effect>;
  73228. private _onApplyObserver;
  73229. /**
  73230. * A function that is added to the onApplyObservable
  73231. */
  73232. onApply: (effect: Effect) => void;
  73233. /**
  73234. * An event triggered before rendering the postprocess
  73235. */
  73236. onBeforeRenderObservable: Observable<Effect>;
  73237. private _onBeforeRenderObserver;
  73238. /**
  73239. * A function that is added to the onBeforeRenderObservable
  73240. */
  73241. onBeforeRender: (effect: Effect) => void;
  73242. /**
  73243. * An event triggered after rendering the postprocess
  73244. */
  73245. onAfterRenderObservable: Observable<Effect>;
  73246. private _onAfterRenderObserver;
  73247. /**
  73248. * A function that is added to the onAfterRenderObservable
  73249. */
  73250. onAfterRender: (efect: Effect) => void;
  73251. /**
  73252. * 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
  73253. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73254. */
  73255. inputTexture: InternalTexture;
  73256. /**
  73257. * Gets the camera which post process is applied to.
  73258. * @returns The camera the post process is applied to.
  73259. */
  73260. getCamera(): Camera;
  73261. /**
  73262. * Gets the texel size of the postprocess.
  73263. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73264. */
  73265. readonly texelSize: Vector2;
  73266. /**
  73267. * Creates a new instance PostProcess
  73268. * @param name The name of the PostProcess.
  73269. * @param fragmentUrl The url of the fragment shader to be used.
  73270. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73271. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73272. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73273. * @param camera The camera to apply the render pass to.
  73274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73275. * @param engine The engine which the post process will be applied. (default: current engine)
  73276. * @param reusable If the post process can be reused on the same frame. (default: false)
  73277. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73278. * @param textureType Type of textures used when performing the post process. (default: 0)
  73279. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73280. * @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
  73281. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73282. */
  73283. constructor(
  73284. /** Name of the PostProcess. */
  73285. 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);
  73286. /**
  73287. * Gets a string idenfifying the name of the class
  73288. * @returns "PostProcess" string
  73289. */
  73290. getClassName(): string;
  73291. /**
  73292. * Gets the engine which this post process belongs to.
  73293. * @returns The engine the post process was enabled with.
  73294. */
  73295. getEngine(): Engine;
  73296. /**
  73297. * The effect that is created when initializing the post process.
  73298. * @returns The created effect corrisponding the the postprocess.
  73299. */
  73300. getEffect(): Effect;
  73301. /**
  73302. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73303. * @param postProcess The post process to share the output with.
  73304. * @returns This post process.
  73305. */
  73306. shareOutputWith(postProcess: PostProcess): PostProcess;
  73307. /**
  73308. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73309. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73310. */
  73311. useOwnOutput(): void;
  73312. /**
  73313. * Updates the effect with the current post process compile time values and recompiles the shader.
  73314. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73315. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73316. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73317. * @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
  73318. * @param onCompiled Called when the shader has been compiled.
  73319. * @param onError Called if there is an error when compiling a shader.
  73320. */
  73321. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73322. /**
  73323. * The post process is reusable if it can be used multiple times within one frame.
  73324. * @returns If the post process is reusable
  73325. */
  73326. isReusable(): boolean;
  73327. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73328. markTextureDirty(): void;
  73329. /**
  73330. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73331. * 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.
  73332. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73333. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73334. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73335. * @returns The target texture that was bound to be written to.
  73336. */
  73337. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73338. /**
  73339. * If the post process is supported.
  73340. */
  73341. readonly isSupported: boolean;
  73342. /**
  73343. * The aspect ratio of the output texture.
  73344. */
  73345. readonly aspectRatio: number;
  73346. /**
  73347. * Get a value indicating if the post-process is ready to be used
  73348. * @returns true if the post-process is ready (shader is compiled)
  73349. */
  73350. isReady(): boolean;
  73351. /**
  73352. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73353. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73354. */
  73355. apply(): Nullable<Effect>;
  73356. private _disposeTextures;
  73357. /**
  73358. * Disposes the post process.
  73359. * @param camera The camera to dispose the post process on.
  73360. */
  73361. dispose(camera?: Camera): void;
  73362. }
  73363. }
  73364. declare module BABYLON {
  73365. /**
  73366. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73367. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73368. */
  73369. export class PostProcessManager {
  73370. private _scene;
  73371. private _indexBuffer;
  73372. private _vertexBuffers;
  73373. /**
  73374. * Creates a new instance PostProcess
  73375. * @param scene The scene that the post process is associated with.
  73376. */
  73377. constructor(scene: Scene);
  73378. private _prepareBuffers;
  73379. private _buildIndexBuffer;
  73380. /**
  73381. * Rebuilds the vertex buffers of the manager.
  73382. * @hidden
  73383. */
  73384. _rebuild(): void;
  73385. /**
  73386. * Prepares a frame to be run through a post process.
  73387. * @param sourceTexture The input texture to the post procesess. (default: null)
  73388. * @param postProcesses An array of post processes to be run. (default: null)
  73389. * @returns True if the post processes were able to be run.
  73390. * @hidden
  73391. */
  73392. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73393. /**
  73394. * Manually render a set of post processes to a texture.
  73395. * @param postProcesses An array of post processes to be run.
  73396. * @param targetTexture The target texture to render to.
  73397. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73398. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73399. * @param lodLevel defines which lod of the texture to render to
  73400. */
  73401. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73402. /**
  73403. * Finalize the result of the output of the postprocesses.
  73404. * @param doNotPresent If true the result will not be displayed to the screen.
  73405. * @param targetTexture The target texture to render to.
  73406. * @param faceIndex The index of the face to bind the target texture to.
  73407. * @param postProcesses The array of post processes to render.
  73408. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73409. * @hidden
  73410. */
  73411. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73412. /**
  73413. * Disposes of the post process manager.
  73414. */
  73415. dispose(): void;
  73416. }
  73417. }
  73418. declare module BABYLON {
  73419. interface AbstractScene {
  73420. /**
  73421. * The list of layers (background and foreground) of the scene
  73422. */
  73423. layers: Array<Layer>;
  73424. }
  73425. /**
  73426. * Defines the layer scene component responsible to manage any layers
  73427. * in a given scene.
  73428. */
  73429. export class LayerSceneComponent implements ISceneComponent {
  73430. /**
  73431. * The component name helpfull to identify the component in the list of scene components.
  73432. */
  73433. readonly name: string;
  73434. /**
  73435. * The scene the component belongs to.
  73436. */
  73437. scene: Scene;
  73438. private _engine;
  73439. /**
  73440. * Creates a new instance of the component for the given scene
  73441. * @param scene Defines the scene to register the component in
  73442. */
  73443. constructor(scene: Scene);
  73444. /**
  73445. * Registers the component in a given scene
  73446. */
  73447. register(): void;
  73448. /**
  73449. * Rebuilds the elements related to this component in case of
  73450. * context lost for instance.
  73451. */
  73452. rebuild(): void;
  73453. /**
  73454. * Disposes the component and the associated ressources.
  73455. */
  73456. dispose(): void;
  73457. private _draw;
  73458. private _drawCameraPredicate;
  73459. private _drawCameraBackground;
  73460. private _drawCameraForeground;
  73461. private _drawRenderTargetPredicate;
  73462. private _drawRenderTargetBackground;
  73463. private _drawRenderTargetForeground;
  73464. }
  73465. }
  73466. declare module BABYLON {
  73467. /** @hidden */
  73468. export var layerPixelShader: {
  73469. name: string;
  73470. shader: string;
  73471. };
  73472. }
  73473. declare module BABYLON {
  73474. /** @hidden */
  73475. export var layerVertexShader: {
  73476. name: string;
  73477. shader: string;
  73478. };
  73479. }
  73480. declare module BABYLON {
  73481. /**
  73482. * This represents a full screen 2d layer.
  73483. * This can be useful to display a picture in the background of your scene for instance.
  73484. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73485. */
  73486. export class Layer {
  73487. /**
  73488. * Define the name of the layer.
  73489. */
  73490. name: string;
  73491. /**
  73492. * Define the texture the layer should display.
  73493. */
  73494. texture: Nullable<Texture>;
  73495. /**
  73496. * Is the layer in background or foreground.
  73497. */
  73498. isBackground: boolean;
  73499. /**
  73500. * Define the color of the layer (instead of texture).
  73501. */
  73502. color: Color4;
  73503. /**
  73504. * Define the scale of the layer in order to zoom in out of the texture.
  73505. */
  73506. scale: Vector2;
  73507. /**
  73508. * Define an offset for the layer in order to shift the texture.
  73509. */
  73510. offset: Vector2;
  73511. /**
  73512. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73513. */
  73514. alphaBlendingMode: number;
  73515. /**
  73516. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73517. * Alpha test will not mix with the background color in case of transparency.
  73518. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73519. */
  73520. alphaTest: boolean;
  73521. /**
  73522. * Define a mask to restrict the layer to only some of the scene cameras.
  73523. */
  73524. layerMask: number;
  73525. /**
  73526. * Define the list of render target the layer is visible into.
  73527. */
  73528. renderTargetTextures: RenderTargetTexture[];
  73529. /**
  73530. * Define if the layer is only used in renderTarget or if it also
  73531. * renders in the main frame buffer of the canvas.
  73532. */
  73533. renderOnlyInRenderTargetTextures: boolean;
  73534. private _scene;
  73535. private _vertexBuffers;
  73536. private _indexBuffer;
  73537. private _effect;
  73538. private _alphaTestEffect;
  73539. /**
  73540. * An event triggered when the layer is disposed.
  73541. */
  73542. onDisposeObservable: Observable<Layer>;
  73543. private _onDisposeObserver;
  73544. /**
  73545. * Back compatibility with callback before the onDisposeObservable existed.
  73546. * The set callback will be triggered when the layer has been disposed.
  73547. */
  73548. onDispose: () => void;
  73549. /**
  73550. * An event triggered before rendering the scene
  73551. */
  73552. onBeforeRenderObservable: Observable<Layer>;
  73553. private _onBeforeRenderObserver;
  73554. /**
  73555. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73556. * The set callback will be triggered just before rendering the layer.
  73557. */
  73558. onBeforeRender: () => void;
  73559. /**
  73560. * An event triggered after rendering the scene
  73561. */
  73562. onAfterRenderObservable: Observable<Layer>;
  73563. private _onAfterRenderObserver;
  73564. /**
  73565. * Back compatibility with callback before the onAfterRenderObservable existed.
  73566. * The set callback will be triggered just after rendering the layer.
  73567. */
  73568. onAfterRender: () => void;
  73569. /**
  73570. * Instantiates a new layer.
  73571. * This represents a full screen 2d layer.
  73572. * This can be useful to display a picture in the background of your scene for instance.
  73573. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73574. * @param name Define the name of the layer in the scene
  73575. * @param imgUrl Define the url of the texture to display in the layer
  73576. * @param scene Define the scene the layer belongs to
  73577. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73578. * @param color Defines a color for the layer
  73579. */
  73580. constructor(
  73581. /**
  73582. * Define the name of the layer.
  73583. */
  73584. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73585. private _createIndexBuffer;
  73586. /** @hidden */
  73587. _rebuild(): void;
  73588. /**
  73589. * Renders the layer in the scene.
  73590. */
  73591. render(): void;
  73592. /**
  73593. * Disposes and releases the associated ressources.
  73594. */
  73595. dispose(): void;
  73596. }
  73597. }
  73598. declare module BABYLON {
  73599. interface AbstractScene {
  73600. /**
  73601. * The list of procedural textures added to the scene
  73602. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73603. */
  73604. proceduralTextures: Array<ProceduralTexture>;
  73605. }
  73606. /**
  73607. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  73608. * in a given scene.
  73609. */
  73610. export class ProceduralTextureSceneComponent implements ISceneComponent {
  73611. /**
  73612. * The component name helpfull to identify the component in the list of scene components.
  73613. */
  73614. readonly name: string;
  73615. /**
  73616. * The scene the component belongs to.
  73617. */
  73618. scene: Scene;
  73619. /**
  73620. * Creates a new instance of the component for the given scene
  73621. * @param scene Defines the scene to register the component in
  73622. */
  73623. constructor(scene: Scene);
  73624. /**
  73625. * Registers the component in a given scene
  73626. */
  73627. register(): void;
  73628. /**
  73629. * Rebuilds the elements related to this component in case of
  73630. * context lost for instance.
  73631. */
  73632. rebuild(): void;
  73633. /**
  73634. * Disposes the component and the associated ressources.
  73635. */
  73636. dispose(): void;
  73637. private _beforeClear;
  73638. }
  73639. }
  73640. declare module BABYLON {
  73641. interface Engine {
  73642. /**
  73643. * Creates a new render target cube texture
  73644. * @param size defines the size of the texture
  73645. * @param options defines the options used to create the texture
  73646. * @returns a new render target cube texture stored in an InternalTexture
  73647. */
  73648. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  73649. }
  73650. }
  73651. declare module BABYLON {
  73652. /** @hidden */
  73653. export var proceduralVertexShader: {
  73654. name: string;
  73655. shader: string;
  73656. };
  73657. }
  73658. declare module BABYLON {
  73659. /**
  73660. * 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.
  73661. * This is the base class of any Procedural texture and contains most of the shareable code.
  73662. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73663. */
  73664. export class ProceduralTexture extends Texture {
  73665. isCube: boolean;
  73666. /**
  73667. * Define if the texture is enabled or not (disabled texture will not render)
  73668. */
  73669. isEnabled: boolean;
  73670. /**
  73671. * Define if the texture must be cleared before rendering (default is true)
  73672. */
  73673. autoClear: boolean;
  73674. /**
  73675. * Callback called when the texture is generated
  73676. */
  73677. onGenerated: () => void;
  73678. /**
  73679. * Event raised when the texture is generated
  73680. */
  73681. onGeneratedObservable: Observable<ProceduralTexture>;
  73682. /** @hidden */
  73683. _generateMipMaps: boolean;
  73684. /** @hidden **/
  73685. _effect: Effect;
  73686. /** @hidden */
  73687. _textures: {
  73688. [key: string]: Texture;
  73689. };
  73690. private _size;
  73691. private _currentRefreshId;
  73692. private _refreshRate;
  73693. private _vertexBuffers;
  73694. private _indexBuffer;
  73695. private _uniforms;
  73696. private _samplers;
  73697. private _fragment;
  73698. private _floats;
  73699. private _ints;
  73700. private _floatsArrays;
  73701. private _colors3;
  73702. private _colors4;
  73703. private _vectors2;
  73704. private _vectors3;
  73705. private _matrices;
  73706. private _fallbackTexture;
  73707. private _fallbackTextureUsed;
  73708. private _engine;
  73709. private _cachedDefines;
  73710. private _contentUpdateId;
  73711. private _contentData;
  73712. /**
  73713. * Instantiates a new procedural texture.
  73714. * 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.
  73715. * This is the base class of any Procedural texture and contains most of the shareable code.
  73716. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73717. * @param name Define the name of the texture
  73718. * @param size Define the size of the texture to create
  73719. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73720. * @param scene Define the scene the texture belongs to
  73721. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73722. * @param generateMipMaps Define if the texture should creates mip maps or not
  73723. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73724. */
  73725. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73726. /**
  73727. * The effect that is created when initializing the post process.
  73728. * @returns The created effect corrisponding the the postprocess.
  73729. */
  73730. getEffect(): Effect;
  73731. /**
  73732. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73733. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73734. */
  73735. getContent(): Nullable<ArrayBufferView>;
  73736. private _createIndexBuffer;
  73737. /** @hidden */
  73738. _rebuild(): void;
  73739. /**
  73740. * Resets the texture in order to recreate its associated resources.
  73741. * This can be called in case of context loss
  73742. */
  73743. reset(): void;
  73744. protected _getDefines(): string;
  73745. /**
  73746. * Is the texture ready to be used ? (rendered at least once)
  73747. * @returns true if ready, otherwise, false.
  73748. */
  73749. isReady(): boolean;
  73750. /**
  73751. * Resets the refresh counter of the texture and start bak from scratch.
  73752. * Could be useful to regenerate the texture if it is setup to render only once.
  73753. */
  73754. resetRefreshCounter(): void;
  73755. /**
  73756. * Set the fragment shader to use in order to render the texture.
  73757. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73758. */
  73759. setFragment(fragment: any): void;
  73760. /**
  73761. * Define the refresh rate of the texture or the rendering frequency.
  73762. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73763. */
  73764. refreshRate: number;
  73765. /** @hidden */
  73766. _shouldRender(): boolean;
  73767. /**
  73768. * Get the size the texture is rendering at.
  73769. * @returns the size (texture is always squared)
  73770. */
  73771. getRenderSize(): number;
  73772. /**
  73773. * Resize the texture to new value.
  73774. * @param size Define the new size the texture should have
  73775. * @param generateMipMaps Define whether the new texture should create mip maps
  73776. */
  73777. resize(size: number, generateMipMaps: boolean): void;
  73778. private _checkUniform;
  73779. /**
  73780. * Set a texture in the shader program used to render.
  73781. * @param name Define the name of the uniform samplers as defined in the shader
  73782. * @param texture Define the texture to bind to this sampler
  73783. * @return the texture itself allowing "fluent" like uniform updates
  73784. */
  73785. setTexture(name: string, texture: Texture): ProceduralTexture;
  73786. /**
  73787. * Set a float in the shader.
  73788. * @param name Define the name of the uniform as defined in the shader
  73789. * @param value Define the value to give to the uniform
  73790. * @return the texture itself allowing "fluent" like uniform updates
  73791. */
  73792. setFloat(name: string, value: number): ProceduralTexture;
  73793. /**
  73794. * Set a int in the shader.
  73795. * @param name Define the name of the uniform as defined in the shader
  73796. * @param value Define the value to give to the uniform
  73797. * @return the texture itself allowing "fluent" like uniform updates
  73798. */
  73799. setInt(name: string, value: number): ProceduralTexture;
  73800. /**
  73801. * Set an array of floats in the shader.
  73802. * @param name Define the name of the uniform as defined in the shader
  73803. * @param value Define the value to give to the uniform
  73804. * @return the texture itself allowing "fluent" like uniform updates
  73805. */
  73806. setFloats(name: string, value: number[]): ProceduralTexture;
  73807. /**
  73808. * Set a vec3 in the shader from a Color3.
  73809. * @param name Define the name of the uniform as defined in the shader
  73810. * @param value Define the value to give to the uniform
  73811. * @return the texture itself allowing "fluent" like uniform updates
  73812. */
  73813. setColor3(name: string, value: Color3): ProceduralTexture;
  73814. /**
  73815. * Set a vec4 in the shader from a Color4.
  73816. * @param name Define the name of the uniform as defined in the shader
  73817. * @param value Define the value to give to the uniform
  73818. * @return the texture itself allowing "fluent" like uniform updates
  73819. */
  73820. setColor4(name: string, value: Color4): ProceduralTexture;
  73821. /**
  73822. * Set a vec2 in the shader from a Vector2.
  73823. * @param name Define the name of the uniform as defined in the shader
  73824. * @param value Define the value to give to the uniform
  73825. * @return the texture itself allowing "fluent" like uniform updates
  73826. */
  73827. setVector2(name: string, value: Vector2): ProceduralTexture;
  73828. /**
  73829. * Set a vec3 in the shader from a Vector3.
  73830. * @param name Define the name of the uniform as defined in the shader
  73831. * @param value Define the value to give to the uniform
  73832. * @return the texture itself allowing "fluent" like uniform updates
  73833. */
  73834. setVector3(name: string, value: Vector3): ProceduralTexture;
  73835. /**
  73836. * Set a mat4 in the shader from a MAtrix.
  73837. * @param name Define the name of the uniform as defined in the shader
  73838. * @param value Define the value to give to the uniform
  73839. * @return the texture itself allowing "fluent" like uniform updates
  73840. */
  73841. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73842. /**
  73843. * Render the texture to its associated render target.
  73844. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73845. */
  73846. render(useCameraPostProcess?: boolean): void;
  73847. /**
  73848. * Clone the texture.
  73849. * @returns the cloned texture
  73850. */
  73851. clone(): ProceduralTexture;
  73852. /**
  73853. * Dispose the texture and release its asoociated resources.
  73854. */
  73855. dispose(): void;
  73856. }
  73857. }
  73858. declare module BABYLON {
  73859. /**
  73860. * This represents the base class for particle system in Babylon.
  73861. * 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.
  73862. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73863. * @example https://doc.babylonjs.com/babylon101/particles
  73864. */
  73865. export class BaseParticleSystem {
  73866. /**
  73867. * Source color is added to the destination color without alpha affecting the result
  73868. */
  73869. static BLENDMODE_ONEONE: number;
  73870. /**
  73871. * Blend current color and particle color using particle’s alpha
  73872. */
  73873. static BLENDMODE_STANDARD: number;
  73874. /**
  73875. * Add current color and particle color multiplied by particle’s alpha
  73876. */
  73877. static BLENDMODE_ADD: number;
  73878. /**
  73879. * Multiply current color with particle color
  73880. */
  73881. static BLENDMODE_MULTIPLY: number;
  73882. /**
  73883. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  73884. */
  73885. static BLENDMODE_MULTIPLYADD: number;
  73886. /**
  73887. * List of animations used by the particle system.
  73888. */
  73889. animations: Animation[];
  73890. /**
  73891. * The id of the Particle system.
  73892. */
  73893. id: string;
  73894. /**
  73895. * The friendly name of the Particle system.
  73896. */
  73897. name: string;
  73898. /**
  73899. * The rendering group used by the Particle system to chose when to render.
  73900. */
  73901. renderingGroupId: number;
  73902. /**
  73903. * The emitter represents the Mesh or position we are attaching the particle system to.
  73904. */
  73905. emitter: Nullable<AbstractMesh | Vector3>;
  73906. /**
  73907. * The maximum number of particles to emit per frame
  73908. */
  73909. emitRate: number;
  73910. /**
  73911. * If you want to launch only a few particles at once, that can be done, as well.
  73912. */
  73913. manualEmitCount: number;
  73914. /**
  73915. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73916. */
  73917. updateSpeed: number;
  73918. /**
  73919. * The amount of time the particle system is running (depends of the overall update speed).
  73920. */
  73921. targetStopDuration: number;
  73922. /**
  73923. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73924. */
  73925. disposeOnStop: boolean;
  73926. /**
  73927. * Minimum power of emitting particles.
  73928. */
  73929. minEmitPower: number;
  73930. /**
  73931. * Maximum power of emitting particles.
  73932. */
  73933. maxEmitPower: number;
  73934. /**
  73935. * Minimum life time of emitting particles.
  73936. */
  73937. minLifeTime: number;
  73938. /**
  73939. * Maximum life time of emitting particles.
  73940. */
  73941. maxLifeTime: number;
  73942. /**
  73943. * Minimum Size of emitting particles.
  73944. */
  73945. minSize: number;
  73946. /**
  73947. * Maximum Size of emitting particles.
  73948. */
  73949. maxSize: number;
  73950. /**
  73951. * Minimum scale of emitting particles on X axis.
  73952. */
  73953. minScaleX: number;
  73954. /**
  73955. * Maximum scale of emitting particles on X axis.
  73956. */
  73957. maxScaleX: number;
  73958. /**
  73959. * Minimum scale of emitting particles on Y axis.
  73960. */
  73961. minScaleY: number;
  73962. /**
  73963. * Maximum scale of emitting particles on Y axis.
  73964. */
  73965. maxScaleY: number;
  73966. /**
  73967. * Gets or sets the minimal initial rotation in radians.
  73968. */
  73969. minInitialRotation: number;
  73970. /**
  73971. * Gets or sets the maximal initial rotation in radians.
  73972. */
  73973. maxInitialRotation: number;
  73974. /**
  73975. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73976. */
  73977. minAngularSpeed: number;
  73978. /**
  73979. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73980. */
  73981. maxAngularSpeed: number;
  73982. /**
  73983. * The texture used to render each particle. (this can be a spritesheet)
  73984. */
  73985. particleTexture: Nullable<Texture>;
  73986. /**
  73987. * The layer mask we are rendering the particles through.
  73988. */
  73989. layerMask: number;
  73990. /**
  73991. * This can help using your own shader to render the particle system.
  73992. * The according effect will be created
  73993. */
  73994. customShader: any;
  73995. /**
  73996. * By default particle system starts as soon as they are created. This prevents the
  73997. * automatic start to happen and let you decide when to start emitting particles.
  73998. */
  73999. preventAutoStart: boolean;
  74000. private _noiseTexture;
  74001. /**
  74002. * Gets or sets a texture used to add random noise to particle positions
  74003. */
  74004. noiseTexture: Nullable<ProceduralTexture>;
  74005. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74006. noiseStrength: Vector3;
  74007. /**
  74008. * Callback triggered when the particle animation is ending.
  74009. */
  74010. onAnimationEnd: Nullable<() => void>;
  74011. /**
  74012. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74013. */
  74014. blendMode: number;
  74015. /**
  74016. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74017. * to override the particles.
  74018. */
  74019. forceDepthWrite: boolean;
  74020. /** 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 */
  74021. preWarmCycles: number;
  74022. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74023. preWarmStepOffset: number;
  74024. /**
  74025. * 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)
  74026. */
  74027. spriteCellChangeSpeed: number;
  74028. /**
  74029. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74030. */
  74031. startSpriteCellID: number;
  74032. /**
  74033. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74034. */
  74035. endSpriteCellID: number;
  74036. /**
  74037. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74038. */
  74039. spriteCellWidth: number;
  74040. /**
  74041. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74042. */
  74043. spriteCellHeight: number;
  74044. /**
  74045. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74046. */
  74047. spriteRandomStartCell: boolean;
  74048. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74049. translationPivot: Vector2;
  74050. /** @hidden */
  74051. protected _isAnimationSheetEnabled: boolean;
  74052. /**
  74053. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74054. */
  74055. beginAnimationOnStart: boolean;
  74056. /**
  74057. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74058. */
  74059. beginAnimationFrom: number;
  74060. /**
  74061. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74062. */
  74063. beginAnimationTo: number;
  74064. /**
  74065. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74066. */
  74067. beginAnimationLoop: boolean;
  74068. /**
  74069. * Gets or sets a world offset applied to all particles
  74070. */
  74071. worldOffset: Vector3;
  74072. /**
  74073. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74074. */
  74075. isAnimationSheetEnabled: boolean;
  74076. /**
  74077. * Get hosting scene
  74078. * @returns the scene
  74079. */
  74080. getScene(): Scene;
  74081. /**
  74082. * You can use gravity if you want to give an orientation to your particles.
  74083. */
  74084. gravity: Vector3;
  74085. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74086. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74087. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74088. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74089. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74090. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74091. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74092. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74093. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74094. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74095. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74096. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74097. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74098. /**
  74099. * Defines the delay in milliseconds before starting the system (0 by default)
  74100. */
  74101. startDelay: number;
  74102. /**
  74103. * Gets the current list of drag gradients.
  74104. * You must use addDragGradient and removeDragGradient to udpate this list
  74105. * @returns the list of drag gradients
  74106. */
  74107. getDragGradients(): Nullable<Array<FactorGradient>>;
  74108. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74109. limitVelocityDamping: number;
  74110. /**
  74111. * Gets the current list of limit velocity gradients.
  74112. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74113. * @returns the list of limit velocity gradients
  74114. */
  74115. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74116. /**
  74117. * Gets the current list of color gradients.
  74118. * You must use addColorGradient and removeColorGradient to udpate this list
  74119. * @returns the list of color gradients
  74120. */
  74121. getColorGradients(): Nullable<Array<ColorGradient>>;
  74122. /**
  74123. * Gets the current list of size gradients.
  74124. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74125. * @returns the list of size gradients
  74126. */
  74127. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74128. /**
  74129. * Gets the current list of color remap gradients.
  74130. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74131. * @returns the list of color remap gradients
  74132. */
  74133. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74134. /**
  74135. * Gets the current list of alpha remap gradients.
  74136. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74137. * @returns the list of alpha remap gradients
  74138. */
  74139. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74140. /**
  74141. * Gets the current list of life time gradients.
  74142. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74143. * @returns the list of life time gradients
  74144. */
  74145. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74146. /**
  74147. * Gets the current list of angular speed gradients.
  74148. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74149. * @returns the list of angular speed gradients
  74150. */
  74151. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74152. /**
  74153. * Gets the current list of velocity gradients.
  74154. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74155. * @returns the list of velocity gradients
  74156. */
  74157. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74158. /**
  74159. * Gets the current list of start size gradients.
  74160. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74161. * @returns the list of start size gradients
  74162. */
  74163. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74164. /**
  74165. * Gets the current list of emit rate gradients.
  74166. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74167. * @returns the list of emit rate gradients
  74168. */
  74169. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74170. /**
  74171. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74172. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74173. */
  74174. direction1: Vector3;
  74175. /**
  74176. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74177. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74178. */
  74179. direction2: Vector3;
  74180. /**
  74181. * 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.
  74182. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74183. */
  74184. minEmitBox: Vector3;
  74185. /**
  74186. * 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.
  74187. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74188. */
  74189. maxEmitBox: Vector3;
  74190. /**
  74191. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74192. */
  74193. color1: Color4;
  74194. /**
  74195. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74196. */
  74197. color2: Color4;
  74198. /**
  74199. * Color the particle will have at the end of its lifetime
  74200. */
  74201. colorDead: Color4;
  74202. /**
  74203. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74204. */
  74205. textureMask: Color4;
  74206. /**
  74207. * The particle emitter type defines the emitter used by the particle system.
  74208. * It can be for example box, sphere, or cone...
  74209. */
  74210. particleEmitterType: IParticleEmitterType;
  74211. /** @hidden */
  74212. _isSubEmitter: boolean;
  74213. /**
  74214. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74215. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74216. */
  74217. billboardMode: number;
  74218. protected _isBillboardBased: boolean;
  74219. /**
  74220. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74221. */
  74222. isBillboardBased: boolean;
  74223. /**
  74224. * The scene the particle system belongs to.
  74225. */
  74226. protected _scene: Scene;
  74227. /**
  74228. * Local cache of defines for image processing.
  74229. */
  74230. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74231. /**
  74232. * Default configuration related to image processing available in the standard Material.
  74233. */
  74234. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74235. /**
  74236. * Gets the image processing configuration used either in this material.
  74237. */
  74238. /**
  74239. * Sets the Default image processing configuration used either in the this material.
  74240. *
  74241. * If sets to null, the scene one is in use.
  74242. */
  74243. imageProcessingConfiguration: ImageProcessingConfiguration;
  74244. /**
  74245. * Attaches a new image processing configuration to the Standard Material.
  74246. * @param configuration
  74247. */
  74248. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74249. /** @hidden */
  74250. protected _reset(): void;
  74251. /** @hidden */
  74252. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74253. /**
  74254. * Instantiates a particle system.
  74255. * 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.
  74256. * @param name The name of the particle system
  74257. */
  74258. constructor(name: string);
  74259. /**
  74260. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74261. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74262. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74263. * @returns the emitter
  74264. */
  74265. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74266. /**
  74267. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74268. * @param radius The radius of the hemisphere to emit from
  74269. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74270. * @returns the emitter
  74271. */
  74272. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74273. /**
  74274. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74275. * @param radius The radius of the sphere to emit from
  74276. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74277. * @returns the emitter
  74278. */
  74279. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74280. /**
  74281. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74282. * @param radius The radius of the sphere to emit from
  74283. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74284. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74285. * @returns the emitter
  74286. */
  74287. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74288. /**
  74289. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74290. * @param radius The radius of the emission cylinder
  74291. * @param height The height of the emission cylinder
  74292. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74293. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74294. * @returns the emitter
  74295. */
  74296. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74297. /**
  74298. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74299. * @param radius The radius of the cylinder to emit from
  74300. * @param height The height of the emission cylinder
  74301. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74302. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74303. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74304. * @returns the emitter
  74305. */
  74306. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74307. /**
  74308. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74309. * @param radius The radius of the cone to emit from
  74310. * @param angle The base angle of the cone
  74311. * @returns the emitter
  74312. */
  74313. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74314. /**
  74315. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74316. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74317. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74318. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74319. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74320. * @returns the emitter
  74321. */
  74322. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74323. }
  74324. }
  74325. declare module BABYLON {
  74326. /**
  74327. * Type of sub emitter
  74328. */
  74329. export enum SubEmitterType {
  74330. /**
  74331. * Attached to the particle over it's lifetime
  74332. */
  74333. ATTACHED = 0,
  74334. /**
  74335. * Created when the particle dies
  74336. */
  74337. END = 1
  74338. }
  74339. /**
  74340. * Sub emitter class used to emit particles from an existing particle
  74341. */
  74342. export class SubEmitter {
  74343. /**
  74344. * the particle system to be used by the sub emitter
  74345. */
  74346. particleSystem: ParticleSystem;
  74347. /**
  74348. * Type of the submitter (Default: END)
  74349. */
  74350. type: SubEmitterType;
  74351. /**
  74352. * 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)
  74353. * Note: This only is supported when using an emitter of type Mesh
  74354. */
  74355. inheritDirection: boolean;
  74356. /**
  74357. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74358. */
  74359. inheritedVelocityAmount: number;
  74360. /**
  74361. * Creates a sub emitter
  74362. * @param particleSystem the particle system to be used by the sub emitter
  74363. */
  74364. constructor(
  74365. /**
  74366. * the particle system to be used by the sub emitter
  74367. */
  74368. particleSystem: ParticleSystem);
  74369. /**
  74370. * Clones the sub emitter
  74371. * @returns the cloned sub emitter
  74372. */
  74373. clone(): SubEmitter;
  74374. /**
  74375. * Serialize current object to a JSON object
  74376. * @returns the serialized object
  74377. */
  74378. serialize(): any;
  74379. /** @hidden */
  74380. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74381. /**
  74382. * Creates a new SubEmitter from a serialized JSON version
  74383. * @param serializationObject defines the JSON object to read from
  74384. * @param scene defines the hosting scene
  74385. * @param rootUrl defines the rootUrl for data loading
  74386. * @returns a new SubEmitter
  74387. */
  74388. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74389. /** Release associated resources */
  74390. dispose(): void;
  74391. }
  74392. }
  74393. declare module BABYLON {
  74394. /** @hidden */
  74395. export var clipPlaneFragmentDeclaration: {
  74396. name: string;
  74397. shader: string;
  74398. };
  74399. }
  74400. declare module BABYLON {
  74401. /** @hidden */
  74402. export var imageProcessingDeclaration: {
  74403. name: string;
  74404. shader: string;
  74405. };
  74406. }
  74407. declare module BABYLON {
  74408. /** @hidden */
  74409. export var imageProcessingFunctions: {
  74410. name: string;
  74411. shader: string;
  74412. };
  74413. }
  74414. declare module BABYLON {
  74415. /** @hidden */
  74416. export var clipPlaneFragment: {
  74417. name: string;
  74418. shader: string;
  74419. };
  74420. }
  74421. declare module BABYLON {
  74422. /** @hidden */
  74423. export var particlesPixelShader: {
  74424. name: string;
  74425. shader: string;
  74426. };
  74427. }
  74428. declare module BABYLON {
  74429. /** @hidden */
  74430. export var clipPlaneVertexDeclaration: {
  74431. name: string;
  74432. shader: string;
  74433. };
  74434. }
  74435. declare module BABYLON {
  74436. /** @hidden */
  74437. export var clipPlaneVertex: {
  74438. name: string;
  74439. shader: string;
  74440. };
  74441. }
  74442. declare module BABYLON {
  74443. /** @hidden */
  74444. export var particlesVertexShader: {
  74445. name: string;
  74446. shader: string;
  74447. };
  74448. }
  74449. declare module BABYLON {
  74450. /**
  74451. * This represents a particle system in Babylon.
  74452. * 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.
  74453. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74454. * @example https://doc.babylonjs.com/babylon101/particles
  74455. */
  74456. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74457. /**
  74458. * Billboard mode will only apply to Y axis
  74459. */
  74460. static readonly BILLBOARDMODE_Y: number;
  74461. /**
  74462. * Billboard mode will apply to all axes
  74463. */
  74464. static readonly BILLBOARDMODE_ALL: number;
  74465. /**
  74466. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74467. */
  74468. static readonly BILLBOARDMODE_STRETCHED: number;
  74469. /**
  74470. * This function can be defined to provide custom update for active particles.
  74471. * This function will be called instead of regular update (age, position, color, etc.).
  74472. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74473. */
  74474. updateFunction: (particles: Particle[]) => void;
  74475. private _emitterWorldMatrix;
  74476. /**
  74477. * This function can be defined to specify initial direction for every new particle.
  74478. * It by default use the emitterType defined function
  74479. */
  74480. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74481. /**
  74482. * This function can be defined to specify initial position for every new particle.
  74483. * It by default use the emitterType defined function
  74484. */
  74485. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74486. /**
  74487. * @hidden
  74488. */
  74489. _inheritedVelocityOffset: Vector3;
  74490. /**
  74491. * An event triggered when the system is disposed
  74492. */
  74493. onDisposeObservable: Observable<ParticleSystem>;
  74494. private _onDisposeObserver;
  74495. /**
  74496. * Sets a callback that will be triggered when the system is disposed
  74497. */
  74498. onDispose: () => void;
  74499. private _particles;
  74500. private _epsilon;
  74501. private _capacity;
  74502. private _stockParticles;
  74503. private _newPartsExcess;
  74504. private _vertexData;
  74505. private _vertexBuffer;
  74506. private _vertexBuffers;
  74507. private _spriteBuffer;
  74508. private _indexBuffer;
  74509. private _effect;
  74510. private _customEffect;
  74511. private _cachedDefines;
  74512. private _scaledColorStep;
  74513. private _colorDiff;
  74514. private _scaledDirection;
  74515. private _scaledGravity;
  74516. private _currentRenderId;
  74517. private _alive;
  74518. private _useInstancing;
  74519. private _started;
  74520. private _stopped;
  74521. private _actualFrame;
  74522. private _scaledUpdateSpeed;
  74523. private _vertexBufferSize;
  74524. /** @hidden */
  74525. _currentEmitRateGradient: Nullable<FactorGradient>;
  74526. /** @hidden */
  74527. _currentEmitRate1: number;
  74528. /** @hidden */
  74529. _currentEmitRate2: number;
  74530. /** @hidden */
  74531. _currentStartSizeGradient: Nullable<FactorGradient>;
  74532. /** @hidden */
  74533. _currentStartSize1: number;
  74534. /** @hidden */
  74535. _currentStartSize2: number;
  74536. private readonly _rawTextureWidth;
  74537. private _rampGradientsTexture;
  74538. private _useRampGradients;
  74539. /** Gets or sets a boolean indicating that ramp gradients must be used
  74540. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74541. */
  74542. useRampGradients: boolean;
  74543. /**
  74544. * 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.
  74545. * 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: [])
  74546. */
  74547. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74548. private _subEmitters;
  74549. /**
  74550. * @hidden
  74551. * If the particle systems emitter should be disposed when the particle system is disposed
  74552. */
  74553. _disposeEmitterOnDispose: boolean;
  74554. /**
  74555. * The current active Sub-systems, this property is used by the root particle system only.
  74556. */
  74557. activeSubSystems: Array<ParticleSystem>;
  74558. private _rootParticleSystem;
  74559. /**
  74560. * Gets the current list of active particles
  74561. */
  74562. readonly particles: Particle[];
  74563. /**
  74564. * Returns the string "ParticleSystem"
  74565. * @returns a string containing the class name
  74566. */
  74567. getClassName(): string;
  74568. /**
  74569. * Instantiates a particle system.
  74570. * 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.
  74571. * @param name The name of the particle system
  74572. * @param capacity The max number of particles alive at the same time
  74573. * @param scene The scene the particle system belongs to
  74574. * @param customEffect a custom effect used to change the way particles are rendered by default
  74575. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74576. * @param epsilon Offset used to render the particles
  74577. */
  74578. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74579. private _addFactorGradient;
  74580. private _removeFactorGradient;
  74581. /**
  74582. * Adds a new life time gradient
  74583. * @param gradient defines the gradient to use (between 0 and 1)
  74584. * @param factor defines the life time factor to affect to the specified gradient
  74585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74586. * @returns the current particle system
  74587. */
  74588. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74589. /**
  74590. * Remove a specific life time gradient
  74591. * @param gradient defines the gradient to remove
  74592. * @returns the current particle system
  74593. */
  74594. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74595. /**
  74596. * Adds a new size gradient
  74597. * @param gradient defines the gradient to use (between 0 and 1)
  74598. * @param factor defines the size factor to affect to the specified gradient
  74599. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74600. * @returns the current particle system
  74601. */
  74602. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74603. /**
  74604. * Remove a specific size gradient
  74605. * @param gradient defines the gradient to remove
  74606. * @returns the current particle system
  74607. */
  74608. removeSizeGradient(gradient: number): IParticleSystem;
  74609. /**
  74610. * Adds a new color remap gradient
  74611. * @param gradient defines the gradient to use (between 0 and 1)
  74612. * @param min defines the color remap minimal range
  74613. * @param max defines the color remap maximal range
  74614. * @returns the current particle system
  74615. */
  74616. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74617. /**
  74618. * Remove a specific color remap gradient
  74619. * @param gradient defines the gradient to remove
  74620. * @returns the current particle system
  74621. */
  74622. removeColorRemapGradient(gradient: number): IParticleSystem;
  74623. /**
  74624. * Adds a new alpha remap gradient
  74625. * @param gradient defines the gradient to use (between 0 and 1)
  74626. * @param min defines the alpha remap minimal range
  74627. * @param max defines the alpha remap maximal range
  74628. * @returns the current particle system
  74629. */
  74630. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74631. /**
  74632. * Remove a specific alpha remap gradient
  74633. * @param gradient defines the gradient to remove
  74634. * @returns the current particle system
  74635. */
  74636. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  74637. /**
  74638. * Adds a new angular speed gradient
  74639. * @param gradient defines the gradient to use (between 0 and 1)
  74640. * @param factor defines the angular speed to affect to the specified gradient
  74641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74642. * @returns the current particle system
  74643. */
  74644. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74645. /**
  74646. * Remove a specific angular speed gradient
  74647. * @param gradient defines the gradient to remove
  74648. * @returns the current particle system
  74649. */
  74650. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74651. /**
  74652. * Adds a new velocity gradient
  74653. * @param gradient defines the gradient to use (between 0 and 1)
  74654. * @param factor defines the velocity to affect to the specified gradient
  74655. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74656. * @returns the current particle system
  74657. */
  74658. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74659. /**
  74660. * Remove a specific velocity gradient
  74661. * @param gradient defines the gradient to remove
  74662. * @returns the current particle system
  74663. */
  74664. removeVelocityGradient(gradient: number): IParticleSystem;
  74665. /**
  74666. * Adds a new limit velocity gradient
  74667. * @param gradient defines the gradient to use (between 0 and 1)
  74668. * @param factor defines the limit velocity value to affect to the specified gradient
  74669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74670. * @returns the current particle system
  74671. */
  74672. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74673. /**
  74674. * Remove a specific limit velocity gradient
  74675. * @param gradient defines the gradient to remove
  74676. * @returns the current particle system
  74677. */
  74678. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74679. /**
  74680. * Adds a new drag gradient
  74681. * @param gradient defines the gradient to use (between 0 and 1)
  74682. * @param factor defines the drag value to affect to the specified gradient
  74683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74684. * @returns the current particle system
  74685. */
  74686. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74687. /**
  74688. * Remove a specific drag gradient
  74689. * @param gradient defines the gradient to remove
  74690. * @returns the current particle system
  74691. */
  74692. removeDragGradient(gradient: number): IParticleSystem;
  74693. /**
  74694. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74695. * @param gradient defines the gradient to use (between 0 and 1)
  74696. * @param factor defines the emit rate value to affect to the specified gradient
  74697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74698. * @returns the current particle system
  74699. */
  74700. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74701. /**
  74702. * Remove a specific emit rate gradient
  74703. * @param gradient defines the gradient to remove
  74704. * @returns the current particle system
  74705. */
  74706. removeEmitRateGradient(gradient: number): IParticleSystem;
  74707. /**
  74708. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74709. * @param gradient defines the gradient to use (between 0 and 1)
  74710. * @param factor defines the start size value to affect to the specified gradient
  74711. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74712. * @returns the current particle system
  74713. */
  74714. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74715. /**
  74716. * Remove a specific start size gradient
  74717. * @param gradient defines the gradient to remove
  74718. * @returns the current particle system
  74719. */
  74720. removeStartSizeGradient(gradient: number): IParticleSystem;
  74721. private _createRampGradientTexture;
  74722. /**
  74723. * Gets the current list of ramp gradients.
  74724. * You must use addRampGradient and removeRampGradient to udpate this list
  74725. * @returns the list of ramp gradients
  74726. */
  74727. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74728. /**
  74729. * Adds a new ramp gradient used to remap particle colors
  74730. * @param gradient defines the gradient to use (between 0 and 1)
  74731. * @param color defines the color to affect to the specified gradient
  74732. * @returns the current particle system
  74733. */
  74734. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74735. /**
  74736. * Remove a specific ramp gradient
  74737. * @param gradient defines the gradient to remove
  74738. * @returns the current particle system
  74739. */
  74740. removeRampGradient(gradient: number): ParticleSystem;
  74741. /**
  74742. * Adds a new color gradient
  74743. * @param gradient defines the gradient to use (between 0 and 1)
  74744. * @param color1 defines the color to affect to the specified gradient
  74745. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74746. * @returns this particle system
  74747. */
  74748. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74749. /**
  74750. * Remove a specific color gradient
  74751. * @param gradient defines the gradient to remove
  74752. * @returns this particle system
  74753. */
  74754. removeColorGradient(gradient: number): IParticleSystem;
  74755. private _fetchR;
  74756. protected _reset(): void;
  74757. private _resetEffect;
  74758. private _createVertexBuffers;
  74759. private _createIndexBuffer;
  74760. /**
  74761. * Gets the maximum number of particles active at the same time.
  74762. * @returns The max number of active particles.
  74763. */
  74764. getCapacity(): number;
  74765. /**
  74766. * Gets whether there are still active particles in the system.
  74767. * @returns True if it is alive, otherwise false.
  74768. */
  74769. isAlive(): boolean;
  74770. /**
  74771. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74772. * @returns True if it has been started, otherwise false.
  74773. */
  74774. isStarted(): boolean;
  74775. private _prepareSubEmitterInternalArray;
  74776. /**
  74777. * Starts the particle system and begins to emit
  74778. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74779. */
  74780. start(delay?: number): void;
  74781. /**
  74782. * Stops the particle system.
  74783. * @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.
  74784. */
  74785. stop(stopSubEmitters?: boolean): void;
  74786. /**
  74787. * Remove all active particles
  74788. */
  74789. reset(): void;
  74790. /**
  74791. * @hidden (for internal use only)
  74792. */
  74793. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74794. /**
  74795. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74796. * Its lifetime will start back at 0.
  74797. */
  74798. recycleParticle: (particle: Particle) => void;
  74799. private _stopSubEmitters;
  74800. private _createParticle;
  74801. private _removeFromRoot;
  74802. private _emitFromParticle;
  74803. private _update;
  74804. /** @hidden */
  74805. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74806. /** @hidden */
  74807. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74808. /** @hidden */
  74809. private _getEffect;
  74810. /**
  74811. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74812. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74813. */
  74814. animate(preWarmOnly?: boolean): void;
  74815. private _appendParticleVertices;
  74816. /**
  74817. * Rebuilds the particle system.
  74818. */
  74819. rebuild(): void;
  74820. /**
  74821. * Is this system ready to be used/rendered
  74822. * @return true if the system is ready
  74823. */
  74824. isReady(): boolean;
  74825. private _render;
  74826. /**
  74827. * Renders the particle system in its current state.
  74828. * @returns the current number of particles
  74829. */
  74830. render(): number;
  74831. /**
  74832. * Disposes the particle system and free the associated resources
  74833. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74834. */
  74835. dispose(disposeTexture?: boolean): void;
  74836. /**
  74837. * Clones the particle system.
  74838. * @param name The name of the cloned object
  74839. * @param newEmitter The new emitter to use
  74840. * @returns the cloned particle system
  74841. */
  74842. clone(name: string, newEmitter: any): ParticleSystem;
  74843. /**
  74844. * Serializes the particle system to a JSON object.
  74845. * @returns the JSON object
  74846. */
  74847. serialize(): any;
  74848. /** @hidden */
  74849. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74850. /** @hidden */
  74851. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74852. /**
  74853. * Parses a JSON object to create a particle system.
  74854. * @param parsedParticleSystem The JSON object to parse
  74855. * @param scene The scene to create the particle system in
  74856. * @param rootUrl The root url to use to load external dependencies like texture
  74857. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74858. * @returns the Parsed particle system
  74859. */
  74860. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74861. }
  74862. }
  74863. declare module BABYLON {
  74864. /**
  74865. * A particle represents one of the element emitted by a particle system.
  74866. * This is mainly define by its coordinates, direction, velocity and age.
  74867. */
  74868. export class Particle {
  74869. /**
  74870. * The particle system the particle belongs to.
  74871. */
  74872. particleSystem: ParticleSystem;
  74873. private static _Count;
  74874. /**
  74875. * Unique ID of the particle
  74876. */
  74877. id: number;
  74878. /**
  74879. * The world position of the particle in the scene.
  74880. */
  74881. position: Vector3;
  74882. /**
  74883. * The world direction of the particle in the scene.
  74884. */
  74885. direction: Vector3;
  74886. /**
  74887. * The color of the particle.
  74888. */
  74889. color: Color4;
  74890. /**
  74891. * The color change of the particle per step.
  74892. */
  74893. colorStep: Color4;
  74894. /**
  74895. * Defines how long will the life of the particle be.
  74896. */
  74897. lifeTime: number;
  74898. /**
  74899. * The current age of the particle.
  74900. */
  74901. age: number;
  74902. /**
  74903. * The current size of the particle.
  74904. */
  74905. size: number;
  74906. /**
  74907. * The current scale of the particle.
  74908. */
  74909. scale: Vector2;
  74910. /**
  74911. * The current angle of the particle.
  74912. */
  74913. angle: number;
  74914. /**
  74915. * Defines how fast is the angle changing.
  74916. */
  74917. angularSpeed: number;
  74918. /**
  74919. * Defines the cell index used by the particle to be rendered from a sprite.
  74920. */
  74921. cellIndex: number;
  74922. /**
  74923. * The information required to support color remapping
  74924. */
  74925. remapData: Vector4;
  74926. /** @hidden */
  74927. _randomCellOffset?: number;
  74928. /** @hidden */
  74929. _initialDirection: Nullable<Vector3>;
  74930. /** @hidden */
  74931. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  74932. /** @hidden */
  74933. _initialStartSpriteCellID: number;
  74934. /** @hidden */
  74935. _initialEndSpriteCellID: number;
  74936. /** @hidden */
  74937. _currentColorGradient: Nullable<ColorGradient>;
  74938. /** @hidden */
  74939. _currentColor1: Color4;
  74940. /** @hidden */
  74941. _currentColor2: Color4;
  74942. /** @hidden */
  74943. _currentSizeGradient: Nullable<FactorGradient>;
  74944. /** @hidden */
  74945. _currentSize1: number;
  74946. /** @hidden */
  74947. _currentSize2: number;
  74948. /** @hidden */
  74949. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  74950. /** @hidden */
  74951. _currentAngularSpeed1: number;
  74952. /** @hidden */
  74953. _currentAngularSpeed2: number;
  74954. /** @hidden */
  74955. _currentVelocityGradient: Nullable<FactorGradient>;
  74956. /** @hidden */
  74957. _currentVelocity1: number;
  74958. /** @hidden */
  74959. _currentVelocity2: number;
  74960. /** @hidden */
  74961. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  74962. /** @hidden */
  74963. _currentLimitVelocity1: number;
  74964. /** @hidden */
  74965. _currentLimitVelocity2: number;
  74966. /** @hidden */
  74967. _currentDragGradient: Nullable<FactorGradient>;
  74968. /** @hidden */
  74969. _currentDrag1: number;
  74970. /** @hidden */
  74971. _currentDrag2: number;
  74972. /** @hidden */
  74973. _randomNoiseCoordinates1: Vector3;
  74974. /** @hidden */
  74975. _randomNoiseCoordinates2: Vector3;
  74976. /**
  74977. * Creates a new instance Particle
  74978. * @param particleSystem the particle system the particle belongs to
  74979. */
  74980. constructor(
  74981. /**
  74982. * The particle system the particle belongs to.
  74983. */
  74984. particleSystem: ParticleSystem);
  74985. private updateCellInfoFromSystem;
  74986. /**
  74987. * Defines how the sprite cell index is updated for the particle
  74988. */
  74989. updateCellIndex(): void;
  74990. /** @hidden */
  74991. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  74992. /** @hidden */
  74993. _inheritParticleInfoToSubEmitters(): void;
  74994. /** @hidden */
  74995. _reset(): void;
  74996. /**
  74997. * Copy the properties of particle to another one.
  74998. * @param other the particle to copy the information to.
  74999. */
  75000. copyTo(other: Particle): void;
  75001. }
  75002. }
  75003. declare module BABYLON {
  75004. /**
  75005. * Particle emitter represents a volume emitting particles.
  75006. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75007. */
  75008. export interface IParticleEmitterType {
  75009. /**
  75010. * Called by the particle System when the direction is computed for the created particle.
  75011. * @param worldMatrix is the world matrix of the particle system
  75012. * @param directionToUpdate is the direction vector to update with the result
  75013. * @param particle is the particle we are computed the direction for
  75014. */
  75015. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75016. /**
  75017. * Called by the particle System when the position is computed for the created particle.
  75018. * @param worldMatrix is the world matrix of the particle system
  75019. * @param positionToUpdate is the position vector to update with the result
  75020. * @param particle is the particle we are computed the position for
  75021. */
  75022. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75023. /**
  75024. * Clones the current emitter and returns a copy of it
  75025. * @returns the new emitter
  75026. */
  75027. clone(): IParticleEmitterType;
  75028. /**
  75029. * Called by the GPUParticleSystem to setup the update shader
  75030. * @param effect defines the update shader
  75031. */
  75032. applyToShader(effect: Effect): void;
  75033. /**
  75034. * Returns a string to use to update the GPU particles update shader
  75035. * @returns the effect defines string
  75036. */
  75037. getEffectDefines(): string;
  75038. /**
  75039. * Returns a string representing the class name
  75040. * @returns a string containing the class name
  75041. */
  75042. getClassName(): string;
  75043. /**
  75044. * Serializes the particle system to a JSON object.
  75045. * @returns the JSON object
  75046. */
  75047. serialize(): any;
  75048. /**
  75049. * Parse properties from a JSON object
  75050. * @param serializationObject defines the JSON object
  75051. */
  75052. parse(serializationObject: any): void;
  75053. }
  75054. }
  75055. declare module BABYLON {
  75056. /**
  75057. * Particle emitter emitting particles from the inside of a box.
  75058. * It emits the particles randomly between 2 given directions.
  75059. */
  75060. export class BoxParticleEmitter implements IParticleEmitterType {
  75061. /**
  75062. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75063. */
  75064. direction1: Vector3;
  75065. /**
  75066. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75067. */
  75068. direction2: Vector3;
  75069. /**
  75070. * 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.
  75071. */
  75072. minEmitBox: Vector3;
  75073. /**
  75074. * 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.
  75075. */
  75076. maxEmitBox: Vector3;
  75077. /**
  75078. * Creates a new instance BoxParticleEmitter
  75079. */
  75080. constructor();
  75081. /**
  75082. * Called by the particle System when the direction is computed for the created particle.
  75083. * @param worldMatrix is the world matrix of the particle system
  75084. * @param directionToUpdate is the direction vector to update with the result
  75085. * @param particle is the particle we are computed the direction for
  75086. */
  75087. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75088. /**
  75089. * Called by the particle System when the position is computed for the created particle.
  75090. * @param worldMatrix is the world matrix of the particle system
  75091. * @param positionToUpdate is the position vector to update with the result
  75092. * @param particle is the particle we are computed the position for
  75093. */
  75094. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75095. /**
  75096. * Clones the current emitter and returns a copy of it
  75097. * @returns the new emitter
  75098. */
  75099. clone(): BoxParticleEmitter;
  75100. /**
  75101. * Called by the GPUParticleSystem to setup the update shader
  75102. * @param effect defines the update shader
  75103. */
  75104. applyToShader(effect: Effect): void;
  75105. /**
  75106. * Returns a string to use to update the GPU particles update shader
  75107. * @returns a string containng the defines string
  75108. */
  75109. getEffectDefines(): string;
  75110. /**
  75111. * Returns the string "BoxParticleEmitter"
  75112. * @returns a string containing the class name
  75113. */
  75114. getClassName(): string;
  75115. /**
  75116. * Serializes the particle system to a JSON object.
  75117. * @returns the JSON object
  75118. */
  75119. serialize(): any;
  75120. /**
  75121. * Parse properties from a JSON object
  75122. * @param serializationObject defines the JSON object
  75123. */
  75124. parse(serializationObject: any): void;
  75125. }
  75126. }
  75127. declare module BABYLON {
  75128. /**
  75129. * Particle emitter emitting particles from the inside of a cone.
  75130. * It emits the particles alongside the cone volume from the base to the particle.
  75131. * The emission direction might be randomized.
  75132. */
  75133. export class ConeParticleEmitter implements IParticleEmitterType {
  75134. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75135. directionRandomizer: number;
  75136. private _radius;
  75137. private _angle;
  75138. private _height;
  75139. /**
  75140. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75141. */
  75142. radiusRange: number;
  75143. /**
  75144. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75145. */
  75146. heightRange: number;
  75147. /**
  75148. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75149. */
  75150. emitFromSpawnPointOnly: boolean;
  75151. /**
  75152. * Gets or sets the radius of the emission cone
  75153. */
  75154. radius: number;
  75155. /**
  75156. * Gets or sets the angle of the emission cone
  75157. */
  75158. angle: number;
  75159. private _buildHeight;
  75160. /**
  75161. * Creates a new instance ConeParticleEmitter
  75162. * @param radius the radius of the emission cone (1 by default)
  75163. * @param angle the cone base angle (PI by default)
  75164. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75165. */
  75166. constructor(radius?: number, angle?: number,
  75167. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75168. directionRandomizer?: number);
  75169. /**
  75170. * Called by the particle System when the direction is computed for the created particle.
  75171. * @param worldMatrix is the world matrix of the particle system
  75172. * @param directionToUpdate is the direction vector to update with the result
  75173. * @param particle is the particle we are computed the direction for
  75174. */
  75175. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75176. /**
  75177. * Called by the particle System when the position is computed for the created particle.
  75178. * @param worldMatrix is the world matrix of the particle system
  75179. * @param positionToUpdate is the position vector to update with the result
  75180. * @param particle is the particle we are computed the position for
  75181. */
  75182. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75183. /**
  75184. * Clones the current emitter and returns a copy of it
  75185. * @returns the new emitter
  75186. */
  75187. clone(): ConeParticleEmitter;
  75188. /**
  75189. * Called by the GPUParticleSystem to setup the update shader
  75190. * @param effect defines the update shader
  75191. */
  75192. applyToShader(effect: Effect): void;
  75193. /**
  75194. * Returns a string to use to update the GPU particles update shader
  75195. * @returns a string containng the defines string
  75196. */
  75197. getEffectDefines(): string;
  75198. /**
  75199. * Returns the string "ConeParticleEmitter"
  75200. * @returns a string containing the class name
  75201. */
  75202. getClassName(): string;
  75203. /**
  75204. * Serializes the particle system to a JSON object.
  75205. * @returns the JSON object
  75206. */
  75207. serialize(): any;
  75208. /**
  75209. * Parse properties from a JSON object
  75210. * @param serializationObject defines the JSON object
  75211. */
  75212. parse(serializationObject: any): void;
  75213. }
  75214. }
  75215. declare module BABYLON {
  75216. /**
  75217. * Particle emitter emitting particles from the inside of a cylinder.
  75218. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75219. */
  75220. export class CylinderParticleEmitter implements IParticleEmitterType {
  75221. /**
  75222. * The radius of the emission cylinder.
  75223. */
  75224. radius: number;
  75225. /**
  75226. * The height of the emission cylinder.
  75227. */
  75228. height: number;
  75229. /**
  75230. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75231. */
  75232. radiusRange: number;
  75233. /**
  75234. * How much to randomize the particle direction [0-1].
  75235. */
  75236. directionRandomizer: number;
  75237. /**
  75238. * Creates a new instance CylinderParticleEmitter
  75239. * @param radius the radius of the emission cylinder (1 by default)
  75240. * @param height the height of the emission cylinder (1 by default)
  75241. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75242. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75243. */
  75244. constructor(
  75245. /**
  75246. * The radius of the emission cylinder.
  75247. */
  75248. radius?: number,
  75249. /**
  75250. * The height of the emission cylinder.
  75251. */
  75252. height?: number,
  75253. /**
  75254. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75255. */
  75256. radiusRange?: number,
  75257. /**
  75258. * How much to randomize the particle direction [0-1].
  75259. */
  75260. directionRandomizer?: number);
  75261. /**
  75262. * Called by the particle System when the direction is computed for the created particle.
  75263. * @param worldMatrix is the world matrix of the particle system
  75264. * @param directionToUpdate is the direction vector to update with the result
  75265. * @param particle is the particle we are computed the direction for
  75266. */
  75267. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75268. /**
  75269. * Called by the particle System when the position is computed for the created particle.
  75270. * @param worldMatrix is the world matrix of the particle system
  75271. * @param positionToUpdate is the position vector to update with the result
  75272. * @param particle is the particle we are computed the position for
  75273. */
  75274. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75275. /**
  75276. * Clones the current emitter and returns a copy of it
  75277. * @returns the new emitter
  75278. */
  75279. clone(): CylinderParticleEmitter;
  75280. /**
  75281. * Called by the GPUParticleSystem to setup the update shader
  75282. * @param effect defines the update shader
  75283. */
  75284. applyToShader(effect: Effect): void;
  75285. /**
  75286. * Returns a string to use to update the GPU particles update shader
  75287. * @returns a string containng the defines string
  75288. */
  75289. getEffectDefines(): string;
  75290. /**
  75291. * Returns the string "CylinderParticleEmitter"
  75292. * @returns a string containing the class name
  75293. */
  75294. getClassName(): string;
  75295. /**
  75296. * Serializes the particle system to a JSON object.
  75297. * @returns the JSON object
  75298. */
  75299. serialize(): any;
  75300. /**
  75301. * Parse properties from a JSON object
  75302. * @param serializationObject defines the JSON object
  75303. */
  75304. parse(serializationObject: any): void;
  75305. }
  75306. /**
  75307. * Particle emitter emitting particles from the inside of a cylinder.
  75308. * It emits the particles randomly between two vectors.
  75309. */
  75310. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75311. /**
  75312. * The min limit of the emission direction.
  75313. */
  75314. direction1: Vector3;
  75315. /**
  75316. * The max limit of the emission direction.
  75317. */
  75318. direction2: Vector3;
  75319. /**
  75320. * Creates a new instance CylinderDirectedParticleEmitter
  75321. * @param radius the radius of the emission cylinder (1 by default)
  75322. * @param height the height of the emission cylinder (1 by default)
  75323. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75324. * @param direction1 the min limit of the emission direction (up vector by default)
  75325. * @param direction2 the max limit of the emission direction (up vector by default)
  75326. */
  75327. constructor(radius?: number, height?: number, radiusRange?: number,
  75328. /**
  75329. * The min limit of the emission direction.
  75330. */
  75331. direction1?: Vector3,
  75332. /**
  75333. * The max limit of the emission direction.
  75334. */
  75335. direction2?: Vector3);
  75336. /**
  75337. * Called by the particle System when the direction is computed for the created particle.
  75338. * @param worldMatrix is the world matrix of the particle system
  75339. * @param directionToUpdate is the direction vector to update with the result
  75340. * @param particle is the particle we are computed the direction for
  75341. */
  75342. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75343. /**
  75344. * Clones the current emitter and returns a copy of it
  75345. * @returns the new emitter
  75346. */
  75347. clone(): CylinderDirectedParticleEmitter;
  75348. /**
  75349. * Called by the GPUParticleSystem to setup the update shader
  75350. * @param effect defines the update shader
  75351. */
  75352. applyToShader(effect: Effect): void;
  75353. /**
  75354. * Returns a string to use to update the GPU particles update shader
  75355. * @returns a string containng the defines string
  75356. */
  75357. getEffectDefines(): string;
  75358. /**
  75359. * Returns the string "CylinderDirectedParticleEmitter"
  75360. * @returns a string containing the class name
  75361. */
  75362. getClassName(): string;
  75363. /**
  75364. * Serializes the particle system to a JSON object.
  75365. * @returns the JSON object
  75366. */
  75367. serialize(): any;
  75368. /**
  75369. * Parse properties from a JSON object
  75370. * @param serializationObject defines the JSON object
  75371. */
  75372. parse(serializationObject: any): void;
  75373. }
  75374. }
  75375. declare module BABYLON {
  75376. /**
  75377. * Particle emitter emitting particles from the inside of a hemisphere.
  75378. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75379. */
  75380. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75381. /**
  75382. * The radius of the emission hemisphere.
  75383. */
  75384. radius: number;
  75385. /**
  75386. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75387. */
  75388. radiusRange: number;
  75389. /**
  75390. * How much to randomize the particle direction [0-1].
  75391. */
  75392. directionRandomizer: number;
  75393. /**
  75394. * Creates a new instance HemisphericParticleEmitter
  75395. * @param radius the radius of the emission hemisphere (1 by default)
  75396. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75397. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75398. */
  75399. constructor(
  75400. /**
  75401. * The radius of the emission hemisphere.
  75402. */
  75403. radius?: number,
  75404. /**
  75405. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75406. */
  75407. radiusRange?: number,
  75408. /**
  75409. * How much to randomize the particle direction [0-1].
  75410. */
  75411. directionRandomizer?: number);
  75412. /**
  75413. * Called by the particle System when the direction is computed for the created particle.
  75414. * @param worldMatrix is the world matrix of the particle system
  75415. * @param directionToUpdate is the direction vector to update with the result
  75416. * @param particle is the particle we are computed the direction for
  75417. */
  75418. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75419. /**
  75420. * Called by the particle System when the position is computed for the created particle.
  75421. * @param worldMatrix is the world matrix of the particle system
  75422. * @param positionToUpdate is the position vector to update with the result
  75423. * @param particle is the particle we are computed the position for
  75424. */
  75425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75426. /**
  75427. * Clones the current emitter and returns a copy of it
  75428. * @returns the new emitter
  75429. */
  75430. clone(): HemisphericParticleEmitter;
  75431. /**
  75432. * Called by the GPUParticleSystem to setup the update shader
  75433. * @param effect defines the update shader
  75434. */
  75435. applyToShader(effect: Effect): void;
  75436. /**
  75437. * Returns a string to use to update the GPU particles update shader
  75438. * @returns a string containng the defines string
  75439. */
  75440. getEffectDefines(): string;
  75441. /**
  75442. * Returns the string "HemisphericParticleEmitter"
  75443. * @returns a string containing the class name
  75444. */
  75445. getClassName(): string;
  75446. /**
  75447. * Serializes the particle system to a JSON object.
  75448. * @returns the JSON object
  75449. */
  75450. serialize(): any;
  75451. /**
  75452. * Parse properties from a JSON object
  75453. * @param serializationObject defines the JSON object
  75454. */
  75455. parse(serializationObject: any): void;
  75456. }
  75457. }
  75458. declare module BABYLON {
  75459. /**
  75460. * Particle emitter emitting particles from a point.
  75461. * It emits the particles randomly between 2 given directions.
  75462. */
  75463. export class PointParticleEmitter implements IParticleEmitterType {
  75464. /**
  75465. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75466. */
  75467. direction1: Vector3;
  75468. /**
  75469. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75470. */
  75471. direction2: Vector3;
  75472. /**
  75473. * Creates a new instance PointParticleEmitter
  75474. */
  75475. constructor();
  75476. /**
  75477. * Called by the particle System when the direction is computed for the created particle.
  75478. * @param worldMatrix is the world matrix of the particle system
  75479. * @param directionToUpdate is the direction vector to update with the result
  75480. * @param particle is the particle we are computed the direction for
  75481. */
  75482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75483. /**
  75484. * Called by the particle System when the position is computed for the created particle.
  75485. * @param worldMatrix is the world matrix of the particle system
  75486. * @param positionToUpdate is the position vector to update with the result
  75487. * @param particle is the particle we are computed the position for
  75488. */
  75489. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75490. /**
  75491. * Clones the current emitter and returns a copy of it
  75492. * @returns the new emitter
  75493. */
  75494. clone(): PointParticleEmitter;
  75495. /**
  75496. * Called by the GPUParticleSystem to setup the update shader
  75497. * @param effect defines the update shader
  75498. */
  75499. applyToShader(effect: Effect): void;
  75500. /**
  75501. * Returns a string to use to update the GPU particles update shader
  75502. * @returns a string containng the defines string
  75503. */
  75504. getEffectDefines(): string;
  75505. /**
  75506. * Returns the string "PointParticleEmitter"
  75507. * @returns a string containing the class name
  75508. */
  75509. getClassName(): string;
  75510. /**
  75511. * Serializes the particle system to a JSON object.
  75512. * @returns the JSON object
  75513. */
  75514. serialize(): any;
  75515. /**
  75516. * Parse properties from a JSON object
  75517. * @param serializationObject defines the JSON object
  75518. */
  75519. parse(serializationObject: any): void;
  75520. }
  75521. }
  75522. declare module BABYLON {
  75523. /**
  75524. * Particle emitter emitting particles from the inside of a sphere.
  75525. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75526. */
  75527. export class SphereParticleEmitter implements IParticleEmitterType {
  75528. /**
  75529. * The radius of the emission sphere.
  75530. */
  75531. radius: number;
  75532. /**
  75533. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75534. */
  75535. radiusRange: number;
  75536. /**
  75537. * How much to randomize the particle direction [0-1].
  75538. */
  75539. directionRandomizer: number;
  75540. /**
  75541. * Creates a new instance SphereParticleEmitter
  75542. * @param radius the radius of the emission sphere (1 by default)
  75543. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75544. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75545. */
  75546. constructor(
  75547. /**
  75548. * The radius of the emission sphere.
  75549. */
  75550. radius?: number,
  75551. /**
  75552. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75553. */
  75554. radiusRange?: number,
  75555. /**
  75556. * How much to randomize the particle direction [0-1].
  75557. */
  75558. directionRandomizer?: number);
  75559. /**
  75560. * Called by the particle System when the direction is computed for the created particle.
  75561. * @param worldMatrix is the world matrix of the particle system
  75562. * @param directionToUpdate is the direction vector to update with the result
  75563. * @param particle is the particle we are computed the direction for
  75564. */
  75565. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75566. /**
  75567. * Called by the particle System when the position is computed for the created particle.
  75568. * @param worldMatrix is the world matrix of the particle system
  75569. * @param positionToUpdate is the position vector to update with the result
  75570. * @param particle is the particle we are computed the position for
  75571. */
  75572. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75573. /**
  75574. * Clones the current emitter and returns a copy of it
  75575. * @returns the new emitter
  75576. */
  75577. clone(): SphereParticleEmitter;
  75578. /**
  75579. * Called by the GPUParticleSystem to setup the update shader
  75580. * @param effect defines the update shader
  75581. */
  75582. applyToShader(effect: Effect): void;
  75583. /**
  75584. * Returns a string to use to update the GPU particles update shader
  75585. * @returns a string containng the defines string
  75586. */
  75587. getEffectDefines(): string;
  75588. /**
  75589. * Returns the string "SphereParticleEmitter"
  75590. * @returns a string containing the class name
  75591. */
  75592. getClassName(): string;
  75593. /**
  75594. * Serializes the particle system to a JSON object.
  75595. * @returns the JSON object
  75596. */
  75597. serialize(): any;
  75598. /**
  75599. * Parse properties from a JSON object
  75600. * @param serializationObject defines the JSON object
  75601. */
  75602. parse(serializationObject: any): void;
  75603. }
  75604. /**
  75605. * Particle emitter emitting particles from the inside of a sphere.
  75606. * It emits the particles randomly between two vectors.
  75607. */
  75608. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  75609. /**
  75610. * The min limit of the emission direction.
  75611. */
  75612. direction1: Vector3;
  75613. /**
  75614. * The max limit of the emission direction.
  75615. */
  75616. direction2: Vector3;
  75617. /**
  75618. * Creates a new instance SphereDirectedParticleEmitter
  75619. * @param radius the radius of the emission sphere (1 by default)
  75620. * @param direction1 the min limit of the emission direction (up vector by default)
  75621. * @param direction2 the max limit of the emission direction (up vector by default)
  75622. */
  75623. constructor(radius?: number,
  75624. /**
  75625. * The min limit of the emission direction.
  75626. */
  75627. direction1?: Vector3,
  75628. /**
  75629. * The max limit of the emission direction.
  75630. */
  75631. direction2?: Vector3);
  75632. /**
  75633. * Called by the particle System when the direction is computed for the created particle.
  75634. * @param worldMatrix is the world matrix of the particle system
  75635. * @param directionToUpdate is the direction vector to update with the result
  75636. * @param particle is the particle we are computed the direction for
  75637. */
  75638. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75639. /**
  75640. * Clones the current emitter and returns a copy of it
  75641. * @returns the new emitter
  75642. */
  75643. clone(): SphereDirectedParticleEmitter;
  75644. /**
  75645. * Called by the GPUParticleSystem to setup the update shader
  75646. * @param effect defines the update shader
  75647. */
  75648. applyToShader(effect: Effect): void;
  75649. /**
  75650. * Returns a string to use to update the GPU particles update shader
  75651. * @returns a string containng the defines string
  75652. */
  75653. getEffectDefines(): string;
  75654. /**
  75655. * Returns the string "SphereDirectedParticleEmitter"
  75656. * @returns a string containing the class name
  75657. */
  75658. getClassName(): string;
  75659. /**
  75660. * Serializes the particle system to a JSON object.
  75661. * @returns the JSON object
  75662. */
  75663. serialize(): any;
  75664. /**
  75665. * Parse properties from a JSON object
  75666. * @param serializationObject defines the JSON object
  75667. */
  75668. parse(serializationObject: any): void;
  75669. }
  75670. }
  75671. declare module BABYLON {
  75672. /**
  75673. * Interface representing a particle system in Babylon.js.
  75674. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75675. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75676. */
  75677. export interface IParticleSystem {
  75678. /**
  75679. * List of animations used by the particle system.
  75680. */
  75681. animations: Animation[];
  75682. /**
  75683. * The id of the Particle system.
  75684. */
  75685. id: string;
  75686. /**
  75687. * The name of the Particle system.
  75688. */
  75689. name: string;
  75690. /**
  75691. * The emitter represents the Mesh or position we are attaching the particle system to.
  75692. */
  75693. emitter: Nullable<AbstractMesh | Vector3>;
  75694. /**
  75695. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75696. */
  75697. isBillboardBased: boolean;
  75698. /**
  75699. * The rendering group used by the Particle system to chose when to render.
  75700. */
  75701. renderingGroupId: number;
  75702. /**
  75703. * The layer mask we are rendering the particles through.
  75704. */
  75705. layerMask: number;
  75706. /**
  75707. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75708. */
  75709. updateSpeed: number;
  75710. /**
  75711. * The amount of time the particle system is running (depends of the overall update speed).
  75712. */
  75713. targetStopDuration: number;
  75714. /**
  75715. * The texture used to render each particle. (this can be a spritesheet)
  75716. */
  75717. particleTexture: Nullable<Texture>;
  75718. /**
  75719. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75720. */
  75721. blendMode: number;
  75722. /**
  75723. * Minimum life time of emitting particles.
  75724. */
  75725. minLifeTime: number;
  75726. /**
  75727. * Maximum life time of emitting particles.
  75728. */
  75729. maxLifeTime: number;
  75730. /**
  75731. * Minimum Size of emitting particles.
  75732. */
  75733. minSize: number;
  75734. /**
  75735. * Maximum Size of emitting particles.
  75736. */
  75737. maxSize: number;
  75738. /**
  75739. * Minimum scale of emitting particles on X axis.
  75740. */
  75741. minScaleX: number;
  75742. /**
  75743. * Maximum scale of emitting particles on X axis.
  75744. */
  75745. maxScaleX: number;
  75746. /**
  75747. * Minimum scale of emitting particles on Y axis.
  75748. */
  75749. minScaleY: number;
  75750. /**
  75751. * Maximum scale of emitting particles on Y axis.
  75752. */
  75753. maxScaleY: number;
  75754. /**
  75755. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75756. */
  75757. color1: Color4;
  75758. /**
  75759. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75760. */
  75761. color2: Color4;
  75762. /**
  75763. * Color the particle will have at the end of its lifetime.
  75764. */
  75765. colorDead: Color4;
  75766. /**
  75767. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75768. */
  75769. emitRate: number;
  75770. /**
  75771. * You can use gravity if you want to give an orientation to your particles.
  75772. */
  75773. gravity: Vector3;
  75774. /**
  75775. * Minimum power of emitting particles.
  75776. */
  75777. minEmitPower: number;
  75778. /**
  75779. * Maximum power of emitting particles.
  75780. */
  75781. maxEmitPower: number;
  75782. /**
  75783. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75784. */
  75785. minAngularSpeed: number;
  75786. /**
  75787. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75788. */
  75789. maxAngularSpeed: number;
  75790. /**
  75791. * Gets or sets the minimal initial rotation in radians.
  75792. */
  75793. minInitialRotation: number;
  75794. /**
  75795. * Gets or sets the maximal initial rotation in radians.
  75796. */
  75797. maxInitialRotation: number;
  75798. /**
  75799. * The particle emitter type defines the emitter used by the particle system.
  75800. * It can be for example box, sphere, or cone...
  75801. */
  75802. particleEmitterType: Nullable<IParticleEmitterType>;
  75803. /**
  75804. * Defines the delay in milliseconds before starting the system (0 by default)
  75805. */
  75806. startDelay: number;
  75807. /**
  75808. * 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
  75809. */
  75810. preWarmCycles: number;
  75811. /**
  75812. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75813. */
  75814. preWarmStepOffset: number;
  75815. /**
  75816. * 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)
  75817. */
  75818. spriteCellChangeSpeed: number;
  75819. /**
  75820. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75821. */
  75822. startSpriteCellID: number;
  75823. /**
  75824. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75825. */
  75826. endSpriteCellID: number;
  75827. /**
  75828. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75829. */
  75830. spriteCellWidth: number;
  75831. /**
  75832. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75833. */
  75834. spriteCellHeight: number;
  75835. /**
  75836. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75837. */
  75838. spriteRandomStartCell: boolean;
  75839. /**
  75840. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75841. */
  75842. isAnimationSheetEnabled: boolean;
  75843. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75844. translationPivot: Vector2;
  75845. /**
  75846. * Gets or sets a texture used to add random noise to particle positions
  75847. */
  75848. noiseTexture: Nullable<BaseTexture>;
  75849. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75850. noiseStrength: Vector3;
  75851. /**
  75852. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75853. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75854. */
  75855. billboardMode: number;
  75856. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75857. limitVelocityDamping: number;
  75858. /**
  75859. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75860. */
  75861. beginAnimationOnStart: boolean;
  75862. /**
  75863. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75864. */
  75865. beginAnimationFrom: number;
  75866. /**
  75867. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75868. */
  75869. beginAnimationTo: number;
  75870. /**
  75871. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75872. */
  75873. beginAnimationLoop: boolean;
  75874. /**
  75875. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75876. */
  75877. disposeOnStop: boolean;
  75878. /**
  75879. * Gets the maximum number of particles active at the same time.
  75880. * @returns The max number of active particles.
  75881. */
  75882. getCapacity(): number;
  75883. /**
  75884. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75885. * @returns True if it has been started, otherwise false.
  75886. */
  75887. isStarted(): boolean;
  75888. /**
  75889. * Animates the particle system for this frame.
  75890. */
  75891. animate(): void;
  75892. /**
  75893. * Renders the particle system in its current state.
  75894. * @returns the current number of particles
  75895. */
  75896. render(): number;
  75897. /**
  75898. * Dispose the particle system and frees its associated resources.
  75899. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75900. */
  75901. dispose(disposeTexture?: boolean): void;
  75902. /**
  75903. * Clones the particle system.
  75904. * @param name The name of the cloned object
  75905. * @param newEmitter The new emitter to use
  75906. * @returns the cloned particle system
  75907. */
  75908. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  75909. /**
  75910. * Serializes the particle system to a JSON object.
  75911. * @returns the JSON object
  75912. */
  75913. serialize(): any;
  75914. /**
  75915. * Rebuild the particle system
  75916. */
  75917. rebuild(): void;
  75918. /**
  75919. * Starts the particle system and begins to emit
  75920. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  75921. */
  75922. start(delay?: number): void;
  75923. /**
  75924. * Stops the particle system.
  75925. */
  75926. stop(): void;
  75927. /**
  75928. * Remove all active particles
  75929. */
  75930. reset(): void;
  75931. /**
  75932. * Is this system ready to be used/rendered
  75933. * @return true if the system is ready
  75934. */
  75935. isReady(): boolean;
  75936. /**
  75937. * Adds a new color gradient
  75938. * @param gradient defines the gradient to use (between 0 and 1)
  75939. * @param color1 defines the color to affect to the specified gradient
  75940. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75941. * @returns the current particle system
  75942. */
  75943. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75944. /**
  75945. * Remove a specific color gradient
  75946. * @param gradient defines the gradient to remove
  75947. * @returns the current particle system
  75948. */
  75949. removeColorGradient(gradient: number): IParticleSystem;
  75950. /**
  75951. * Adds a new size gradient
  75952. * @param gradient defines the gradient to use (between 0 and 1)
  75953. * @param factor defines the size factor to affect to the specified gradient
  75954. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75955. * @returns the current particle system
  75956. */
  75957. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75958. /**
  75959. * Remove a specific size gradient
  75960. * @param gradient defines the gradient to remove
  75961. * @returns the current particle system
  75962. */
  75963. removeSizeGradient(gradient: number): IParticleSystem;
  75964. /**
  75965. * Gets the current list of color gradients.
  75966. * You must use addColorGradient and removeColorGradient to udpate this list
  75967. * @returns the list of color gradients
  75968. */
  75969. getColorGradients(): Nullable<Array<ColorGradient>>;
  75970. /**
  75971. * Gets the current list of size gradients.
  75972. * You must use addSizeGradient and removeSizeGradient to udpate this list
  75973. * @returns the list of size gradients
  75974. */
  75975. getSizeGradients(): Nullable<Array<FactorGradient>>;
  75976. /**
  75977. * Gets the current list of angular speed gradients.
  75978. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  75979. * @returns the list of angular speed gradients
  75980. */
  75981. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  75982. /**
  75983. * Adds a new angular speed gradient
  75984. * @param gradient defines the gradient to use (between 0 and 1)
  75985. * @param factor defines the angular speed to affect to the specified gradient
  75986. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75987. * @returns the current particle system
  75988. */
  75989. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75990. /**
  75991. * Remove a specific angular speed gradient
  75992. * @param gradient defines the gradient to remove
  75993. * @returns the current particle system
  75994. */
  75995. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75996. /**
  75997. * Gets the current list of velocity gradients.
  75998. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  75999. * @returns the list of velocity gradients
  76000. */
  76001. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76002. /**
  76003. * Adds a new velocity gradient
  76004. * @param gradient defines the gradient to use (between 0 and 1)
  76005. * @param factor defines the velocity to affect to the specified gradient
  76006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76007. * @returns the current particle system
  76008. */
  76009. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76010. /**
  76011. * Remove a specific velocity gradient
  76012. * @param gradient defines the gradient to remove
  76013. * @returns the current particle system
  76014. */
  76015. removeVelocityGradient(gradient: number): IParticleSystem;
  76016. /**
  76017. * Gets the current list of limit velocity gradients.
  76018. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76019. * @returns the list of limit velocity gradients
  76020. */
  76021. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76022. /**
  76023. * Adds a new limit velocity gradient
  76024. * @param gradient defines the gradient to use (between 0 and 1)
  76025. * @param factor defines the limit velocity to affect to the specified gradient
  76026. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76027. * @returns the current particle system
  76028. */
  76029. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76030. /**
  76031. * Remove a specific limit velocity gradient
  76032. * @param gradient defines the gradient to remove
  76033. * @returns the current particle system
  76034. */
  76035. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76036. /**
  76037. * Adds a new drag gradient
  76038. * @param gradient defines the gradient to use (between 0 and 1)
  76039. * @param factor defines the drag to affect to the specified gradient
  76040. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76041. * @returns the current particle system
  76042. */
  76043. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76044. /**
  76045. * Remove a specific drag gradient
  76046. * @param gradient defines the gradient to remove
  76047. * @returns the current particle system
  76048. */
  76049. removeDragGradient(gradient: number): IParticleSystem;
  76050. /**
  76051. * Gets the current list of drag gradients.
  76052. * You must use addDragGradient and removeDragGradient to udpate this list
  76053. * @returns the list of drag gradients
  76054. */
  76055. getDragGradients(): Nullable<Array<FactorGradient>>;
  76056. /**
  76057. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76058. * @param gradient defines the gradient to use (between 0 and 1)
  76059. * @param factor defines the emit rate to affect to the specified gradient
  76060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76061. * @returns the current particle system
  76062. */
  76063. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76064. /**
  76065. * Remove a specific emit rate gradient
  76066. * @param gradient defines the gradient to remove
  76067. * @returns the current particle system
  76068. */
  76069. removeEmitRateGradient(gradient: number): IParticleSystem;
  76070. /**
  76071. * Gets the current list of emit rate gradients.
  76072. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76073. * @returns the list of emit rate gradients
  76074. */
  76075. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76076. /**
  76077. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76078. * @param gradient defines the gradient to use (between 0 and 1)
  76079. * @param factor defines the start size to affect to the specified gradient
  76080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76081. * @returns the current particle system
  76082. */
  76083. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76084. /**
  76085. * Remove a specific start size gradient
  76086. * @param gradient defines the gradient to remove
  76087. * @returns the current particle system
  76088. */
  76089. removeStartSizeGradient(gradient: number): IParticleSystem;
  76090. /**
  76091. * Gets the current list of start size gradients.
  76092. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76093. * @returns the list of start size gradients
  76094. */
  76095. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76096. /**
  76097. * Adds a new life time gradient
  76098. * @param gradient defines the gradient to use (between 0 and 1)
  76099. * @param factor defines the life time factor to affect to the specified gradient
  76100. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76101. * @returns the current particle system
  76102. */
  76103. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76104. /**
  76105. * Remove a specific life time gradient
  76106. * @param gradient defines the gradient to remove
  76107. * @returns the current particle system
  76108. */
  76109. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76110. /**
  76111. * Gets the current list of life time gradients.
  76112. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76113. * @returns the list of life time gradients
  76114. */
  76115. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76116. /**
  76117. * Gets the current list of color gradients.
  76118. * You must use addColorGradient and removeColorGradient to udpate this list
  76119. * @returns the list of color gradients
  76120. */
  76121. getColorGradients(): Nullable<Array<ColorGradient>>;
  76122. /**
  76123. * Adds a new ramp gradient used to remap particle colors
  76124. * @param gradient defines the gradient to use (between 0 and 1)
  76125. * @param color defines the color to affect to the specified gradient
  76126. * @returns the current particle system
  76127. */
  76128. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76129. /**
  76130. * Gets the current list of ramp gradients.
  76131. * You must use addRampGradient and removeRampGradient to udpate this list
  76132. * @returns the list of ramp gradients
  76133. */
  76134. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76135. /** Gets or sets a boolean indicating that ramp gradients must be used
  76136. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76137. */
  76138. useRampGradients: boolean;
  76139. /**
  76140. * Adds a new color remap gradient
  76141. * @param gradient defines the gradient to use (between 0 and 1)
  76142. * @param min defines the color remap minimal range
  76143. * @param max defines the color remap maximal range
  76144. * @returns the current particle system
  76145. */
  76146. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76147. /**
  76148. * Gets the current list of color remap gradients.
  76149. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76150. * @returns the list of color remap gradients
  76151. */
  76152. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76153. /**
  76154. * Adds a new alpha remap gradient
  76155. * @param gradient defines the gradient to use (between 0 and 1)
  76156. * @param min defines the alpha remap minimal range
  76157. * @param max defines the alpha remap maximal range
  76158. * @returns the current particle system
  76159. */
  76160. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76161. /**
  76162. * Gets the current list of alpha remap gradients.
  76163. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76164. * @returns the list of alpha remap gradients
  76165. */
  76166. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76167. /**
  76168. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76169. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76170. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76171. * @returns the emitter
  76172. */
  76173. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76174. /**
  76175. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76176. * @param radius The radius of the hemisphere to emit from
  76177. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76178. * @returns the emitter
  76179. */
  76180. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76181. /**
  76182. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76183. * @param radius The radius of the sphere to emit from
  76184. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76185. * @returns the emitter
  76186. */
  76187. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76188. /**
  76189. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76190. * @param radius The radius of the sphere to emit from
  76191. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76192. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76193. * @returns the emitter
  76194. */
  76195. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76196. /**
  76197. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76198. * @param radius The radius of the emission cylinder
  76199. * @param height The height of the emission cylinder
  76200. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76201. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76202. * @returns the emitter
  76203. */
  76204. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76205. /**
  76206. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76207. * @param radius The radius of the cylinder to emit from
  76208. * @param height The height of the emission cylinder
  76209. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76210. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76211. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76212. * @returns the emitter
  76213. */
  76214. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76215. /**
  76216. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76217. * @param radius The radius of the cone to emit from
  76218. * @param angle The base angle of the cone
  76219. * @returns the emitter
  76220. */
  76221. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76222. /**
  76223. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76224. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76225. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76226. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76227. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76228. * @returns the emitter
  76229. */
  76230. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76231. /**
  76232. * Get hosting scene
  76233. * @returns the scene
  76234. */
  76235. getScene(): Scene;
  76236. }
  76237. }
  76238. declare module BABYLON {
  76239. /**
  76240. * Creates an instance based on a source mesh.
  76241. */
  76242. export class InstancedMesh extends AbstractMesh {
  76243. private _sourceMesh;
  76244. private _currentLOD;
  76245. /** @hidden */
  76246. _indexInSourceMeshInstanceArray: number;
  76247. constructor(name: string, source: Mesh);
  76248. /**
  76249. * Returns the string "InstancedMesh".
  76250. */
  76251. getClassName(): string;
  76252. /**
  76253. * If the source mesh receives shadows
  76254. */
  76255. readonly receiveShadows: boolean;
  76256. /**
  76257. * The material of the source mesh
  76258. */
  76259. readonly material: Nullable<Material>;
  76260. /**
  76261. * Visibility of the source mesh
  76262. */
  76263. readonly visibility: number;
  76264. /**
  76265. * Skeleton of the source mesh
  76266. */
  76267. readonly skeleton: Nullable<Skeleton>;
  76268. /**
  76269. * Rendering ground id of the source mesh
  76270. */
  76271. renderingGroupId: number;
  76272. /**
  76273. * Returns the total number of vertices (integer).
  76274. */
  76275. getTotalVertices(): number;
  76276. /**
  76277. * Returns a positive integer : the total number of indices in this mesh geometry.
  76278. * @returns the numner of indices or zero if the mesh has no geometry.
  76279. */
  76280. getTotalIndices(): number;
  76281. /**
  76282. * The source mesh of the instance
  76283. */
  76284. readonly sourceMesh: Mesh;
  76285. /**
  76286. * Is this node ready to be used/rendered
  76287. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76288. * @return {boolean} is it ready
  76289. */
  76290. isReady(completeCheck?: boolean): boolean;
  76291. /**
  76292. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76293. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76294. * @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.
  76295. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76296. */
  76297. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76298. /**
  76299. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76300. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76301. * The `data` are either a numeric array either a Float32Array.
  76302. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76303. * 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).
  76304. * Note that a new underlying VertexBuffer object is created each call.
  76305. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76306. *
  76307. * Possible `kind` values :
  76308. * - VertexBuffer.PositionKind
  76309. * - VertexBuffer.UVKind
  76310. * - VertexBuffer.UV2Kind
  76311. * - VertexBuffer.UV3Kind
  76312. * - VertexBuffer.UV4Kind
  76313. * - VertexBuffer.UV5Kind
  76314. * - VertexBuffer.UV6Kind
  76315. * - VertexBuffer.ColorKind
  76316. * - VertexBuffer.MatricesIndicesKind
  76317. * - VertexBuffer.MatricesIndicesExtraKind
  76318. * - VertexBuffer.MatricesWeightsKind
  76319. * - VertexBuffer.MatricesWeightsExtraKind
  76320. *
  76321. * Returns the Mesh.
  76322. */
  76323. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76324. /**
  76325. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76326. * If the mesh has no geometry, it is simply returned as it is.
  76327. * The `data` are either a numeric array either a Float32Array.
  76328. * No new underlying VertexBuffer object is created.
  76329. * 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.
  76330. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76331. *
  76332. * Possible `kind` values :
  76333. * - VertexBuffer.PositionKind
  76334. * - VertexBuffer.UVKind
  76335. * - VertexBuffer.UV2Kind
  76336. * - VertexBuffer.UV3Kind
  76337. * - VertexBuffer.UV4Kind
  76338. * - VertexBuffer.UV5Kind
  76339. * - VertexBuffer.UV6Kind
  76340. * - VertexBuffer.ColorKind
  76341. * - VertexBuffer.MatricesIndicesKind
  76342. * - VertexBuffer.MatricesIndicesExtraKind
  76343. * - VertexBuffer.MatricesWeightsKind
  76344. * - VertexBuffer.MatricesWeightsExtraKind
  76345. *
  76346. * Returns the Mesh.
  76347. */
  76348. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76349. /**
  76350. * Sets the mesh indices.
  76351. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76352. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76353. * This method creates a new index buffer each call.
  76354. * Returns the Mesh.
  76355. */
  76356. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76357. /**
  76358. * Boolean : True if the mesh owns the requested kind of data.
  76359. */
  76360. isVerticesDataPresent(kind: string): boolean;
  76361. /**
  76362. * Returns an array of indices (IndicesArray).
  76363. */
  76364. getIndices(): Nullable<IndicesArray>;
  76365. readonly _positions: Nullable<Vector3[]>;
  76366. /**
  76367. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76368. * This means the mesh underlying bounding box and sphere are recomputed.
  76369. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76370. * @returns the current mesh
  76371. */
  76372. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76373. /** @hidden */
  76374. _preActivate(): InstancedMesh;
  76375. /** @hidden */
  76376. _activate(renderId: number): boolean;
  76377. /**
  76378. * Returns the current associated LOD AbstractMesh.
  76379. */
  76380. getLOD(camera: Camera): AbstractMesh;
  76381. /** @hidden */
  76382. _syncSubMeshes(): InstancedMesh;
  76383. /** @hidden */
  76384. _generatePointsArray(): boolean;
  76385. /**
  76386. * Creates a new InstancedMesh from the current mesh.
  76387. * - name (string) : the cloned mesh name
  76388. * - newParent (optional Node) : the optional Node to parent the clone to.
  76389. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76390. *
  76391. * Returns the clone.
  76392. */
  76393. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76394. /**
  76395. * Disposes the InstancedMesh.
  76396. * Returns nothing.
  76397. */
  76398. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76399. }
  76400. }
  76401. declare module BABYLON {
  76402. /**
  76403. * Defines the options associated with the creation of a shader material.
  76404. */
  76405. export interface IShaderMaterialOptions {
  76406. /**
  76407. * Does the material work in alpha blend mode
  76408. */
  76409. needAlphaBlending: boolean;
  76410. /**
  76411. * Does the material work in alpha test mode
  76412. */
  76413. needAlphaTesting: boolean;
  76414. /**
  76415. * The list of attribute names used in the shader
  76416. */
  76417. attributes: string[];
  76418. /**
  76419. * The list of unifrom names used in the shader
  76420. */
  76421. uniforms: string[];
  76422. /**
  76423. * The list of UBO names used in the shader
  76424. */
  76425. uniformBuffers: string[];
  76426. /**
  76427. * The list of sampler names used in the shader
  76428. */
  76429. samplers: string[];
  76430. /**
  76431. * The list of defines used in the shader
  76432. */
  76433. defines: string[];
  76434. }
  76435. /**
  76436. * 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.
  76437. *
  76438. * This returned material effects how the mesh will look based on the code in the shaders.
  76439. *
  76440. * @see http://doc.babylonjs.com/how_to/shader_material
  76441. */
  76442. export class ShaderMaterial extends Material {
  76443. private _shaderPath;
  76444. private _options;
  76445. private _textures;
  76446. private _textureArrays;
  76447. private _floats;
  76448. private _ints;
  76449. private _floatsArrays;
  76450. private _colors3;
  76451. private _colors3Arrays;
  76452. private _colors4;
  76453. private _vectors2;
  76454. private _vectors3;
  76455. private _vectors4;
  76456. private _matrices;
  76457. private _matrices3x3;
  76458. private _matrices2x2;
  76459. private _vectors2Arrays;
  76460. private _vectors3Arrays;
  76461. private _cachedWorldViewMatrix;
  76462. private _renderId;
  76463. /**
  76464. * Instantiate a new shader material.
  76465. * 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.
  76466. * This returned material effects how the mesh will look based on the code in the shaders.
  76467. * @see http://doc.babylonjs.com/how_to/shader_material
  76468. * @param name Define the name of the material in the scene
  76469. * @param scene Define the scene the material belongs to
  76470. * @param shaderPath Defines the route to the shader code in one of three ways:
  76471. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76472. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76473. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76474. * @param options Define the options used to create the shader
  76475. */
  76476. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76477. /**
  76478. * Gets the options used to compile the shader.
  76479. * They can be modified to trigger a new compilation
  76480. */
  76481. readonly options: IShaderMaterialOptions;
  76482. /**
  76483. * Gets the current class name of the material e.g. "ShaderMaterial"
  76484. * Mainly use in serialization.
  76485. * @returns the class name
  76486. */
  76487. getClassName(): string;
  76488. /**
  76489. * Specifies if the material will require alpha blending
  76490. * @returns a boolean specifying if alpha blending is needed
  76491. */
  76492. needAlphaBlending(): boolean;
  76493. /**
  76494. * Specifies if this material should be rendered in alpha test mode
  76495. * @returns a boolean specifying if an alpha test is needed.
  76496. */
  76497. needAlphaTesting(): boolean;
  76498. private _checkUniform;
  76499. /**
  76500. * Set a texture in the shader.
  76501. * @param name Define the name of the uniform samplers as defined in the shader
  76502. * @param texture Define the texture to bind to this sampler
  76503. * @return the material itself allowing "fluent" like uniform updates
  76504. */
  76505. setTexture(name: string, texture: Texture): ShaderMaterial;
  76506. /**
  76507. * Set a texture array in the shader.
  76508. * @param name Define the name of the uniform sampler array as defined in the shader
  76509. * @param textures Define the list of textures to bind to this sampler
  76510. * @return the material itself allowing "fluent" like uniform updates
  76511. */
  76512. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76513. /**
  76514. * Set a float in the shader.
  76515. * @param name Define the name of the uniform as defined in the shader
  76516. * @param value Define the value to give to the uniform
  76517. * @return the material itself allowing "fluent" like uniform updates
  76518. */
  76519. setFloat(name: string, value: number): ShaderMaterial;
  76520. /**
  76521. * Set a int in the shader.
  76522. * @param name Define the name of the uniform as defined in the shader
  76523. * @param value Define the value to give to the uniform
  76524. * @return the material itself allowing "fluent" like uniform updates
  76525. */
  76526. setInt(name: string, value: number): ShaderMaterial;
  76527. /**
  76528. * Set an array of floats in the shader.
  76529. * @param name Define the name of the uniform as defined in the shader
  76530. * @param value Define the value to give to the uniform
  76531. * @return the material itself allowing "fluent" like uniform updates
  76532. */
  76533. setFloats(name: string, value: number[]): ShaderMaterial;
  76534. /**
  76535. * Set a vec3 in the shader from a Color3.
  76536. * @param name Define the name of the uniform as defined in the shader
  76537. * @param value Define the value to give to the uniform
  76538. * @return the material itself allowing "fluent" like uniform updates
  76539. */
  76540. setColor3(name: string, value: Color3): ShaderMaterial;
  76541. /**
  76542. * Set a vec3 array in the shader from a Color3 array.
  76543. * @param name Define the name of the uniform as defined in the shader
  76544. * @param value Define the value to give to the uniform
  76545. * @return the material itself allowing "fluent" like uniform updates
  76546. */
  76547. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76548. /**
  76549. * Set a vec4 in the shader from a Color4.
  76550. * @param name Define the name of the uniform as defined in the shader
  76551. * @param value Define the value to give to the uniform
  76552. * @return the material itself allowing "fluent" like uniform updates
  76553. */
  76554. setColor4(name: string, value: Color4): ShaderMaterial;
  76555. /**
  76556. * Set a vec2 in the shader from a Vector2.
  76557. * @param name Define the name of the uniform as defined in the shader
  76558. * @param value Define the value to give to the uniform
  76559. * @return the material itself allowing "fluent" like uniform updates
  76560. */
  76561. setVector2(name: string, value: Vector2): ShaderMaterial;
  76562. /**
  76563. * Set a vec3 in the shader from a Vector3.
  76564. * @param name Define the name of the uniform as defined in the shader
  76565. * @param value Define the value to give to the uniform
  76566. * @return the material itself allowing "fluent" like uniform updates
  76567. */
  76568. setVector3(name: string, value: Vector3): ShaderMaterial;
  76569. /**
  76570. * Set a vec4 in the shader from a Vector4.
  76571. * @param name Define the name of the uniform as defined in the shader
  76572. * @param value Define the value to give to the uniform
  76573. * @return the material itself allowing "fluent" like uniform updates
  76574. */
  76575. setVector4(name: string, value: Vector4): ShaderMaterial;
  76576. /**
  76577. * Set a mat4 in the shader from a Matrix.
  76578. * @param name Define the name of the uniform as defined in the shader
  76579. * @param value Define the value to give to the uniform
  76580. * @return the material itself allowing "fluent" like uniform updates
  76581. */
  76582. setMatrix(name: string, value: Matrix): ShaderMaterial;
  76583. /**
  76584. * Set a mat3 in the shader from a Float32Array.
  76585. * @param name Define the name of the uniform as defined in the shader
  76586. * @param value Define the value to give to the uniform
  76587. * @return the material itself allowing "fluent" like uniform updates
  76588. */
  76589. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  76590. /**
  76591. * Set a mat2 in the shader from a Float32Array.
  76592. * @param name Define the name of the uniform as defined in the shader
  76593. * @param value Define the value to give to the uniform
  76594. * @return the material itself allowing "fluent" like uniform updates
  76595. */
  76596. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  76597. /**
  76598. * Set a vec2 array in the shader from a number array.
  76599. * @param name Define the name of the uniform as defined in the shader
  76600. * @param value Define the value to give to the uniform
  76601. * @return the material itself allowing "fluent" like uniform updates
  76602. */
  76603. setArray2(name: string, value: number[]): ShaderMaterial;
  76604. /**
  76605. * Set a vec3 array in the shader from a number array.
  76606. * @param name Define the name of the uniform as defined in the shader
  76607. * @param value Define the value to give to the uniform
  76608. * @return the material itself allowing "fluent" like uniform updates
  76609. */
  76610. setArray3(name: string, value: number[]): ShaderMaterial;
  76611. private _checkCache;
  76612. /**
  76613. * Specifies that the submesh is ready to be used
  76614. * @param mesh defines the mesh to check
  76615. * @param subMesh defines which submesh to check
  76616. * @param useInstances specifies that instances should be used
  76617. * @returns a boolean indicating that the submesh is ready or not
  76618. */
  76619. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  76620. /**
  76621. * Checks if the material is ready to render the requested mesh
  76622. * @param mesh Define the mesh to render
  76623. * @param useInstances Define whether or not the material is used with instances
  76624. * @returns true if ready, otherwise false
  76625. */
  76626. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76627. /**
  76628. * Binds the world matrix to the material
  76629. * @param world defines the world transformation matrix
  76630. */
  76631. bindOnlyWorldMatrix(world: Matrix): void;
  76632. /**
  76633. * Binds the material to the mesh
  76634. * @param world defines the world transformation matrix
  76635. * @param mesh defines the mesh to bind the material to
  76636. */
  76637. bind(world: Matrix, mesh?: Mesh): void;
  76638. /**
  76639. * Gets the active textures from the material
  76640. * @returns an array of textures
  76641. */
  76642. getActiveTextures(): BaseTexture[];
  76643. /**
  76644. * Specifies if the material uses a texture
  76645. * @param texture defines the texture to check against the material
  76646. * @returns a boolean specifying if the material uses the texture
  76647. */
  76648. hasTexture(texture: BaseTexture): boolean;
  76649. /**
  76650. * Makes a duplicate of the material, and gives it a new name
  76651. * @param name defines the new name for the duplicated material
  76652. * @returns the cloned material
  76653. */
  76654. clone(name: string): ShaderMaterial;
  76655. /**
  76656. * Disposes the material
  76657. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76658. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  76659. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  76660. */
  76661. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  76662. /**
  76663. * Serializes this material in a JSON representation
  76664. * @returns the serialized material object
  76665. */
  76666. serialize(): any;
  76667. /**
  76668. * Creates a shader material from parsed shader material data
  76669. * @param source defines the JSON represnetation of the material
  76670. * @param scene defines the hosting scene
  76671. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76672. * @returns a new material
  76673. */
  76674. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76675. }
  76676. }
  76677. declare module BABYLON {
  76678. /** @hidden */
  76679. export var colorPixelShader: {
  76680. name: string;
  76681. shader: string;
  76682. };
  76683. }
  76684. declare module BABYLON {
  76685. /** @hidden */
  76686. export var colorVertexShader: {
  76687. name: string;
  76688. shader: string;
  76689. };
  76690. }
  76691. declare module BABYLON {
  76692. /**
  76693. * Line mesh
  76694. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76695. */
  76696. export class LinesMesh extends Mesh {
  76697. /**
  76698. * If vertex color should be applied to the mesh
  76699. */
  76700. useVertexColor?: boolean | undefined;
  76701. /**
  76702. * If vertex alpha should be applied to the mesh
  76703. */
  76704. useVertexAlpha?: boolean | undefined;
  76705. /**
  76706. * Color of the line (Default: White)
  76707. */
  76708. color: Color3;
  76709. /**
  76710. * Alpha of the line (Default: 1)
  76711. */
  76712. alpha: number;
  76713. /**
  76714. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76715. * This margin is expressed in world space coordinates, so its value may vary.
  76716. * Default value is 0.1
  76717. */
  76718. intersectionThreshold: number;
  76719. private _colorShader;
  76720. /**
  76721. * Creates a new LinesMesh
  76722. * @param name defines the name
  76723. * @param scene defines the hosting scene
  76724. * @param parent defines the parent mesh if any
  76725. * @param source defines the optional source LinesMesh used to clone data from
  76726. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76727. * When false, achieved by calling a clone(), also passing False.
  76728. * This will make creation of children, recursive.
  76729. * @param useVertexColor defines if this LinesMesh supports vertex color
  76730. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76731. */
  76732. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76733. /**
  76734. * If vertex color should be applied to the mesh
  76735. */
  76736. useVertexColor?: boolean | undefined,
  76737. /**
  76738. * If vertex alpha should be applied to the mesh
  76739. */
  76740. useVertexAlpha?: boolean | undefined);
  76741. private _addClipPlaneDefine;
  76742. private _removeClipPlaneDefine;
  76743. isReady(): boolean;
  76744. /**
  76745. * Returns the string "LineMesh"
  76746. */
  76747. getClassName(): string;
  76748. /**
  76749. * @hidden
  76750. */
  76751. /**
  76752. * @hidden
  76753. */
  76754. material: Material;
  76755. /**
  76756. * @hidden
  76757. */
  76758. readonly checkCollisions: boolean;
  76759. /** @hidden */
  76760. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76761. /** @hidden */
  76762. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76763. /**
  76764. * Disposes of the line mesh
  76765. * @param doNotRecurse If children should be disposed
  76766. */
  76767. dispose(doNotRecurse?: boolean): void;
  76768. /**
  76769. * Returns a new LineMesh object cloned from the current one.
  76770. */
  76771. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76772. /**
  76773. * Creates a new InstancedLinesMesh object from the mesh model.
  76774. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76775. * @param name defines the name of the new instance
  76776. * @returns a new InstancedLinesMesh
  76777. */
  76778. createInstance(name: string): InstancedLinesMesh;
  76779. }
  76780. /**
  76781. * Creates an instance based on a source LinesMesh
  76782. */
  76783. export class InstancedLinesMesh extends InstancedMesh {
  76784. /**
  76785. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76786. * This margin is expressed in world space coordinates, so its value may vary.
  76787. * Initilized with the intersectionThreshold value of the source LinesMesh
  76788. */
  76789. intersectionThreshold: number;
  76790. constructor(name: string, source: LinesMesh);
  76791. /**
  76792. * Returns the string "InstancedLinesMesh".
  76793. */
  76794. getClassName(): string;
  76795. }
  76796. }
  76797. declare module BABYLON {
  76798. /** @hidden */
  76799. export var linePixelShader: {
  76800. name: string;
  76801. shader: string;
  76802. };
  76803. }
  76804. declare module BABYLON {
  76805. /** @hidden */
  76806. export var lineVertexShader: {
  76807. name: string;
  76808. shader: string;
  76809. };
  76810. }
  76811. declare module BABYLON {
  76812. interface AbstractMesh {
  76813. /**
  76814. * Disables the mesh edge rendering mode
  76815. * @returns the currentAbstractMesh
  76816. */
  76817. disableEdgesRendering(): AbstractMesh;
  76818. /**
  76819. * Enables the edge rendering mode on the mesh.
  76820. * This mode makes the mesh edges visible
  76821. * @param epsilon defines the maximal distance between two angles to detect a face
  76822. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76823. * @returns the currentAbstractMesh
  76824. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76825. */
  76826. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76827. /**
  76828. * Gets the edgesRenderer associated with the mesh
  76829. */
  76830. edgesRenderer: Nullable<EdgesRenderer>;
  76831. }
  76832. interface LinesMesh {
  76833. /**
  76834. * Enables the edge rendering mode on the mesh.
  76835. * This mode makes the mesh edges visible
  76836. * @param epsilon defines the maximal distance between two angles to detect a face
  76837. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76838. * @returns the currentAbstractMesh
  76839. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76840. */
  76841. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76842. }
  76843. interface InstancedLinesMesh {
  76844. /**
  76845. * Enables the edge rendering mode on the mesh.
  76846. * This mode makes the mesh edges visible
  76847. * @param epsilon defines the maximal distance between two angles to detect a face
  76848. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76849. * @returns the current InstancedLinesMesh
  76850. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76851. */
  76852. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76853. }
  76854. /**
  76855. * Defines the minimum contract an Edges renderer should follow.
  76856. */
  76857. export interface IEdgesRenderer extends IDisposable {
  76858. /**
  76859. * Gets or sets a boolean indicating if the edgesRenderer is active
  76860. */
  76861. isEnabled: boolean;
  76862. /**
  76863. * Renders the edges of the attached mesh,
  76864. */
  76865. render(): void;
  76866. /**
  76867. * Checks wether or not the edges renderer is ready to render.
  76868. * @return true if ready, otherwise false.
  76869. */
  76870. isReady(): boolean;
  76871. }
  76872. /**
  76873. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76874. */
  76875. export class EdgesRenderer implements IEdgesRenderer {
  76876. /**
  76877. * Define the size of the edges with an orthographic camera
  76878. */
  76879. edgesWidthScalerForOrthographic: number;
  76880. /**
  76881. * Define the size of the edges with a perspective camera
  76882. */
  76883. edgesWidthScalerForPerspective: number;
  76884. protected _source: AbstractMesh;
  76885. protected _linesPositions: number[];
  76886. protected _linesNormals: number[];
  76887. protected _linesIndices: number[];
  76888. protected _epsilon: number;
  76889. protected _indicesCount: number;
  76890. protected _lineShader: ShaderMaterial;
  76891. protected _ib: WebGLBuffer;
  76892. protected _buffers: {
  76893. [key: string]: Nullable<VertexBuffer>;
  76894. };
  76895. protected _checkVerticesInsteadOfIndices: boolean;
  76896. private _meshRebuildObserver;
  76897. private _meshDisposeObserver;
  76898. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  76899. isEnabled: boolean;
  76900. /**
  76901. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  76902. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  76903. * @param source Mesh used to create edges
  76904. * @param epsilon sum of angles in adjacency to check for edge
  76905. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  76906. * @param generateEdgesLines - should generate Lines or only prepare resources.
  76907. */
  76908. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  76909. protected _prepareRessources(): void;
  76910. /** @hidden */
  76911. _rebuild(): void;
  76912. /**
  76913. * Releases the required resources for the edges renderer
  76914. */
  76915. dispose(): void;
  76916. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  76917. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  76918. /**
  76919. * Checks if the pair of p0 and p1 is en edge
  76920. * @param faceIndex
  76921. * @param edge
  76922. * @param faceNormals
  76923. * @param p0
  76924. * @param p1
  76925. * @private
  76926. */
  76927. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  76928. /**
  76929. * push line into the position, normal and index buffer
  76930. * @protected
  76931. */
  76932. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  76933. /**
  76934. * Generates lines edges from adjacencjes
  76935. * @private
  76936. */
  76937. _generateEdgesLines(): void;
  76938. /**
  76939. * Checks wether or not the edges renderer is ready to render.
  76940. * @return true if ready, otherwise false.
  76941. */
  76942. isReady(): boolean;
  76943. /**
  76944. * Renders the edges of the attached mesh,
  76945. */
  76946. render(): void;
  76947. }
  76948. /**
  76949. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  76950. */
  76951. export class LineEdgesRenderer extends EdgesRenderer {
  76952. /**
  76953. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  76954. * @param source LineMesh used to generate edges
  76955. * @param epsilon not important (specified angle for edge detection)
  76956. * @param checkVerticesInsteadOfIndices not important for LineMesh
  76957. */
  76958. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  76959. /**
  76960. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  76961. */
  76962. _generateEdgesLines(): void;
  76963. }
  76964. }
  76965. declare module BABYLON {
  76966. /**
  76967. * This represents the object necessary to create a rendering group.
  76968. * This is exclusively used and created by the rendering manager.
  76969. * To modify the behavior, you use the available helpers in your scene or meshes.
  76970. * @hidden
  76971. */
  76972. export class RenderingGroup {
  76973. index: number;
  76974. private _scene;
  76975. private _opaqueSubMeshes;
  76976. private _transparentSubMeshes;
  76977. private _alphaTestSubMeshes;
  76978. private _depthOnlySubMeshes;
  76979. private _particleSystems;
  76980. private _spriteManagers;
  76981. private _opaqueSortCompareFn;
  76982. private _alphaTestSortCompareFn;
  76983. private _transparentSortCompareFn;
  76984. private _renderOpaque;
  76985. private _renderAlphaTest;
  76986. private _renderTransparent;
  76987. /** @hidden */
  76988. _edgesRenderers: SmartArray<IEdgesRenderer>;
  76989. onBeforeTransparentRendering: () => void;
  76990. /**
  76991. * Set the opaque sort comparison function.
  76992. * If null the sub meshes will be render in the order they were created
  76993. */
  76994. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76995. /**
  76996. * Set the alpha test sort comparison function.
  76997. * If null the sub meshes will be render in the order they were created
  76998. */
  76999. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77000. /**
  77001. * Set the transparent sort comparison function.
  77002. * If null the sub meshes will be render in the order they were created
  77003. */
  77004. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77005. /**
  77006. * Creates a new rendering group.
  77007. * @param index The rendering group index
  77008. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77009. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77010. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77011. */
  77012. 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>);
  77013. /**
  77014. * Render all the sub meshes contained in the group.
  77015. * @param customRenderFunction Used to override the default render behaviour of the group.
  77016. * @returns true if rendered some submeshes.
  77017. */
  77018. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77019. /**
  77020. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77021. * @param subMeshes The submeshes to render
  77022. */
  77023. private renderOpaqueSorted;
  77024. /**
  77025. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77026. * @param subMeshes The submeshes to render
  77027. */
  77028. private renderAlphaTestSorted;
  77029. /**
  77030. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77031. * @param subMeshes The submeshes to render
  77032. */
  77033. private renderTransparentSorted;
  77034. /**
  77035. * Renders the submeshes in a specified order.
  77036. * @param subMeshes The submeshes to sort before render
  77037. * @param sortCompareFn The comparison function use to sort
  77038. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77039. * @param transparent Specifies to activate blending if true
  77040. */
  77041. private static renderSorted;
  77042. /**
  77043. * Renders the submeshes in the order they were dispatched (no sort applied).
  77044. * @param subMeshes The submeshes to render
  77045. */
  77046. private static renderUnsorted;
  77047. /**
  77048. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77049. * are rendered back to front if in the same alpha index.
  77050. *
  77051. * @param a The first submesh
  77052. * @param b The second submesh
  77053. * @returns The result of the comparison
  77054. */
  77055. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77056. /**
  77057. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77058. * are rendered back to front.
  77059. *
  77060. * @param a The first submesh
  77061. * @param b The second submesh
  77062. * @returns The result of the comparison
  77063. */
  77064. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77065. /**
  77066. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77067. * are rendered front to back (prevent overdraw).
  77068. *
  77069. * @param a The first submesh
  77070. * @param b The second submesh
  77071. * @returns The result of the comparison
  77072. */
  77073. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77074. /**
  77075. * Resets the different lists of submeshes to prepare a new frame.
  77076. */
  77077. prepare(): void;
  77078. dispose(): void;
  77079. /**
  77080. * Inserts the submesh in its correct queue depending on its material.
  77081. * @param subMesh The submesh to dispatch
  77082. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77083. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77084. */
  77085. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77086. dispatchSprites(spriteManager: ISpriteManager): void;
  77087. dispatchParticles(particleSystem: IParticleSystem): void;
  77088. private _renderParticles;
  77089. private _renderSprites;
  77090. }
  77091. }
  77092. declare module BABYLON {
  77093. /**
  77094. * Interface describing the different options available in the rendering manager
  77095. * regarding Auto Clear between groups.
  77096. */
  77097. export interface IRenderingManagerAutoClearSetup {
  77098. /**
  77099. * Defines whether or not autoclear is enable.
  77100. */
  77101. autoClear: boolean;
  77102. /**
  77103. * Defines whether or not to autoclear the depth buffer.
  77104. */
  77105. depth: boolean;
  77106. /**
  77107. * Defines whether or not to autoclear the stencil buffer.
  77108. */
  77109. stencil: boolean;
  77110. }
  77111. /**
  77112. * This class is used by the onRenderingGroupObservable
  77113. */
  77114. export class RenderingGroupInfo {
  77115. /**
  77116. * The Scene that being rendered
  77117. */
  77118. scene: Scene;
  77119. /**
  77120. * The camera currently used for the rendering pass
  77121. */
  77122. camera: Nullable<Camera>;
  77123. /**
  77124. * The ID of the renderingGroup being processed
  77125. */
  77126. renderingGroupId: number;
  77127. }
  77128. /**
  77129. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77130. * It is enable to manage the different groups as well as the different necessary sort functions.
  77131. * This should not be used directly aside of the few static configurations
  77132. */
  77133. export class RenderingManager {
  77134. /**
  77135. * The max id used for rendering groups (not included)
  77136. */
  77137. static MAX_RENDERINGGROUPS: number;
  77138. /**
  77139. * The min id used for rendering groups (included)
  77140. */
  77141. static MIN_RENDERINGGROUPS: number;
  77142. /**
  77143. * Used to globally prevent autoclearing scenes.
  77144. */
  77145. static AUTOCLEAR: boolean;
  77146. /**
  77147. * @hidden
  77148. */
  77149. _useSceneAutoClearSetup: boolean;
  77150. private _scene;
  77151. private _renderingGroups;
  77152. private _depthStencilBufferAlreadyCleaned;
  77153. private _autoClearDepthStencil;
  77154. private _customOpaqueSortCompareFn;
  77155. private _customAlphaTestSortCompareFn;
  77156. private _customTransparentSortCompareFn;
  77157. private _renderingGroupInfo;
  77158. /**
  77159. * Instantiates a new rendering group for a particular scene
  77160. * @param scene Defines the scene the groups belongs to
  77161. */
  77162. constructor(scene: Scene);
  77163. private _clearDepthStencilBuffer;
  77164. /**
  77165. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77166. * @hidden
  77167. */
  77168. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77169. /**
  77170. * Resets the different information of the group to prepare a new frame
  77171. * @hidden
  77172. */
  77173. reset(): void;
  77174. /**
  77175. * Dispose and release the group and its associated resources.
  77176. * @hidden
  77177. */
  77178. dispose(): void;
  77179. /**
  77180. * Clear the info related to rendering groups preventing retention points during dispose.
  77181. */
  77182. freeRenderingGroups(): void;
  77183. private _prepareRenderingGroup;
  77184. /**
  77185. * Add a sprite manager to the rendering manager in order to render it this frame.
  77186. * @param spriteManager Define the sprite manager to render
  77187. */
  77188. dispatchSprites(spriteManager: ISpriteManager): void;
  77189. /**
  77190. * Add a particle system to the rendering manager in order to render it this frame.
  77191. * @param particleSystem Define the particle system to render
  77192. */
  77193. dispatchParticles(particleSystem: IParticleSystem): void;
  77194. /**
  77195. * Add a submesh to the manager in order to render it this frame
  77196. * @param subMesh The submesh to dispatch
  77197. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77198. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77199. */
  77200. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77201. /**
  77202. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77203. * This allowed control for front to back rendering or reversly depending of the special needs.
  77204. *
  77205. * @param renderingGroupId The rendering group id corresponding to its index
  77206. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77207. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77208. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77209. */
  77210. 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;
  77211. /**
  77212. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77213. *
  77214. * @param renderingGroupId The rendering group id corresponding to its index
  77215. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77216. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77217. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77218. */
  77219. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77220. /**
  77221. * Gets the current auto clear configuration for one rendering group of the rendering
  77222. * manager.
  77223. * @param index the rendering group index to get the information for
  77224. * @returns The auto clear setup for the requested rendering group
  77225. */
  77226. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77227. }
  77228. }
  77229. declare module BABYLON {
  77230. /**
  77231. * This Helps creating a texture that will be created from a camera in your scene.
  77232. * It is basically a dynamic texture that could be used to create special effects for instance.
  77233. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77234. */
  77235. export class RenderTargetTexture extends Texture {
  77236. isCube: boolean;
  77237. /**
  77238. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77239. */
  77240. static readonly REFRESHRATE_RENDER_ONCE: number;
  77241. /**
  77242. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77243. */
  77244. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77245. /**
  77246. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77247. * the central point of your effect and can save a lot of performances.
  77248. */
  77249. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77250. /**
  77251. * Use this predicate to dynamically define the list of mesh you want to render.
  77252. * If set, the renderList property will be overwritten.
  77253. */
  77254. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77255. private _renderList;
  77256. /**
  77257. * Use this list to define the list of mesh you want to render.
  77258. */
  77259. renderList: Nullable<Array<AbstractMesh>>;
  77260. private _hookArray;
  77261. /**
  77262. * Define if particles should be rendered in your texture.
  77263. */
  77264. renderParticles: boolean;
  77265. /**
  77266. * Define if sprites should be rendered in your texture.
  77267. */
  77268. renderSprites: boolean;
  77269. /**
  77270. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77271. */
  77272. coordinatesMode: number;
  77273. /**
  77274. * Define the camera used to render the texture.
  77275. */
  77276. activeCamera: Nullable<Camera>;
  77277. /**
  77278. * Override the render function of the texture with your own one.
  77279. */
  77280. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77281. /**
  77282. * Define if camera post processes should be use while rendering the texture.
  77283. */
  77284. useCameraPostProcesses: boolean;
  77285. /**
  77286. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77287. */
  77288. ignoreCameraViewport: boolean;
  77289. private _postProcessManager;
  77290. private _postProcesses;
  77291. private _resizeObserver;
  77292. /**
  77293. * An event triggered when the texture is unbind.
  77294. */
  77295. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77296. /**
  77297. * An event triggered when the texture is unbind.
  77298. */
  77299. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77300. private _onAfterUnbindObserver;
  77301. /**
  77302. * Set a after unbind callback in the texture.
  77303. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77304. */
  77305. onAfterUnbind: () => void;
  77306. /**
  77307. * An event triggered before rendering the texture
  77308. */
  77309. onBeforeRenderObservable: Observable<number>;
  77310. private _onBeforeRenderObserver;
  77311. /**
  77312. * Set a before render callback in the texture.
  77313. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77314. */
  77315. onBeforeRender: (faceIndex: number) => void;
  77316. /**
  77317. * An event triggered after rendering the texture
  77318. */
  77319. onAfterRenderObservable: Observable<number>;
  77320. private _onAfterRenderObserver;
  77321. /**
  77322. * Set a after render callback in the texture.
  77323. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77324. */
  77325. onAfterRender: (faceIndex: number) => void;
  77326. /**
  77327. * An event triggered after the texture clear
  77328. */
  77329. onClearObservable: Observable<Engine>;
  77330. private _onClearObserver;
  77331. /**
  77332. * Set a clear callback in the texture.
  77333. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77334. */
  77335. onClear: (Engine: Engine) => void;
  77336. /**
  77337. * Define the clear color of the Render Target if it should be different from the scene.
  77338. */
  77339. clearColor: Color4;
  77340. protected _size: number | {
  77341. width: number;
  77342. height: number;
  77343. };
  77344. protected _initialSizeParameter: number | {
  77345. width: number;
  77346. height: number;
  77347. } | {
  77348. ratio: number;
  77349. };
  77350. protected _sizeRatio: Nullable<number>;
  77351. /** @hidden */
  77352. _generateMipMaps: boolean;
  77353. protected _renderingManager: RenderingManager;
  77354. /** @hidden */
  77355. _waitingRenderList: string[];
  77356. protected _doNotChangeAspectRatio: boolean;
  77357. protected _currentRefreshId: number;
  77358. protected _refreshRate: number;
  77359. protected _textureMatrix: Matrix;
  77360. protected _samples: number;
  77361. protected _renderTargetOptions: RenderTargetCreationOptions;
  77362. /**
  77363. * Gets render target creation options that were used.
  77364. */
  77365. readonly renderTargetOptions: RenderTargetCreationOptions;
  77366. protected _engine: Engine;
  77367. protected _onRatioRescale(): void;
  77368. /**
  77369. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77370. * It must define where the camera used to render the texture is set
  77371. */
  77372. boundingBoxPosition: Vector3;
  77373. private _boundingBoxSize;
  77374. /**
  77375. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77376. * When defined, the cubemap will switch to local mode
  77377. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77378. * @example https://www.babylonjs-playground.com/#RNASML
  77379. */
  77380. boundingBoxSize: Vector3;
  77381. /**
  77382. * In case the RTT has been created with a depth texture, get the associated
  77383. * depth texture.
  77384. * Otherwise, return null.
  77385. */
  77386. depthStencilTexture: Nullable<InternalTexture>;
  77387. /**
  77388. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77389. * or used a shadow, depth texture...
  77390. * @param name The friendly name of the texture
  77391. * @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)
  77392. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77393. * @param generateMipMaps True if mip maps need to be generated after render.
  77394. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77395. * @param type The type of the buffer in the RTT (int, half float, float...)
  77396. * @param isCube True if a cube texture needs to be created
  77397. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77398. * @param generateDepthBuffer True to generate a depth buffer
  77399. * @param generateStencilBuffer True to generate a stencil buffer
  77400. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77401. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77402. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77403. */
  77404. constructor(name: string, size: number | {
  77405. width: number;
  77406. height: number;
  77407. } | {
  77408. ratio: number;
  77409. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77410. /**
  77411. * Creates a depth stencil texture.
  77412. * This is only available in WebGL 2 or with the depth texture extension available.
  77413. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77414. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77415. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77416. */
  77417. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77418. private _processSizeParameter;
  77419. /**
  77420. * Define the number of samples to use in case of MSAA.
  77421. * It defaults to one meaning no MSAA has been enabled.
  77422. */
  77423. samples: number;
  77424. /**
  77425. * Resets the refresh counter of the texture and start bak from scratch.
  77426. * Could be useful to regenerate the texture if it is setup to render only once.
  77427. */
  77428. resetRefreshCounter(): void;
  77429. /**
  77430. * Define the refresh rate of the texture or the rendering frequency.
  77431. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77432. */
  77433. refreshRate: number;
  77434. /**
  77435. * Adds a post process to the render target rendering passes.
  77436. * @param postProcess define the post process to add
  77437. */
  77438. addPostProcess(postProcess: PostProcess): void;
  77439. /**
  77440. * Clear all the post processes attached to the render target
  77441. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77442. */
  77443. clearPostProcesses(dispose?: boolean): void;
  77444. /**
  77445. * Remove one of the post process from the list of attached post processes to the texture
  77446. * @param postProcess define the post process to remove from the list
  77447. */
  77448. removePostProcess(postProcess: PostProcess): void;
  77449. /** @hidden */
  77450. _shouldRender(): boolean;
  77451. /**
  77452. * Gets the actual render size of the texture.
  77453. * @returns the width of the render size
  77454. */
  77455. getRenderSize(): number;
  77456. /**
  77457. * Gets the actual render width of the texture.
  77458. * @returns the width of the render size
  77459. */
  77460. getRenderWidth(): number;
  77461. /**
  77462. * Gets the actual render height of the texture.
  77463. * @returns the height of the render size
  77464. */
  77465. getRenderHeight(): number;
  77466. /**
  77467. * Get if the texture can be rescaled or not.
  77468. */
  77469. readonly canRescale: boolean;
  77470. /**
  77471. * Resize the texture using a ratio.
  77472. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77473. */
  77474. scale(ratio: number): void;
  77475. /**
  77476. * Get the texture reflection matrix used to rotate/transform the reflection.
  77477. * @returns the reflection matrix
  77478. */
  77479. getReflectionTextureMatrix(): Matrix;
  77480. /**
  77481. * Resize the texture to a new desired size.
  77482. * Be carrefull as it will recreate all the data in the new texture.
  77483. * @param size Define the new size. It can be:
  77484. * - a number for squared texture,
  77485. * - an object containing { width: number, height: number }
  77486. * - or an object containing a ratio { ratio: number }
  77487. */
  77488. resize(size: number | {
  77489. width: number;
  77490. height: number;
  77491. } | {
  77492. ratio: number;
  77493. }): void;
  77494. /**
  77495. * Renders all the objects from the render list into the texture.
  77496. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77497. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77498. */
  77499. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77500. private _bestReflectionRenderTargetDimension;
  77501. /**
  77502. * @hidden
  77503. * @param faceIndex face index to bind to if this is a cubetexture
  77504. */
  77505. _bindFrameBuffer(faceIndex?: number): void;
  77506. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77507. private renderToTarget;
  77508. /**
  77509. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77510. * This allowed control for front to back rendering or reversly depending of the special needs.
  77511. *
  77512. * @param renderingGroupId The rendering group id corresponding to its index
  77513. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77514. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77515. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77516. */
  77517. 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;
  77518. /**
  77519. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77520. *
  77521. * @param renderingGroupId The rendering group id corresponding to its index
  77522. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77523. */
  77524. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77525. /**
  77526. * Clones the texture.
  77527. * @returns the cloned texture
  77528. */
  77529. clone(): RenderTargetTexture;
  77530. /**
  77531. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77532. * @returns The JSON representation of the texture
  77533. */
  77534. serialize(): any;
  77535. /**
  77536. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77537. */
  77538. disposeFramebufferObjects(): void;
  77539. /**
  77540. * Dispose the texture and release its associated resources.
  77541. */
  77542. dispose(): void;
  77543. /** @hidden */
  77544. _rebuild(): void;
  77545. /**
  77546. * Clear the info related to rendering groups preventing retention point in material dispose.
  77547. */
  77548. freeRenderingGroups(): void;
  77549. /**
  77550. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77551. * @returns the view count
  77552. */
  77553. getViewCount(): number;
  77554. }
  77555. }
  77556. declare module BABYLON {
  77557. /**
  77558. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77559. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77560. * You can then easily use it as a reflectionTexture on a flat surface.
  77561. * In case the surface is not a plane, please consider relying on reflection probes.
  77562. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77563. */
  77564. export class MirrorTexture extends RenderTargetTexture {
  77565. private scene;
  77566. /**
  77567. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77568. * 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.
  77569. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77570. */
  77571. mirrorPlane: Plane;
  77572. /**
  77573. * Define the blur ratio used to blur the reflection if needed.
  77574. */
  77575. blurRatio: number;
  77576. /**
  77577. * Define the adaptive blur kernel used to blur the reflection if needed.
  77578. * This will autocompute the closest best match for the `blurKernel`
  77579. */
  77580. adaptiveBlurKernel: number;
  77581. /**
  77582. * Define the blur kernel used to blur the reflection if needed.
  77583. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77584. */
  77585. blurKernel: number;
  77586. /**
  77587. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  77588. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77589. */
  77590. blurKernelX: number;
  77591. /**
  77592. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  77593. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77594. */
  77595. blurKernelY: number;
  77596. private _autoComputeBlurKernel;
  77597. protected _onRatioRescale(): void;
  77598. private _updateGammaSpace;
  77599. private _imageProcessingConfigChangeObserver;
  77600. private _transformMatrix;
  77601. private _mirrorMatrix;
  77602. private _savedViewMatrix;
  77603. private _blurX;
  77604. private _blurY;
  77605. private _adaptiveBlurKernel;
  77606. private _blurKernelX;
  77607. private _blurKernelY;
  77608. private _blurRatio;
  77609. /**
  77610. * Instantiates a Mirror Texture.
  77611. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77612. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77613. * You can then easily use it as a reflectionTexture on a flat surface.
  77614. * In case the surface is not a plane, please consider relying on reflection probes.
  77615. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77616. * @param name
  77617. * @param size
  77618. * @param scene
  77619. * @param generateMipMaps
  77620. * @param type
  77621. * @param samplingMode
  77622. * @param generateDepthBuffer
  77623. */
  77624. constructor(name: string, size: number | {
  77625. width: number;
  77626. height: number;
  77627. } | {
  77628. ratio: number;
  77629. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  77630. private _preparePostProcesses;
  77631. /**
  77632. * Clone the mirror texture.
  77633. * @returns the cloned texture
  77634. */
  77635. clone(): MirrorTexture;
  77636. /**
  77637. * Serialize the texture to a JSON representation you could use in Parse later on
  77638. * @returns the serialized JSON representation
  77639. */
  77640. serialize(): any;
  77641. /**
  77642. * Dispose the texture and release its associated resources.
  77643. */
  77644. dispose(): void;
  77645. }
  77646. }
  77647. declare module BABYLON {
  77648. /**
  77649. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77650. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77651. */
  77652. export class Texture extends BaseTexture {
  77653. /** @hidden */
  77654. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  77655. /** @hidden */
  77656. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  77657. /** @hidden */
  77658. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  77659. /** nearest is mag = nearest and min = nearest and mip = linear */
  77660. static readonly NEAREST_SAMPLINGMODE: number;
  77661. /** nearest is mag = nearest and min = nearest and mip = linear */
  77662. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  77663. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77664. static readonly BILINEAR_SAMPLINGMODE: number;
  77665. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77666. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  77667. /** Trilinear is mag = linear and min = linear and mip = linear */
  77668. static readonly TRILINEAR_SAMPLINGMODE: number;
  77669. /** Trilinear is mag = linear and min = linear and mip = linear */
  77670. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  77671. /** mag = nearest and min = nearest and mip = nearest */
  77672. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  77673. /** mag = nearest and min = linear and mip = nearest */
  77674. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  77675. /** mag = nearest and min = linear and mip = linear */
  77676. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77677. /** mag = nearest and min = linear and mip = none */
  77678. static readonly NEAREST_LINEAR: number;
  77679. /** mag = nearest and min = nearest and mip = none */
  77680. static readonly NEAREST_NEAREST: number;
  77681. /** mag = linear and min = nearest and mip = nearest */
  77682. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77683. /** mag = linear and min = nearest and mip = linear */
  77684. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77685. /** mag = linear and min = linear and mip = none */
  77686. static readonly LINEAR_LINEAR: number;
  77687. /** mag = linear and min = nearest and mip = none */
  77688. static readonly LINEAR_NEAREST: number;
  77689. /** Explicit coordinates mode */
  77690. static readonly EXPLICIT_MODE: number;
  77691. /** Spherical coordinates mode */
  77692. static readonly SPHERICAL_MODE: number;
  77693. /** Planar coordinates mode */
  77694. static readonly PLANAR_MODE: number;
  77695. /** Cubic coordinates mode */
  77696. static readonly CUBIC_MODE: number;
  77697. /** Projection coordinates mode */
  77698. static readonly PROJECTION_MODE: number;
  77699. /** Inverse Cubic coordinates mode */
  77700. static readonly SKYBOX_MODE: number;
  77701. /** Inverse Cubic coordinates mode */
  77702. static readonly INVCUBIC_MODE: number;
  77703. /** Equirectangular coordinates mode */
  77704. static readonly EQUIRECTANGULAR_MODE: number;
  77705. /** Equirectangular Fixed coordinates mode */
  77706. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77707. /** Equirectangular Fixed Mirrored coordinates mode */
  77708. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77709. /** Texture is not repeating outside of 0..1 UVs */
  77710. static readonly CLAMP_ADDRESSMODE: number;
  77711. /** Texture is repeating outside of 0..1 UVs */
  77712. static readonly WRAP_ADDRESSMODE: number;
  77713. /** Texture is repeating and mirrored */
  77714. static readonly MIRROR_ADDRESSMODE: number;
  77715. /**
  77716. * 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
  77717. */
  77718. static UseSerializedUrlIfAny: boolean;
  77719. /**
  77720. * Define the url of the texture.
  77721. */
  77722. url: Nullable<string>;
  77723. /**
  77724. * Define an offset on the texture to offset the u coordinates of the UVs
  77725. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77726. */
  77727. uOffset: number;
  77728. /**
  77729. * Define an offset on the texture to offset the v coordinates of the UVs
  77730. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77731. */
  77732. vOffset: number;
  77733. /**
  77734. * Define an offset on the texture to scale the u coordinates of the UVs
  77735. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77736. */
  77737. uScale: number;
  77738. /**
  77739. * Define an offset on the texture to scale the v coordinates of the UVs
  77740. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77741. */
  77742. vScale: number;
  77743. /**
  77744. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77745. * @see http://doc.babylonjs.com/how_to/more_materials
  77746. */
  77747. uAng: number;
  77748. /**
  77749. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77750. * @see http://doc.babylonjs.com/how_to/more_materials
  77751. */
  77752. vAng: number;
  77753. /**
  77754. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77755. * @see http://doc.babylonjs.com/how_to/more_materials
  77756. */
  77757. wAng: number;
  77758. /**
  77759. * Defines the center of rotation (U)
  77760. */
  77761. uRotationCenter: number;
  77762. /**
  77763. * Defines the center of rotation (V)
  77764. */
  77765. vRotationCenter: number;
  77766. /**
  77767. * Defines the center of rotation (W)
  77768. */
  77769. wRotationCenter: number;
  77770. /**
  77771. * Are mip maps generated for this texture or not.
  77772. */
  77773. readonly noMipmap: boolean;
  77774. /**
  77775. * List of inspectable custom properties (used by the Inspector)
  77776. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77777. */
  77778. inspectableCustomProperties: Nullable<IInspectable[]>;
  77779. private _noMipmap;
  77780. /** @hidden */
  77781. _invertY: boolean;
  77782. private _rowGenerationMatrix;
  77783. private _cachedTextureMatrix;
  77784. private _projectionModeMatrix;
  77785. private _t0;
  77786. private _t1;
  77787. private _t2;
  77788. private _cachedUOffset;
  77789. private _cachedVOffset;
  77790. private _cachedUScale;
  77791. private _cachedVScale;
  77792. private _cachedUAng;
  77793. private _cachedVAng;
  77794. private _cachedWAng;
  77795. private _cachedProjectionMatrixId;
  77796. private _cachedCoordinatesMode;
  77797. /** @hidden */
  77798. protected _initialSamplingMode: number;
  77799. /** @hidden */
  77800. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77801. private _deleteBuffer;
  77802. protected _format: Nullable<number>;
  77803. private _delayedOnLoad;
  77804. private _delayedOnError;
  77805. /**
  77806. * Observable triggered once the texture has been loaded.
  77807. */
  77808. onLoadObservable: Observable<Texture>;
  77809. protected _isBlocking: boolean;
  77810. /**
  77811. * Is the texture preventing material to render while loading.
  77812. * If false, a default texture will be used instead of the loading one during the preparation step.
  77813. */
  77814. isBlocking: boolean;
  77815. /**
  77816. * Get the current sampling mode associated with the texture.
  77817. */
  77818. readonly samplingMode: number;
  77819. /**
  77820. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77821. */
  77822. readonly invertY: boolean;
  77823. /**
  77824. * Instantiates a new texture.
  77825. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77826. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77827. * @param url define the url of the picture to load as a texture
  77828. * @param scene define the scene the texture will belong to
  77829. * @param noMipmap define if the texture will require mip maps or not
  77830. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77831. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77832. * @param onLoad define a callback triggered when the texture has been loaded
  77833. * @param onError define a callback triggered when an error occurred during the loading session
  77834. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77835. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77836. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77837. */
  77838. 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);
  77839. /**
  77840. * Update the url (and optional buffer) of this texture if url was null during construction.
  77841. * @param url the url of the texture
  77842. * @param buffer the buffer of the texture (defaults to null)
  77843. * @param onLoad callback called when the texture is loaded (defaults to null)
  77844. */
  77845. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77846. /**
  77847. * Finish the loading sequence of a texture flagged as delayed load.
  77848. * @hidden
  77849. */
  77850. delayLoad(): void;
  77851. private _prepareRowForTextureGeneration;
  77852. /**
  77853. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77854. * @returns the transform matrix of the texture.
  77855. */
  77856. getTextureMatrix(): Matrix;
  77857. /**
  77858. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77859. * @returns The reflection texture transform
  77860. */
  77861. getReflectionTextureMatrix(): Matrix;
  77862. /**
  77863. * Clones the texture.
  77864. * @returns the cloned texture
  77865. */
  77866. clone(): Texture;
  77867. /**
  77868. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77869. * @returns The JSON representation of the texture
  77870. */
  77871. serialize(): any;
  77872. /**
  77873. * Get the current class name of the texture useful for serialization or dynamic coding.
  77874. * @returns "Texture"
  77875. */
  77876. getClassName(): string;
  77877. /**
  77878. * Dispose the texture and release its associated resources.
  77879. */
  77880. dispose(): void;
  77881. /**
  77882. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  77883. * @param parsedTexture Define the JSON representation of the texture
  77884. * @param scene Define the scene the parsed texture should be instantiated in
  77885. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  77886. * @returns The parsed texture if successful
  77887. */
  77888. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  77889. /**
  77890. * Creates a texture from its base 64 representation.
  77891. * @param data Define the base64 payload without the data: prefix
  77892. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77893. * @param scene Define the scene the texture should belong to
  77894. * @param noMipmap Forces the texture to not create mip map information if true
  77895. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77896. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77897. * @param onLoad define a callback triggered when the texture has been loaded
  77898. * @param onError define a callback triggered when an error occurred during the loading session
  77899. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77900. * @returns the created texture
  77901. */
  77902. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  77903. /**
  77904. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  77905. * @param data Define the base64 payload without the data: prefix
  77906. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77907. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77908. * @param scene Define the scene the texture should belong to
  77909. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77910. * @param noMipmap Forces the texture to not create mip map information if true
  77911. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77912. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77913. * @param onLoad define a callback triggered when the texture has been loaded
  77914. * @param onError define a callback triggered when an error occurred during the loading session
  77915. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77916. * @returns the created texture
  77917. */
  77918. 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;
  77919. }
  77920. }
  77921. declare module BABYLON {
  77922. interface Engine {
  77923. /**
  77924. * Creates a raw texture
  77925. * @param data defines the data to store in the texture
  77926. * @param width defines the width of the texture
  77927. * @param height defines the height of the texture
  77928. * @param format defines the format of the data
  77929. * @param generateMipMaps defines if the engine should generate the mip levels
  77930. * @param invertY defines if data must be stored with Y axis inverted
  77931. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77932. * @param compression defines the compression used (null by default)
  77933. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77934. * @returns the raw texture inside an InternalTexture
  77935. */
  77936. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  77937. /**
  77938. * Update a raw texture
  77939. * @param texture defines the texture to update
  77940. * @param data defines the data to store in the texture
  77941. * @param format defines the format of the data
  77942. * @param invertY defines if data must be stored with Y axis inverted
  77943. */
  77944. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77945. /**
  77946. * Update a raw texture
  77947. * @param texture defines the texture to update
  77948. * @param data defines the data to store in the texture
  77949. * @param format defines the format of the data
  77950. * @param invertY defines if data must be stored with Y axis inverted
  77951. * @param compression defines the compression used (null by default)
  77952. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77953. */
  77954. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  77955. /**
  77956. * Creates a new raw cube texture
  77957. * @param data defines the array of data to use to create each face
  77958. * @param size defines the size of the textures
  77959. * @param format defines the format of the data
  77960. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77961. * @param generateMipMaps defines if the engine should generate the mip levels
  77962. * @param invertY defines if data must be stored with Y axis inverted
  77963. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77964. * @param compression defines the compression used (null by default)
  77965. * @returns the cube texture as an InternalTexture
  77966. */
  77967. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  77968. /**
  77969. * Update a raw cube texture
  77970. * @param texture defines the texture to udpdate
  77971. * @param data defines the data to store
  77972. * @param format defines the data format
  77973. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77974. * @param invertY defines if data must be stored with Y axis inverted
  77975. */
  77976. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  77977. /**
  77978. * Update a raw cube texture
  77979. * @param texture defines the texture to udpdate
  77980. * @param data defines the data to store
  77981. * @param format defines the data format
  77982. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77983. * @param invertY defines if data must be stored with Y axis inverted
  77984. * @param compression defines the compression used (null by default)
  77985. */
  77986. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  77987. /**
  77988. * Update a raw cube texture
  77989. * @param texture defines the texture to udpdate
  77990. * @param data defines the data to store
  77991. * @param format defines the data format
  77992. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77993. * @param invertY defines if data must be stored with Y axis inverted
  77994. * @param compression defines the compression used (null by default)
  77995. * @param level defines which level of the texture to update
  77996. */
  77997. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  77998. /**
  77999. * Creates a new raw cube texture from a specified url
  78000. * @param url defines the url where the data is located
  78001. * @param scene defines the current scene
  78002. * @param size defines the size of the textures
  78003. * @param format defines the format of the data
  78004. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78005. * @param noMipmap defines if the engine should avoid generating the mip levels
  78006. * @param callback defines a callback used to extract texture data from loaded data
  78007. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78008. * @param onLoad defines a callback called when texture is loaded
  78009. * @param onError defines a callback called if there is an error
  78010. * @returns the cube texture as an InternalTexture
  78011. */
  78012. 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;
  78013. /**
  78014. * Creates a new raw cube texture from a specified url
  78015. * @param url defines the url where the data is located
  78016. * @param scene defines the current scene
  78017. * @param size defines the size of the textures
  78018. * @param format defines the format of the data
  78019. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78020. * @param noMipmap defines if the engine should avoid generating the mip levels
  78021. * @param callback defines a callback used to extract texture data from loaded data
  78022. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78023. * @param onLoad defines a callback called when texture is loaded
  78024. * @param onError defines a callback called if there is an error
  78025. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78026. * @param invertY defines if data must be stored with Y axis inverted
  78027. * @returns the cube texture as an InternalTexture
  78028. */
  78029. 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;
  78030. /**
  78031. * Creates a new raw 3D texture
  78032. * @param data defines the data used to create the texture
  78033. * @param width defines the width of the texture
  78034. * @param height defines the height of the texture
  78035. * @param depth defines the depth of the texture
  78036. * @param format defines the format of the texture
  78037. * @param generateMipMaps defines if the engine must generate mip levels
  78038. * @param invertY defines if data must be stored with Y axis inverted
  78039. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78040. * @param compression defines the compressed used (can be null)
  78041. * @param textureType defines the compressed used (can be null)
  78042. * @returns a new raw 3D texture (stored in an InternalTexture)
  78043. */
  78044. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78045. /**
  78046. * Update a raw 3D texture
  78047. * @param texture defines the texture to update
  78048. * @param data defines the data to store
  78049. * @param format defines the data format
  78050. * @param invertY defines if data must be stored with Y axis inverted
  78051. */
  78052. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78053. /**
  78054. * Update a raw 3D texture
  78055. * @param texture defines the texture to update
  78056. * @param data defines the data to store
  78057. * @param format defines the data format
  78058. * @param invertY defines if data must be stored with Y axis inverted
  78059. * @param compression defines the used compression (can be null)
  78060. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78061. */
  78062. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78063. }
  78064. }
  78065. declare module BABYLON {
  78066. /**
  78067. * Raw texture can help creating a texture directly from an array of data.
  78068. * This can be super useful if you either get the data from an uncompressed source or
  78069. * if you wish to create your texture pixel by pixel.
  78070. */
  78071. export class RawTexture extends Texture {
  78072. /**
  78073. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78074. */
  78075. format: number;
  78076. private _engine;
  78077. /**
  78078. * Instantiates a new RawTexture.
  78079. * Raw texture can help creating a texture directly from an array of data.
  78080. * This can be super useful if you either get the data from an uncompressed source or
  78081. * if you wish to create your texture pixel by pixel.
  78082. * @param data define the array of data to use to create the texture
  78083. * @param width define the width of the texture
  78084. * @param height define the height of the texture
  78085. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78086. * @param scene define the scene the texture belongs to
  78087. * @param generateMipMaps define whether mip maps should be generated or not
  78088. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78089. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78090. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78091. */
  78092. constructor(data: ArrayBufferView, width: number, height: number,
  78093. /**
  78094. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78095. */
  78096. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78097. /**
  78098. * Updates the texture underlying data.
  78099. * @param data Define the new data of the texture
  78100. */
  78101. update(data: ArrayBufferView): void;
  78102. /**
  78103. * Creates a luminance texture from some data.
  78104. * @param data Define the texture data
  78105. * @param width Define the width of the texture
  78106. * @param height Define the height of the texture
  78107. * @param scene Define the scene the texture belongs to
  78108. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78109. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78110. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78111. * @returns the luminance texture
  78112. */
  78113. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78114. /**
  78115. * Creates a luminance alpha texture from some data.
  78116. * @param data Define the texture data
  78117. * @param width Define the width of the texture
  78118. * @param height Define the height of the texture
  78119. * @param scene Define the scene the texture belongs to
  78120. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78121. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78122. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78123. * @returns the luminance alpha texture
  78124. */
  78125. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78126. /**
  78127. * Creates an alpha texture from some data.
  78128. * @param data Define the texture data
  78129. * @param width Define the width of the texture
  78130. * @param height Define the height of the texture
  78131. * @param scene Define the scene the texture belongs to
  78132. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78133. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78134. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78135. * @returns the alpha texture
  78136. */
  78137. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78138. /**
  78139. * Creates a RGB texture from some data.
  78140. * @param data Define the texture data
  78141. * @param width Define the width of the texture
  78142. * @param height Define the height of the texture
  78143. * @param scene Define the scene the texture belongs to
  78144. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78145. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78146. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78147. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78148. * @returns the RGB alpha texture
  78149. */
  78150. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78151. /**
  78152. * Creates a RGBA texture from some data.
  78153. * @param data Define the texture data
  78154. * @param width Define the width of the texture
  78155. * @param height Define the height of the texture
  78156. * @param scene Define the scene the texture belongs to
  78157. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78158. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78159. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78160. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78161. * @returns the RGBA texture
  78162. */
  78163. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78164. /**
  78165. * Creates a R texture from some data.
  78166. * @param data Define the texture data
  78167. * @param width Define the width of the texture
  78168. * @param height Define the height of the texture
  78169. * @param scene Define the scene the texture belongs to
  78170. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78171. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78172. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78173. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78174. * @returns the R texture
  78175. */
  78176. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78177. }
  78178. }
  78179. declare module BABYLON {
  78180. /**
  78181. * Defines a runtime animation
  78182. */
  78183. export class RuntimeAnimation {
  78184. private _events;
  78185. /**
  78186. * The current frame of the runtime animation
  78187. */
  78188. private _currentFrame;
  78189. /**
  78190. * The animation used by the runtime animation
  78191. */
  78192. private _animation;
  78193. /**
  78194. * The target of the runtime animation
  78195. */
  78196. private _target;
  78197. /**
  78198. * The initiating animatable
  78199. */
  78200. private _host;
  78201. /**
  78202. * The original value of the runtime animation
  78203. */
  78204. private _originalValue;
  78205. /**
  78206. * The original blend value of the runtime animation
  78207. */
  78208. private _originalBlendValue;
  78209. /**
  78210. * The offsets cache of the runtime animation
  78211. */
  78212. private _offsetsCache;
  78213. /**
  78214. * The high limits cache of the runtime animation
  78215. */
  78216. private _highLimitsCache;
  78217. /**
  78218. * Specifies if the runtime animation has been stopped
  78219. */
  78220. private _stopped;
  78221. /**
  78222. * The blending factor of the runtime animation
  78223. */
  78224. private _blendingFactor;
  78225. /**
  78226. * The BabylonJS scene
  78227. */
  78228. private _scene;
  78229. /**
  78230. * The current value of the runtime animation
  78231. */
  78232. private _currentValue;
  78233. /** @hidden */
  78234. _animationState: _IAnimationState;
  78235. /**
  78236. * The active target of the runtime animation
  78237. */
  78238. private _activeTargets;
  78239. private _currentActiveTarget;
  78240. private _directTarget;
  78241. /**
  78242. * The target path of the runtime animation
  78243. */
  78244. private _targetPath;
  78245. /**
  78246. * The weight of the runtime animation
  78247. */
  78248. private _weight;
  78249. /**
  78250. * The ratio offset of the runtime animation
  78251. */
  78252. private _ratioOffset;
  78253. /**
  78254. * The previous delay of the runtime animation
  78255. */
  78256. private _previousDelay;
  78257. /**
  78258. * The previous ratio of the runtime animation
  78259. */
  78260. private _previousRatio;
  78261. private _enableBlending;
  78262. private _keys;
  78263. private _minFrame;
  78264. private _maxFrame;
  78265. private _minValue;
  78266. private _maxValue;
  78267. private _targetIsArray;
  78268. /**
  78269. * Gets the current frame of the runtime animation
  78270. */
  78271. readonly currentFrame: number;
  78272. /**
  78273. * Gets the weight of the runtime animation
  78274. */
  78275. readonly weight: number;
  78276. /**
  78277. * Gets the current value of the runtime animation
  78278. */
  78279. readonly currentValue: any;
  78280. /**
  78281. * Gets the target path of the runtime animation
  78282. */
  78283. readonly targetPath: string;
  78284. /**
  78285. * Gets the actual target of the runtime animation
  78286. */
  78287. readonly target: any;
  78288. /** @hidden */
  78289. _onLoop: () => void;
  78290. /**
  78291. * Create a new RuntimeAnimation object
  78292. * @param target defines the target of the animation
  78293. * @param animation defines the source animation object
  78294. * @param scene defines the hosting scene
  78295. * @param host defines the initiating Animatable
  78296. */
  78297. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78298. private _preparePath;
  78299. /**
  78300. * Gets the animation from the runtime animation
  78301. */
  78302. readonly animation: Animation;
  78303. /**
  78304. * Resets the runtime animation to the beginning
  78305. * @param restoreOriginal defines whether to restore the target property to the original value
  78306. */
  78307. reset(restoreOriginal?: boolean): void;
  78308. /**
  78309. * Specifies if the runtime animation is stopped
  78310. * @returns Boolean specifying if the runtime animation is stopped
  78311. */
  78312. isStopped(): boolean;
  78313. /**
  78314. * Disposes of the runtime animation
  78315. */
  78316. dispose(): void;
  78317. /**
  78318. * Apply the interpolated value to the target
  78319. * @param currentValue defines the value computed by the animation
  78320. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78321. */
  78322. setValue(currentValue: any, weight: number): void;
  78323. private _getOriginalValues;
  78324. private _setValue;
  78325. /**
  78326. * Gets the loop pmode of the runtime animation
  78327. * @returns Loop Mode
  78328. */
  78329. private _getCorrectLoopMode;
  78330. /**
  78331. * Move the current animation to a given frame
  78332. * @param frame defines the frame to move to
  78333. */
  78334. goToFrame(frame: number): void;
  78335. /**
  78336. * @hidden Internal use only
  78337. */
  78338. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78339. /**
  78340. * Execute the current animation
  78341. * @param delay defines the delay to add to the current frame
  78342. * @param from defines the lower bound of the animation range
  78343. * @param to defines the upper bound of the animation range
  78344. * @param loop defines if the current animation must loop
  78345. * @param speedRatio defines the current speed ratio
  78346. * @param weight defines the weight of the animation (default is -1 so no weight)
  78347. * @param onLoop optional callback called when animation loops
  78348. * @returns a boolean indicating if the animation is running
  78349. */
  78350. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78351. }
  78352. }
  78353. declare module BABYLON {
  78354. /**
  78355. * Class used to store an actual running animation
  78356. */
  78357. export class Animatable {
  78358. /** defines the target object */
  78359. target: any;
  78360. /** defines the starting frame number (default is 0) */
  78361. fromFrame: number;
  78362. /** defines the ending frame number (default is 100) */
  78363. toFrame: number;
  78364. /** defines if the animation must loop (default is false) */
  78365. loopAnimation: boolean;
  78366. /** defines a callback to call when animation ends if it is not looping */
  78367. onAnimationEnd?: (() => void) | null | undefined;
  78368. /** defines a callback to call when animation loops */
  78369. onAnimationLoop?: (() => void) | null | undefined;
  78370. private _localDelayOffset;
  78371. private _pausedDelay;
  78372. private _runtimeAnimations;
  78373. private _paused;
  78374. private _scene;
  78375. private _speedRatio;
  78376. private _weight;
  78377. private _syncRoot;
  78378. /**
  78379. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78380. * This will only apply for non looping animation (default is true)
  78381. */
  78382. disposeOnEnd: boolean;
  78383. /**
  78384. * Gets a boolean indicating if the animation has started
  78385. */
  78386. animationStarted: boolean;
  78387. /**
  78388. * Observer raised when the animation ends
  78389. */
  78390. onAnimationEndObservable: Observable<Animatable>;
  78391. /**
  78392. * Observer raised when the animation loops
  78393. */
  78394. onAnimationLoopObservable: Observable<Animatable>;
  78395. /**
  78396. * Gets the root Animatable used to synchronize and normalize animations
  78397. */
  78398. readonly syncRoot: Nullable<Animatable>;
  78399. /**
  78400. * Gets the current frame of the first RuntimeAnimation
  78401. * Used to synchronize Animatables
  78402. */
  78403. readonly masterFrame: number;
  78404. /**
  78405. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78406. */
  78407. weight: number;
  78408. /**
  78409. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78410. */
  78411. speedRatio: number;
  78412. /**
  78413. * Creates a new Animatable
  78414. * @param scene defines the hosting scene
  78415. * @param target defines the target object
  78416. * @param fromFrame defines the starting frame number (default is 0)
  78417. * @param toFrame defines the ending frame number (default is 100)
  78418. * @param loopAnimation defines if the animation must loop (default is false)
  78419. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78420. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78421. * @param animations defines a group of animation to add to the new Animatable
  78422. * @param onAnimationLoop defines a callback to call when animation loops
  78423. */
  78424. constructor(scene: Scene,
  78425. /** defines the target object */
  78426. target: any,
  78427. /** defines the starting frame number (default is 0) */
  78428. fromFrame?: number,
  78429. /** defines the ending frame number (default is 100) */
  78430. toFrame?: number,
  78431. /** defines if the animation must loop (default is false) */
  78432. loopAnimation?: boolean, speedRatio?: number,
  78433. /** defines a callback to call when animation ends if it is not looping */
  78434. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78435. /** defines a callback to call when animation loops */
  78436. onAnimationLoop?: (() => void) | null | undefined);
  78437. /**
  78438. * Synchronize and normalize current Animatable with a source Animatable
  78439. * This is useful when using animation weights and when animations are not of the same length
  78440. * @param root defines the root Animatable to synchronize with
  78441. * @returns the current Animatable
  78442. */
  78443. syncWith(root: Animatable): Animatable;
  78444. /**
  78445. * Gets the list of runtime animations
  78446. * @returns an array of RuntimeAnimation
  78447. */
  78448. getAnimations(): RuntimeAnimation[];
  78449. /**
  78450. * Adds more animations to the current animatable
  78451. * @param target defines the target of the animations
  78452. * @param animations defines the new animations to add
  78453. */
  78454. appendAnimations(target: any, animations: Animation[]): void;
  78455. /**
  78456. * Gets the source animation for a specific property
  78457. * @param property defines the propertyu to look for
  78458. * @returns null or the source animation for the given property
  78459. */
  78460. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78461. /**
  78462. * Gets the runtime animation for a specific property
  78463. * @param property defines the propertyu to look for
  78464. * @returns null or the runtime animation for the given property
  78465. */
  78466. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78467. /**
  78468. * Resets the animatable to its original state
  78469. */
  78470. reset(): void;
  78471. /**
  78472. * Allows the animatable to blend with current running animations
  78473. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78474. * @param blendingSpeed defines the blending speed to use
  78475. */
  78476. enableBlending(blendingSpeed: number): void;
  78477. /**
  78478. * Disable animation blending
  78479. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78480. */
  78481. disableBlending(): void;
  78482. /**
  78483. * Jump directly to a given frame
  78484. * @param frame defines the frame to jump to
  78485. */
  78486. goToFrame(frame: number): void;
  78487. /**
  78488. * Pause the animation
  78489. */
  78490. pause(): void;
  78491. /**
  78492. * Restart the animation
  78493. */
  78494. restart(): void;
  78495. private _raiseOnAnimationEnd;
  78496. /**
  78497. * Stop and delete the current animation
  78498. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78499. * @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)
  78500. */
  78501. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78502. /**
  78503. * Wait asynchronously for the animation to end
  78504. * @returns a promise which will be fullfilled when the animation ends
  78505. */
  78506. waitAsync(): Promise<Animatable>;
  78507. /** @hidden */
  78508. _animate(delay: number): boolean;
  78509. }
  78510. interface Scene {
  78511. /** @hidden */
  78512. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78513. /** @hidden */
  78514. _processLateAnimationBindingsForMatrices(holder: {
  78515. totalWeight: number;
  78516. animations: RuntimeAnimation[];
  78517. originalValue: Matrix;
  78518. }): any;
  78519. /** @hidden */
  78520. _processLateAnimationBindingsForQuaternions(holder: {
  78521. totalWeight: number;
  78522. animations: RuntimeAnimation[];
  78523. originalValue: Quaternion;
  78524. }, refQuaternion: Quaternion): Quaternion;
  78525. /** @hidden */
  78526. _processLateAnimationBindings(): void;
  78527. /**
  78528. * Will start the animation sequence of a given target
  78529. * @param target defines the target
  78530. * @param from defines from which frame should animation start
  78531. * @param to defines until which frame should animation run.
  78532. * @param weight defines the weight to apply to the animation (1.0 by default)
  78533. * @param loop defines if the animation loops
  78534. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78535. * @param onAnimationEnd defines the function to be executed when the animation ends
  78536. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78537. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78538. * @param onAnimationLoop defines the callback to call when an animation loops
  78539. * @returns the animatable object created for this animation
  78540. */
  78541. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78542. /**
  78543. * Will start the animation sequence of a given target
  78544. * @param target defines the target
  78545. * @param from defines from which frame should animation start
  78546. * @param to defines until which frame should animation run.
  78547. * @param loop defines if the animation loops
  78548. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78549. * @param onAnimationEnd defines the function to be executed when the animation ends
  78550. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78551. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78552. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78553. * @param onAnimationLoop defines the callback to call when an animation loops
  78554. * @returns the animatable object created for this animation
  78555. */
  78556. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78557. /**
  78558. * Will start the animation sequence of a given target and its hierarchy
  78559. * @param target defines the target
  78560. * @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.
  78561. * @param from defines from which frame should animation start
  78562. * @param to defines until which frame should animation run.
  78563. * @param loop defines if the animation loops
  78564. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78565. * @param onAnimationEnd defines the function to be executed when the animation ends
  78566. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78567. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78568. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78569. * @param onAnimationLoop defines the callback to call when an animation loops
  78570. * @returns the list of created animatables
  78571. */
  78572. 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[];
  78573. /**
  78574. * Begin a new animation on a given node
  78575. * @param target defines the target where the animation will take place
  78576. * @param animations defines the list of animations to start
  78577. * @param from defines the initial value
  78578. * @param to defines the final value
  78579. * @param loop defines if you want animation to loop (off by default)
  78580. * @param speedRatio defines the speed ratio to apply to all animations
  78581. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78582. * @param onAnimationLoop defines the callback to call when an animation loops
  78583. * @returns the list of created animatables
  78584. */
  78585. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78586. /**
  78587. * Begin a new animation on a given node and its hierarchy
  78588. * @param target defines the root node where the animation will take place
  78589. * @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.
  78590. * @param animations defines the list of animations to start
  78591. * @param from defines the initial value
  78592. * @param to defines the final value
  78593. * @param loop defines if you want animation to loop (off by default)
  78594. * @param speedRatio defines the speed ratio to apply to all animations
  78595. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78596. * @param onAnimationLoop defines the callback to call when an animation loops
  78597. * @returns the list of animatables created for all nodes
  78598. */
  78599. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78600. /**
  78601. * Gets the animatable associated with a specific target
  78602. * @param target defines the target of the animatable
  78603. * @returns the required animatable if found
  78604. */
  78605. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78606. /**
  78607. * Gets all animatables associated with a given target
  78608. * @param target defines the target to look animatables for
  78609. * @returns an array of Animatables
  78610. */
  78611. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78612. /**
  78613. * Will stop the animation of the given target
  78614. * @param target - the target
  78615. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  78616. * @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)
  78617. */
  78618. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  78619. /**
  78620. * Stops and removes all animations that have been applied to the scene
  78621. */
  78622. stopAllAnimations(): void;
  78623. }
  78624. interface Bone {
  78625. /**
  78626. * Copy an animation range from another bone
  78627. * @param source defines the source bone
  78628. * @param rangeName defines the range name to copy
  78629. * @param frameOffset defines the frame offset
  78630. * @param rescaleAsRequired defines if rescaling must be applied if required
  78631. * @param skelDimensionsRatio defines the scaling ratio
  78632. * @returns true if operation was successful
  78633. */
  78634. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78635. }
  78636. }
  78637. declare module BABYLON {
  78638. /**
  78639. * Class used to handle skinning animations
  78640. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78641. */
  78642. export class Skeleton implements IAnimatable {
  78643. /** defines the skeleton name */
  78644. name: string;
  78645. /** defines the skeleton Id */
  78646. id: string;
  78647. /**
  78648. * Defines the list of child bones
  78649. */
  78650. bones: Bone[];
  78651. /**
  78652. * Defines an estimate of the dimension of the skeleton at rest
  78653. */
  78654. dimensionsAtRest: Vector3;
  78655. /**
  78656. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78657. */
  78658. needInitialSkinMatrix: boolean;
  78659. /**
  78660. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78661. */
  78662. overrideMesh: Nullable<AbstractMesh>;
  78663. /**
  78664. * Gets the list of animations attached to this skeleton
  78665. */
  78666. animations: Array<Animation>;
  78667. private _scene;
  78668. private _isDirty;
  78669. private _transformMatrices;
  78670. private _transformMatrixTexture;
  78671. private _meshesWithPoseMatrix;
  78672. private _animatables;
  78673. private _identity;
  78674. private _synchronizedWithMesh;
  78675. private _ranges;
  78676. private _lastAbsoluteTransformsUpdateId;
  78677. private _canUseTextureForBones;
  78678. private _uniqueId;
  78679. /** @hidden */
  78680. _numBonesWithLinkedTransformNode: number;
  78681. /**
  78682. * Specifies if the skeleton should be serialized
  78683. */
  78684. doNotSerialize: boolean;
  78685. private _useTextureToStoreBoneMatrices;
  78686. /**
  78687. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78688. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  78689. */
  78690. useTextureToStoreBoneMatrices: boolean;
  78691. private _animationPropertiesOverride;
  78692. /**
  78693. * Gets or sets the animation properties override
  78694. */
  78695. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78696. /**
  78697. * List of inspectable custom properties (used by the Inspector)
  78698. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78699. */
  78700. inspectableCustomProperties: IInspectable[];
  78701. /**
  78702. * An observable triggered before computing the skeleton's matrices
  78703. */
  78704. onBeforeComputeObservable: Observable<Skeleton>;
  78705. /**
  78706. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78707. */
  78708. readonly isUsingTextureForMatrices: boolean;
  78709. /**
  78710. * Gets the unique ID of this skeleton
  78711. */
  78712. readonly uniqueId: number;
  78713. /**
  78714. * Creates a new skeleton
  78715. * @param name defines the skeleton name
  78716. * @param id defines the skeleton Id
  78717. * @param scene defines the hosting scene
  78718. */
  78719. constructor(
  78720. /** defines the skeleton name */
  78721. name: string,
  78722. /** defines the skeleton Id */
  78723. id: string, scene: Scene);
  78724. /**
  78725. * Gets the current object class name.
  78726. * @return the class name
  78727. */
  78728. getClassName(): string;
  78729. /**
  78730. * Returns an array containing the root bones
  78731. * @returns an array containing the root bones
  78732. */
  78733. getChildren(): Array<Bone>;
  78734. /**
  78735. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78736. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78737. * @returns a Float32Array containing matrices data
  78738. */
  78739. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78740. /**
  78741. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78742. * @returns a raw texture containing the data
  78743. */
  78744. getTransformMatrixTexture(): Nullable<RawTexture>;
  78745. /**
  78746. * Gets the current hosting scene
  78747. * @returns a scene object
  78748. */
  78749. getScene(): Scene;
  78750. /**
  78751. * Gets a string representing the current skeleton data
  78752. * @param fullDetails defines a boolean indicating if we want a verbose version
  78753. * @returns a string representing the current skeleton data
  78754. */
  78755. toString(fullDetails?: boolean): string;
  78756. /**
  78757. * Get bone's index searching by name
  78758. * @param name defines bone's name to search for
  78759. * @return the indice of the bone. Returns -1 if not found
  78760. */
  78761. getBoneIndexByName(name: string): number;
  78762. /**
  78763. * Creater a new animation range
  78764. * @param name defines the name of the range
  78765. * @param from defines the start key
  78766. * @param to defines the end key
  78767. */
  78768. createAnimationRange(name: string, from: number, to: number): void;
  78769. /**
  78770. * Delete a specific animation range
  78771. * @param name defines the name of the range
  78772. * @param deleteFrames defines if frames must be removed as well
  78773. */
  78774. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78775. /**
  78776. * Gets a specific animation range
  78777. * @param name defines the name of the range to look for
  78778. * @returns the requested animation range or null if not found
  78779. */
  78780. getAnimationRange(name: string): Nullable<AnimationRange>;
  78781. /**
  78782. * Gets the list of all animation ranges defined on this skeleton
  78783. * @returns an array
  78784. */
  78785. getAnimationRanges(): Nullable<AnimationRange>[];
  78786. /**
  78787. * Copy animation range from a source skeleton.
  78788. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78789. * @param source defines the source skeleton
  78790. * @param name defines the name of the range to copy
  78791. * @param rescaleAsRequired defines if rescaling must be applied if required
  78792. * @returns true if operation was successful
  78793. */
  78794. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78795. /**
  78796. * Forces the skeleton to go to rest pose
  78797. */
  78798. returnToRest(): void;
  78799. private _getHighestAnimationFrame;
  78800. /**
  78801. * Begin a specific animation range
  78802. * @param name defines the name of the range to start
  78803. * @param loop defines if looping must be turned on (false by default)
  78804. * @param speedRatio defines the speed ratio to apply (1 by default)
  78805. * @param onAnimationEnd defines a callback which will be called when animation will end
  78806. * @returns a new animatable
  78807. */
  78808. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78809. /** @hidden */
  78810. _markAsDirty(): void;
  78811. /** @hidden */
  78812. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78813. /** @hidden */
  78814. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78815. private _computeTransformMatrices;
  78816. /**
  78817. * Build all resources required to render a skeleton
  78818. */
  78819. prepare(): void;
  78820. /**
  78821. * Gets the list of animatables currently running for this skeleton
  78822. * @returns an array of animatables
  78823. */
  78824. getAnimatables(): IAnimatable[];
  78825. /**
  78826. * Clone the current skeleton
  78827. * @param name defines the name of the new skeleton
  78828. * @param id defines the id of the new skeleton
  78829. * @returns the new skeleton
  78830. */
  78831. clone(name: string, id: string): Skeleton;
  78832. /**
  78833. * Enable animation blending for this skeleton
  78834. * @param blendingSpeed defines the blending speed to apply
  78835. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78836. */
  78837. enableBlending(blendingSpeed?: number): void;
  78838. /**
  78839. * Releases all resources associated with the current skeleton
  78840. */
  78841. dispose(): void;
  78842. /**
  78843. * Serialize the skeleton in a JSON object
  78844. * @returns a JSON object
  78845. */
  78846. serialize(): any;
  78847. /**
  78848. * Creates a new skeleton from serialized data
  78849. * @param parsedSkeleton defines the serialized data
  78850. * @param scene defines the hosting scene
  78851. * @returns a new skeleton
  78852. */
  78853. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78854. /**
  78855. * Compute all node absolute transforms
  78856. * @param forceUpdate defines if computation must be done even if cache is up to date
  78857. */
  78858. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78859. /**
  78860. * Gets the root pose matrix
  78861. * @returns a matrix
  78862. */
  78863. getPoseMatrix(): Nullable<Matrix>;
  78864. /**
  78865. * Sorts bones per internal index
  78866. */
  78867. sortBones(): void;
  78868. private _sortBones;
  78869. }
  78870. }
  78871. declare module BABYLON {
  78872. /**
  78873. * Defines a target to use with MorphTargetManager
  78874. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78875. */
  78876. export class MorphTarget implements IAnimatable {
  78877. /** defines the name of the target */
  78878. name: string;
  78879. /**
  78880. * Gets or sets the list of animations
  78881. */
  78882. animations: Animation[];
  78883. private _scene;
  78884. private _positions;
  78885. private _normals;
  78886. private _tangents;
  78887. private _influence;
  78888. /**
  78889. * Observable raised when the influence changes
  78890. */
  78891. onInfluenceChanged: Observable<boolean>;
  78892. /** @hidden */
  78893. _onDataLayoutChanged: Observable<void>;
  78894. /**
  78895. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  78896. */
  78897. influence: number;
  78898. /**
  78899. * Gets or sets the id of the morph Target
  78900. */
  78901. id: string;
  78902. private _animationPropertiesOverride;
  78903. /**
  78904. * Gets or sets the animation properties override
  78905. */
  78906. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78907. /**
  78908. * Creates a new MorphTarget
  78909. * @param name defines the name of the target
  78910. * @param influence defines the influence to use
  78911. * @param scene defines the scene the morphtarget belongs to
  78912. */
  78913. constructor(
  78914. /** defines the name of the target */
  78915. name: string, influence?: number, scene?: Nullable<Scene>);
  78916. /**
  78917. * Gets a boolean defining if the target contains position data
  78918. */
  78919. readonly hasPositions: boolean;
  78920. /**
  78921. * Gets a boolean defining if the target contains normal data
  78922. */
  78923. readonly hasNormals: boolean;
  78924. /**
  78925. * Gets a boolean defining if the target contains tangent data
  78926. */
  78927. readonly hasTangents: boolean;
  78928. /**
  78929. * Affects position data to this target
  78930. * @param data defines the position data to use
  78931. */
  78932. setPositions(data: Nullable<FloatArray>): void;
  78933. /**
  78934. * Gets the position data stored in this target
  78935. * @returns a FloatArray containing the position data (or null if not present)
  78936. */
  78937. getPositions(): Nullable<FloatArray>;
  78938. /**
  78939. * Affects normal data to this target
  78940. * @param data defines the normal data to use
  78941. */
  78942. setNormals(data: Nullable<FloatArray>): void;
  78943. /**
  78944. * Gets the normal data stored in this target
  78945. * @returns a FloatArray containing the normal data (or null if not present)
  78946. */
  78947. getNormals(): Nullable<FloatArray>;
  78948. /**
  78949. * Affects tangent data to this target
  78950. * @param data defines the tangent data to use
  78951. */
  78952. setTangents(data: Nullable<FloatArray>): void;
  78953. /**
  78954. * Gets the tangent data stored in this target
  78955. * @returns a FloatArray containing the tangent data (or null if not present)
  78956. */
  78957. getTangents(): Nullable<FloatArray>;
  78958. /**
  78959. * Serializes the current target into a Serialization object
  78960. * @returns the serialized object
  78961. */
  78962. serialize(): any;
  78963. /**
  78964. * Returns the string "MorphTarget"
  78965. * @returns "MorphTarget"
  78966. */
  78967. getClassName(): string;
  78968. /**
  78969. * Creates a new target from serialized data
  78970. * @param serializationObject defines the serialized data to use
  78971. * @returns a new MorphTarget
  78972. */
  78973. static Parse(serializationObject: any): MorphTarget;
  78974. /**
  78975. * Creates a MorphTarget from mesh data
  78976. * @param mesh defines the source mesh
  78977. * @param name defines the name to use for the new target
  78978. * @param influence defines the influence to attach to the target
  78979. * @returns a new MorphTarget
  78980. */
  78981. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  78982. }
  78983. }
  78984. declare module BABYLON {
  78985. /**
  78986. * This class is used to deform meshes using morphing between different targets
  78987. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78988. */
  78989. export class MorphTargetManager {
  78990. private _targets;
  78991. private _targetInfluenceChangedObservers;
  78992. private _targetDataLayoutChangedObservers;
  78993. private _activeTargets;
  78994. private _scene;
  78995. private _influences;
  78996. private _supportsNormals;
  78997. private _supportsTangents;
  78998. private _vertexCount;
  78999. private _uniqueId;
  79000. private _tempInfluences;
  79001. /**
  79002. * Creates a new MorphTargetManager
  79003. * @param scene defines the current scene
  79004. */
  79005. constructor(scene?: Nullable<Scene>);
  79006. /**
  79007. * Gets the unique ID of this manager
  79008. */
  79009. readonly uniqueId: number;
  79010. /**
  79011. * Gets the number of vertices handled by this manager
  79012. */
  79013. readonly vertexCount: number;
  79014. /**
  79015. * Gets a boolean indicating if this manager supports morphing of normals
  79016. */
  79017. readonly supportsNormals: boolean;
  79018. /**
  79019. * Gets a boolean indicating if this manager supports morphing of tangents
  79020. */
  79021. readonly supportsTangents: boolean;
  79022. /**
  79023. * Gets the number of targets stored in this manager
  79024. */
  79025. readonly numTargets: number;
  79026. /**
  79027. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79028. */
  79029. readonly numInfluencers: number;
  79030. /**
  79031. * Gets the list of influences (one per target)
  79032. */
  79033. readonly influences: Float32Array;
  79034. /**
  79035. * Gets the active target at specified index. An active target is a target with an influence > 0
  79036. * @param index defines the index to check
  79037. * @returns the requested target
  79038. */
  79039. getActiveTarget(index: number): MorphTarget;
  79040. /**
  79041. * Gets the target at specified index
  79042. * @param index defines the index to check
  79043. * @returns the requested target
  79044. */
  79045. getTarget(index: number): MorphTarget;
  79046. /**
  79047. * Add a new target to this manager
  79048. * @param target defines the target to add
  79049. */
  79050. addTarget(target: MorphTarget): void;
  79051. /**
  79052. * Removes a target from the manager
  79053. * @param target defines the target to remove
  79054. */
  79055. removeTarget(target: MorphTarget): void;
  79056. /**
  79057. * Serializes the current manager into a Serialization object
  79058. * @returns the serialized object
  79059. */
  79060. serialize(): any;
  79061. private _syncActiveTargets;
  79062. /**
  79063. * Syncrhonize the targets with all the meshes using this morph target manager
  79064. */
  79065. synchronize(): void;
  79066. /**
  79067. * Creates a new MorphTargetManager from serialized data
  79068. * @param serializationObject defines the serialized data
  79069. * @param scene defines the hosting scene
  79070. * @returns the new MorphTargetManager
  79071. */
  79072. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79073. }
  79074. }
  79075. declare module BABYLON {
  79076. /**
  79077. * Mesh representing the gorund
  79078. */
  79079. export class GroundMesh extends Mesh {
  79080. /** If octree should be generated */
  79081. generateOctree: boolean;
  79082. private _heightQuads;
  79083. /** @hidden */
  79084. _subdivisionsX: number;
  79085. /** @hidden */
  79086. _subdivisionsY: number;
  79087. /** @hidden */
  79088. _width: number;
  79089. /** @hidden */
  79090. _height: number;
  79091. /** @hidden */
  79092. _minX: number;
  79093. /** @hidden */
  79094. _maxX: number;
  79095. /** @hidden */
  79096. _minZ: number;
  79097. /** @hidden */
  79098. _maxZ: number;
  79099. constructor(name: string, scene: Scene);
  79100. /**
  79101. * "GroundMesh"
  79102. * @returns "GroundMesh"
  79103. */
  79104. getClassName(): string;
  79105. /**
  79106. * The minimum of x and y subdivisions
  79107. */
  79108. readonly subdivisions: number;
  79109. /**
  79110. * X subdivisions
  79111. */
  79112. readonly subdivisionsX: number;
  79113. /**
  79114. * Y subdivisions
  79115. */
  79116. readonly subdivisionsY: number;
  79117. /**
  79118. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79119. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79120. * @param chunksCount the number of subdivisions for x and y
  79121. * @param octreeBlocksSize (Default: 32)
  79122. */
  79123. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79124. /**
  79125. * Returns a height (y) value in the Worl system :
  79126. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79127. * @param x x coordinate
  79128. * @param z z coordinate
  79129. * @returns the ground y position if (x, z) are outside the ground surface.
  79130. */
  79131. getHeightAtCoordinates(x: number, z: number): number;
  79132. /**
  79133. * Returns a normalized vector (Vector3) orthogonal to the ground
  79134. * at the ground coordinates (x, z) expressed in the World system.
  79135. * @param x x coordinate
  79136. * @param z z coordinate
  79137. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79138. */
  79139. getNormalAtCoordinates(x: number, z: number): Vector3;
  79140. /**
  79141. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79142. * at the ground coordinates (x, z) expressed in the World system.
  79143. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79144. * @param x x coordinate
  79145. * @param z z coordinate
  79146. * @param ref vector to store the result
  79147. * @returns the GroundMesh.
  79148. */
  79149. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79150. /**
  79151. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79152. * if the ground has been updated.
  79153. * This can be used in the render loop.
  79154. * @returns the GroundMesh.
  79155. */
  79156. updateCoordinateHeights(): GroundMesh;
  79157. private _getFacetAt;
  79158. private _initHeightQuads;
  79159. private _computeHeightQuads;
  79160. /**
  79161. * Serializes this ground mesh
  79162. * @param serializationObject object to write serialization to
  79163. */
  79164. serialize(serializationObject: any): void;
  79165. /**
  79166. * Parses a serialized ground mesh
  79167. * @param parsedMesh the serialized mesh
  79168. * @param scene the scene to create the ground mesh in
  79169. * @returns the created ground mesh
  79170. */
  79171. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79172. }
  79173. }
  79174. declare module BABYLON {
  79175. /**
  79176. * Interface for Physics-Joint data
  79177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79178. */
  79179. export interface PhysicsJointData {
  79180. /**
  79181. * The main pivot of the joint
  79182. */
  79183. mainPivot?: Vector3;
  79184. /**
  79185. * The connected pivot of the joint
  79186. */
  79187. connectedPivot?: Vector3;
  79188. /**
  79189. * The main axis of the joint
  79190. */
  79191. mainAxis?: Vector3;
  79192. /**
  79193. * The connected axis of the joint
  79194. */
  79195. connectedAxis?: Vector3;
  79196. /**
  79197. * The collision of the joint
  79198. */
  79199. collision?: boolean;
  79200. /**
  79201. * Native Oimo/Cannon/Energy data
  79202. */
  79203. nativeParams?: any;
  79204. }
  79205. /**
  79206. * This is a holder class for the physics joint created by the physics plugin
  79207. * It holds a set of functions to control the underlying joint
  79208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79209. */
  79210. export class PhysicsJoint {
  79211. /**
  79212. * The type of the physics joint
  79213. */
  79214. type: number;
  79215. /**
  79216. * The data for the physics joint
  79217. */
  79218. jointData: PhysicsJointData;
  79219. private _physicsJoint;
  79220. protected _physicsPlugin: IPhysicsEnginePlugin;
  79221. /**
  79222. * Initializes the physics joint
  79223. * @param type The type of the physics joint
  79224. * @param jointData The data for the physics joint
  79225. */
  79226. constructor(
  79227. /**
  79228. * The type of the physics joint
  79229. */
  79230. type: number,
  79231. /**
  79232. * The data for the physics joint
  79233. */
  79234. jointData: PhysicsJointData);
  79235. /**
  79236. * Gets the physics joint
  79237. */
  79238. /**
  79239. * Sets the physics joint
  79240. */
  79241. physicsJoint: any;
  79242. /**
  79243. * Sets the physics plugin
  79244. */
  79245. physicsPlugin: IPhysicsEnginePlugin;
  79246. /**
  79247. * Execute a function that is physics-plugin specific.
  79248. * @param {Function} func the function that will be executed.
  79249. * It accepts two parameters: the physics world and the physics joint
  79250. */
  79251. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79252. /**
  79253. * Distance-Joint type
  79254. */
  79255. static DistanceJoint: number;
  79256. /**
  79257. * Hinge-Joint type
  79258. */
  79259. static HingeJoint: number;
  79260. /**
  79261. * Ball-and-Socket joint type
  79262. */
  79263. static BallAndSocketJoint: number;
  79264. /**
  79265. * Wheel-Joint type
  79266. */
  79267. static WheelJoint: number;
  79268. /**
  79269. * Slider-Joint type
  79270. */
  79271. static SliderJoint: number;
  79272. /**
  79273. * Prismatic-Joint type
  79274. */
  79275. static PrismaticJoint: number;
  79276. /**
  79277. * Universal-Joint type
  79278. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79279. */
  79280. static UniversalJoint: number;
  79281. /**
  79282. * Hinge-Joint 2 type
  79283. */
  79284. static Hinge2Joint: number;
  79285. /**
  79286. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79287. */
  79288. static PointToPointJoint: number;
  79289. /**
  79290. * Spring-Joint type
  79291. */
  79292. static SpringJoint: number;
  79293. /**
  79294. * Lock-Joint type
  79295. */
  79296. static LockJoint: number;
  79297. }
  79298. /**
  79299. * A class representing a physics distance joint
  79300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79301. */
  79302. export class DistanceJoint extends PhysicsJoint {
  79303. /**
  79304. *
  79305. * @param jointData The data for the Distance-Joint
  79306. */
  79307. constructor(jointData: DistanceJointData);
  79308. /**
  79309. * Update the predefined distance.
  79310. * @param maxDistance The maximum preferred distance
  79311. * @param minDistance The minimum preferred distance
  79312. */
  79313. updateDistance(maxDistance: number, minDistance?: number): void;
  79314. }
  79315. /**
  79316. * Represents a Motor-Enabled Joint
  79317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79318. */
  79319. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79320. /**
  79321. * Initializes the Motor-Enabled Joint
  79322. * @param type The type of the joint
  79323. * @param jointData The physica joint data for the joint
  79324. */
  79325. constructor(type: number, jointData: PhysicsJointData);
  79326. /**
  79327. * Set the motor values.
  79328. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79329. * @param force the force to apply
  79330. * @param maxForce max force for this motor.
  79331. */
  79332. setMotor(force?: number, maxForce?: number): void;
  79333. /**
  79334. * Set the motor's limits.
  79335. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79336. * @param upperLimit The upper limit of the motor
  79337. * @param lowerLimit The lower limit of the motor
  79338. */
  79339. setLimit(upperLimit: number, lowerLimit?: number): void;
  79340. }
  79341. /**
  79342. * This class represents a single physics Hinge-Joint
  79343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79344. */
  79345. export class HingeJoint extends MotorEnabledJoint {
  79346. /**
  79347. * Initializes the Hinge-Joint
  79348. * @param jointData The joint data for the Hinge-Joint
  79349. */
  79350. constructor(jointData: PhysicsJointData);
  79351. /**
  79352. * Set the motor values.
  79353. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79354. * @param {number} force the force to apply
  79355. * @param {number} maxForce max force for this motor.
  79356. */
  79357. setMotor(force?: number, maxForce?: number): void;
  79358. /**
  79359. * Set the motor's limits.
  79360. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79361. * @param upperLimit The upper limit of the motor
  79362. * @param lowerLimit The lower limit of the motor
  79363. */
  79364. setLimit(upperLimit: number, lowerLimit?: number): void;
  79365. }
  79366. /**
  79367. * This class represents a dual hinge physics joint (same as wheel joint)
  79368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79369. */
  79370. export class Hinge2Joint extends MotorEnabledJoint {
  79371. /**
  79372. * Initializes the Hinge2-Joint
  79373. * @param jointData The joint data for the Hinge2-Joint
  79374. */
  79375. constructor(jointData: PhysicsJointData);
  79376. /**
  79377. * Set the motor values.
  79378. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79379. * @param {number} targetSpeed the speed the motor is to reach
  79380. * @param {number} maxForce max force for this motor.
  79381. * @param {motorIndex} the motor's index, 0 or 1.
  79382. */
  79383. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79384. /**
  79385. * Set the motor limits.
  79386. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79387. * @param {number} upperLimit the upper limit
  79388. * @param {number} lowerLimit lower limit
  79389. * @param {motorIndex} the motor's index, 0 or 1.
  79390. */
  79391. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79392. }
  79393. /**
  79394. * Interface for a motor enabled joint
  79395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79396. */
  79397. export interface IMotorEnabledJoint {
  79398. /**
  79399. * Physics joint
  79400. */
  79401. physicsJoint: any;
  79402. /**
  79403. * Sets the motor of the motor-enabled joint
  79404. * @param force The force of the motor
  79405. * @param maxForce The maximum force of the motor
  79406. * @param motorIndex The index of the motor
  79407. */
  79408. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79409. /**
  79410. * Sets the limit of the motor
  79411. * @param upperLimit The upper limit of the motor
  79412. * @param lowerLimit The lower limit of the motor
  79413. * @param motorIndex The index of the motor
  79414. */
  79415. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79416. }
  79417. /**
  79418. * Joint data for a Distance-Joint
  79419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79420. */
  79421. export interface DistanceJointData extends PhysicsJointData {
  79422. /**
  79423. * Max distance the 2 joint objects can be apart
  79424. */
  79425. maxDistance: number;
  79426. }
  79427. /**
  79428. * Joint data from a spring joint
  79429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79430. */
  79431. export interface SpringJointData extends PhysicsJointData {
  79432. /**
  79433. * Length of the spring
  79434. */
  79435. length: number;
  79436. /**
  79437. * Stiffness of the spring
  79438. */
  79439. stiffness: number;
  79440. /**
  79441. * Damping of the spring
  79442. */
  79443. damping: number;
  79444. /** this callback will be called when applying the force to the impostors. */
  79445. forceApplicationCallback: () => void;
  79446. }
  79447. }
  79448. declare module BABYLON {
  79449. /**
  79450. * Holds the data for the raycast result
  79451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79452. */
  79453. export class PhysicsRaycastResult {
  79454. private _hasHit;
  79455. private _hitDistance;
  79456. private _hitNormalWorld;
  79457. private _hitPointWorld;
  79458. private _rayFromWorld;
  79459. private _rayToWorld;
  79460. /**
  79461. * Gets if there was a hit
  79462. */
  79463. readonly hasHit: boolean;
  79464. /**
  79465. * Gets the distance from the hit
  79466. */
  79467. readonly hitDistance: number;
  79468. /**
  79469. * Gets the hit normal/direction in the world
  79470. */
  79471. readonly hitNormalWorld: Vector3;
  79472. /**
  79473. * Gets the hit point in the world
  79474. */
  79475. readonly hitPointWorld: Vector3;
  79476. /**
  79477. * Gets the ray "start point" of the ray in the world
  79478. */
  79479. readonly rayFromWorld: Vector3;
  79480. /**
  79481. * Gets the ray "end point" of the ray in the world
  79482. */
  79483. readonly rayToWorld: Vector3;
  79484. /**
  79485. * Sets the hit data (normal & point in world space)
  79486. * @param hitNormalWorld defines the normal in world space
  79487. * @param hitPointWorld defines the point in world space
  79488. */
  79489. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79490. /**
  79491. * Sets the distance from the start point to the hit point
  79492. * @param distance
  79493. */
  79494. setHitDistance(distance: number): void;
  79495. /**
  79496. * Calculates the distance manually
  79497. */
  79498. calculateHitDistance(): void;
  79499. /**
  79500. * Resets all the values to default
  79501. * @param from The from point on world space
  79502. * @param to The to point on world space
  79503. */
  79504. reset(from?: Vector3, to?: Vector3): void;
  79505. }
  79506. /**
  79507. * Interface for the size containing width and height
  79508. */
  79509. interface IXYZ {
  79510. /**
  79511. * X
  79512. */
  79513. x: number;
  79514. /**
  79515. * Y
  79516. */
  79517. y: number;
  79518. /**
  79519. * Z
  79520. */
  79521. z: number;
  79522. }
  79523. }
  79524. declare module BABYLON {
  79525. /**
  79526. * Interface used to describe a physics joint
  79527. */
  79528. export interface PhysicsImpostorJoint {
  79529. /** Defines the main impostor to which the joint is linked */
  79530. mainImpostor: PhysicsImpostor;
  79531. /** Defines the impostor that is connected to the main impostor using this joint */
  79532. connectedImpostor: PhysicsImpostor;
  79533. /** Defines the joint itself */
  79534. joint: PhysicsJoint;
  79535. }
  79536. /** @hidden */
  79537. export interface IPhysicsEnginePlugin {
  79538. world: any;
  79539. name: string;
  79540. setGravity(gravity: Vector3): void;
  79541. setTimeStep(timeStep: number): void;
  79542. getTimeStep(): number;
  79543. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79544. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79545. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79546. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79547. removePhysicsBody(impostor: PhysicsImpostor): void;
  79548. generateJoint(joint: PhysicsImpostorJoint): void;
  79549. removeJoint(joint: PhysicsImpostorJoint): void;
  79550. isSupported(): boolean;
  79551. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  79552. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  79553. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79554. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79555. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79556. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79557. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  79558. getBodyMass(impostor: PhysicsImpostor): number;
  79559. getBodyFriction(impostor: PhysicsImpostor): number;
  79560. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  79561. getBodyRestitution(impostor: PhysicsImpostor): number;
  79562. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  79563. getBodyPressure?(impostor: PhysicsImpostor): number;
  79564. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  79565. getBodyStiffness?(impostor: PhysicsImpostor): number;
  79566. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  79567. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  79568. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  79569. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  79570. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  79571. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79572. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79573. sleepBody(impostor: PhysicsImpostor): void;
  79574. wakeUpBody(impostor: PhysicsImpostor): void;
  79575. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79576. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  79577. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  79578. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79579. getRadius(impostor: PhysicsImpostor): number;
  79580. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  79581. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  79582. dispose(): void;
  79583. }
  79584. /**
  79585. * Interface used to define a physics engine
  79586. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  79587. */
  79588. export interface IPhysicsEngine {
  79589. /**
  79590. * Gets the gravity vector used by the simulation
  79591. */
  79592. gravity: Vector3;
  79593. /**
  79594. * Sets the gravity vector used by the simulation
  79595. * @param gravity defines the gravity vector to use
  79596. */
  79597. setGravity(gravity: Vector3): void;
  79598. /**
  79599. * Set the time step of the physics engine.
  79600. * Default is 1/60.
  79601. * To slow it down, enter 1/600 for example.
  79602. * To speed it up, 1/30
  79603. * @param newTimeStep the new timestep to apply to this world.
  79604. */
  79605. setTimeStep(newTimeStep: number): void;
  79606. /**
  79607. * Get the time step of the physics engine.
  79608. * @returns the current time step
  79609. */
  79610. getTimeStep(): number;
  79611. /**
  79612. * Release all resources
  79613. */
  79614. dispose(): void;
  79615. /**
  79616. * Gets the name of the current physics plugin
  79617. * @returns the name of the plugin
  79618. */
  79619. getPhysicsPluginName(): string;
  79620. /**
  79621. * Adding a new impostor for the impostor tracking.
  79622. * This will be done by the impostor itself.
  79623. * @param impostor the impostor to add
  79624. */
  79625. addImpostor(impostor: PhysicsImpostor): void;
  79626. /**
  79627. * Remove an impostor from the engine.
  79628. * This impostor and its mesh will not longer be updated by the physics engine.
  79629. * @param impostor the impostor to remove
  79630. */
  79631. removeImpostor(impostor: PhysicsImpostor): void;
  79632. /**
  79633. * Add a joint to the physics engine
  79634. * @param mainImpostor defines the main impostor to which the joint is added.
  79635. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  79636. * @param joint defines the joint that will connect both impostors.
  79637. */
  79638. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79639. /**
  79640. * Removes a joint from the simulation
  79641. * @param mainImpostor defines the impostor used with the joint
  79642. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  79643. * @param joint defines the joint to remove
  79644. */
  79645. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79646. /**
  79647. * Gets the current plugin used to run the simulation
  79648. * @returns current plugin
  79649. */
  79650. getPhysicsPlugin(): IPhysicsEnginePlugin;
  79651. /**
  79652. * Gets the list of physic impostors
  79653. * @returns an array of PhysicsImpostor
  79654. */
  79655. getImpostors(): Array<PhysicsImpostor>;
  79656. /**
  79657. * Gets the impostor for a physics enabled object
  79658. * @param object defines the object impersonated by the impostor
  79659. * @returns the PhysicsImpostor or null if not found
  79660. */
  79661. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79662. /**
  79663. * Gets the impostor for a physics body object
  79664. * @param body defines physics body used by the impostor
  79665. * @returns the PhysicsImpostor or null if not found
  79666. */
  79667. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  79668. /**
  79669. * Does a raycast in the physics world
  79670. * @param from when should the ray start?
  79671. * @param to when should the ray end?
  79672. * @returns PhysicsRaycastResult
  79673. */
  79674. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79675. /**
  79676. * Called by the scene. No need to call it.
  79677. * @param delta defines the timespam between frames
  79678. */
  79679. _step(delta: number): void;
  79680. }
  79681. }
  79682. declare module BABYLON {
  79683. /**
  79684. * The interface for the physics imposter parameters
  79685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79686. */
  79687. export interface PhysicsImpostorParameters {
  79688. /**
  79689. * The mass of the physics imposter
  79690. */
  79691. mass: number;
  79692. /**
  79693. * The friction of the physics imposter
  79694. */
  79695. friction?: number;
  79696. /**
  79697. * The coefficient of restitution of the physics imposter
  79698. */
  79699. restitution?: number;
  79700. /**
  79701. * The native options of the physics imposter
  79702. */
  79703. nativeOptions?: any;
  79704. /**
  79705. * Specifies if the parent should be ignored
  79706. */
  79707. ignoreParent?: boolean;
  79708. /**
  79709. * Specifies if bi-directional transformations should be disabled
  79710. */
  79711. disableBidirectionalTransformation?: boolean;
  79712. /**
  79713. * The pressure inside the physics imposter, soft object only
  79714. */
  79715. pressure?: number;
  79716. /**
  79717. * The stiffness the physics imposter, soft object only
  79718. */
  79719. stiffness?: number;
  79720. /**
  79721. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  79722. */
  79723. velocityIterations?: number;
  79724. /**
  79725. * The number of iterations used in maintaining consistent vertex positions, soft object only
  79726. */
  79727. positionIterations?: number;
  79728. /**
  79729. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  79730. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  79731. * Add to fix multiple points
  79732. */
  79733. fixedPoints?: number;
  79734. /**
  79735. * The collision margin around a soft object
  79736. */
  79737. margin?: number;
  79738. /**
  79739. * The collision margin around a soft object
  79740. */
  79741. damping?: number;
  79742. /**
  79743. * The path for a rope based on an extrusion
  79744. */
  79745. path?: any;
  79746. /**
  79747. * The shape of an extrusion used for a rope based on an extrusion
  79748. */
  79749. shape?: any;
  79750. }
  79751. /**
  79752. * Interface for a physics-enabled object
  79753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79754. */
  79755. export interface IPhysicsEnabledObject {
  79756. /**
  79757. * The position of the physics-enabled object
  79758. */
  79759. position: Vector3;
  79760. /**
  79761. * The rotation of the physics-enabled object
  79762. */
  79763. rotationQuaternion: Nullable<Quaternion>;
  79764. /**
  79765. * The scale of the physics-enabled object
  79766. */
  79767. scaling: Vector3;
  79768. /**
  79769. * The rotation of the physics-enabled object
  79770. */
  79771. rotation?: Vector3;
  79772. /**
  79773. * The parent of the physics-enabled object
  79774. */
  79775. parent?: any;
  79776. /**
  79777. * The bounding info of the physics-enabled object
  79778. * @returns The bounding info of the physics-enabled object
  79779. */
  79780. getBoundingInfo(): BoundingInfo;
  79781. /**
  79782. * Computes the world matrix
  79783. * @param force Specifies if the world matrix should be computed by force
  79784. * @returns A world matrix
  79785. */
  79786. computeWorldMatrix(force: boolean): Matrix;
  79787. /**
  79788. * Gets the world matrix
  79789. * @returns A world matrix
  79790. */
  79791. getWorldMatrix?(): Matrix;
  79792. /**
  79793. * Gets the child meshes
  79794. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  79795. * @returns An array of abstract meshes
  79796. */
  79797. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  79798. /**
  79799. * Gets the vertex data
  79800. * @param kind The type of vertex data
  79801. * @returns A nullable array of numbers, or a float32 array
  79802. */
  79803. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  79804. /**
  79805. * Gets the indices from the mesh
  79806. * @returns A nullable array of index arrays
  79807. */
  79808. getIndices?(): Nullable<IndicesArray>;
  79809. /**
  79810. * Gets the scene from the mesh
  79811. * @returns the indices array or null
  79812. */
  79813. getScene?(): Scene;
  79814. /**
  79815. * Gets the absolute position from the mesh
  79816. * @returns the absolute position
  79817. */
  79818. getAbsolutePosition(): Vector3;
  79819. /**
  79820. * Gets the absolute pivot point from the mesh
  79821. * @returns the absolute pivot point
  79822. */
  79823. getAbsolutePivotPoint(): Vector3;
  79824. /**
  79825. * Rotates the mesh
  79826. * @param axis The axis of rotation
  79827. * @param amount The amount of rotation
  79828. * @param space The space of the rotation
  79829. * @returns The rotation transform node
  79830. */
  79831. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79832. /**
  79833. * Translates the mesh
  79834. * @param axis The axis of translation
  79835. * @param distance The distance of translation
  79836. * @param space The space of the translation
  79837. * @returns The transform node
  79838. */
  79839. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79840. /**
  79841. * Sets the absolute position of the mesh
  79842. * @param absolutePosition The absolute position of the mesh
  79843. * @returns The transform node
  79844. */
  79845. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79846. /**
  79847. * Gets the class name of the mesh
  79848. * @returns The class name
  79849. */
  79850. getClassName(): string;
  79851. }
  79852. /**
  79853. * Represents a physics imposter
  79854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79855. */
  79856. export class PhysicsImpostor {
  79857. /**
  79858. * The physics-enabled object used as the physics imposter
  79859. */
  79860. object: IPhysicsEnabledObject;
  79861. /**
  79862. * The type of the physics imposter
  79863. */
  79864. type: number;
  79865. private _options;
  79866. private _scene?;
  79867. /**
  79868. * The default object size of the imposter
  79869. */
  79870. static DEFAULT_OBJECT_SIZE: Vector3;
  79871. /**
  79872. * The identity quaternion of the imposter
  79873. */
  79874. static IDENTITY_QUATERNION: Quaternion;
  79875. /** @hidden */
  79876. _pluginData: any;
  79877. private _physicsEngine;
  79878. private _physicsBody;
  79879. private _bodyUpdateRequired;
  79880. private _onBeforePhysicsStepCallbacks;
  79881. private _onAfterPhysicsStepCallbacks;
  79882. /** @hidden */
  79883. _onPhysicsCollideCallbacks: Array<{
  79884. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  79885. otherImpostors: Array<PhysicsImpostor>;
  79886. }>;
  79887. private _deltaPosition;
  79888. private _deltaRotation;
  79889. private _deltaRotationConjugated;
  79890. /** hidden */
  79891. _isFromLine: boolean;
  79892. private _parent;
  79893. private _isDisposed;
  79894. private static _tmpVecs;
  79895. private static _tmpQuat;
  79896. /**
  79897. * Specifies if the physics imposter is disposed
  79898. */
  79899. readonly isDisposed: boolean;
  79900. /**
  79901. * Gets the mass of the physics imposter
  79902. */
  79903. mass: number;
  79904. /**
  79905. * Gets the coefficient of friction
  79906. */
  79907. /**
  79908. * Sets the coefficient of friction
  79909. */
  79910. friction: number;
  79911. /**
  79912. * Gets the coefficient of restitution
  79913. */
  79914. /**
  79915. * Sets the coefficient of restitution
  79916. */
  79917. restitution: number;
  79918. /**
  79919. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  79920. */
  79921. /**
  79922. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  79923. */
  79924. pressure: number;
  79925. /**
  79926. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79927. */
  79928. /**
  79929. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79930. */
  79931. stiffness: number;
  79932. /**
  79933. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79934. */
  79935. /**
  79936. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79937. */
  79938. velocityIterations: number;
  79939. /**
  79940. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79941. */
  79942. /**
  79943. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79944. */
  79945. positionIterations: number;
  79946. /**
  79947. * The unique id of the physics imposter
  79948. * set by the physics engine when adding this impostor to the array
  79949. */
  79950. uniqueId: number;
  79951. /**
  79952. * @hidden
  79953. */
  79954. soft: boolean;
  79955. /**
  79956. * @hidden
  79957. */
  79958. segments: number;
  79959. private _joints;
  79960. /**
  79961. * Initializes the physics imposter
  79962. * @param object The physics-enabled object used as the physics imposter
  79963. * @param type The type of the physics imposter
  79964. * @param _options The options for the physics imposter
  79965. * @param _scene The Babylon scene
  79966. */
  79967. constructor(
  79968. /**
  79969. * The physics-enabled object used as the physics imposter
  79970. */
  79971. object: IPhysicsEnabledObject,
  79972. /**
  79973. * The type of the physics imposter
  79974. */
  79975. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  79976. /**
  79977. * This function will completly initialize this impostor.
  79978. * It will create a new body - but only if this mesh has no parent.
  79979. * If it has, this impostor will not be used other than to define the impostor
  79980. * of the child mesh.
  79981. * @hidden
  79982. */
  79983. _init(): void;
  79984. private _getPhysicsParent;
  79985. /**
  79986. * Should a new body be generated.
  79987. * @returns boolean specifying if body initialization is required
  79988. */
  79989. isBodyInitRequired(): boolean;
  79990. /**
  79991. * Sets the updated scaling
  79992. * @param updated Specifies if the scaling is updated
  79993. */
  79994. setScalingUpdated(): void;
  79995. /**
  79996. * Force a regeneration of this or the parent's impostor's body.
  79997. * Use under cautious - This will remove all joints already implemented.
  79998. */
  79999. forceUpdate(): void;
  80000. /**
  80001. * Gets the body that holds this impostor. Either its own, or its parent.
  80002. */
  80003. /**
  80004. * Set the physics body. Used mainly by the physics engine/plugin
  80005. */
  80006. physicsBody: any;
  80007. /**
  80008. * Get the parent of the physics imposter
  80009. * @returns Physics imposter or null
  80010. */
  80011. /**
  80012. * Sets the parent of the physics imposter
  80013. */
  80014. parent: Nullable<PhysicsImpostor>;
  80015. /**
  80016. * Resets the update flags
  80017. */
  80018. resetUpdateFlags(): void;
  80019. /**
  80020. * Gets the object extend size
  80021. * @returns the object extend size
  80022. */
  80023. getObjectExtendSize(): Vector3;
  80024. /**
  80025. * Gets the object center
  80026. * @returns The object center
  80027. */
  80028. getObjectCenter(): Vector3;
  80029. /**
  80030. * Get a specific parametes from the options parameter
  80031. * @param paramName The object parameter name
  80032. * @returns The object parameter
  80033. */
  80034. getParam(paramName: string): any;
  80035. /**
  80036. * Sets a specific parameter in the options given to the physics plugin
  80037. * @param paramName The parameter name
  80038. * @param value The value of the parameter
  80039. */
  80040. setParam(paramName: string, value: number): void;
  80041. /**
  80042. * Specifically change the body's mass option. Won't recreate the physics body object
  80043. * @param mass The mass of the physics imposter
  80044. */
  80045. setMass(mass: number): void;
  80046. /**
  80047. * Gets the linear velocity
  80048. * @returns linear velocity or null
  80049. */
  80050. getLinearVelocity(): Nullable<Vector3>;
  80051. /**
  80052. * Sets the linear velocity
  80053. * @param velocity linear velocity or null
  80054. */
  80055. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80056. /**
  80057. * Gets the angular velocity
  80058. * @returns angular velocity or null
  80059. */
  80060. getAngularVelocity(): Nullable<Vector3>;
  80061. /**
  80062. * Sets the angular velocity
  80063. * @param velocity The velocity or null
  80064. */
  80065. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80066. /**
  80067. * Execute a function with the physics plugin native code
  80068. * Provide a function the will have two variables - the world object and the physics body object
  80069. * @param func The function to execute with the physics plugin native code
  80070. */
  80071. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80072. /**
  80073. * Register a function that will be executed before the physics world is stepping forward
  80074. * @param func The function to execute before the physics world is stepped forward
  80075. */
  80076. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80077. /**
  80078. * Unregister a function that will be executed before the physics world is stepping forward
  80079. * @param func The function to execute before the physics world is stepped forward
  80080. */
  80081. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80082. /**
  80083. * Register a function that will be executed after the physics step
  80084. * @param func The function to execute after physics step
  80085. */
  80086. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80087. /**
  80088. * Unregisters a function that will be executed after the physics step
  80089. * @param func The function to execute after physics step
  80090. */
  80091. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80092. /**
  80093. * register a function that will be executed when this impostor collides against a different body
  80094. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80095. * @param func Callback that is executed on collision
  80096. */
  80097. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80098. /**
  80099. * Unregisters the physics imposter on contact
  80100. * @param collideAgainst The physics object to collide against
  80101. * @param func Callback to execute on collision
  80102. */
  80103. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80104. private _tmpQuat;
  80105. private _tmpQuat2;
  80106. /**
  80107. * Get the parent rotation
  80108. * @returns The parent rotation
  80109. */
  80110. getParentsRotation(): Quaternion;
  80111. /**
  80112. * this function is executed by the physics engine.
  80113. */
  80114. beforeStep: () => void;
  80115. /**
  80116. * this function is executed by the physics engine
  80117. */
  80118. afterStep: () => void;
  80119. /**
  80120. * Legacy collision detection event support
  80121. */
  80122. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80123. /**
  80124. * event and body object due to cannon's event-based architecture.
  80125. */
  80126. onCollide: (e: {
  80127. body: any;
  80128. }) => void;
  80129. /**
  80130. * Apply a force
  80131. * @param force The force to apply
  80132. * @param contactPoint The contact point for the force
  80133. * @returns The physics imposter
  80134. */
  80135. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80136. /**
  80137. * Apply an impulse
  80138. * @param force The impulse force
  80139. * @param contactPoint The contact point for the impulse force
  80140. * @returns The physics imposter
  80141. */
  80142. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80143. /**
  80144. * A help function to create a joint
  80145. * @param otherImpostor A physics imposter used to create a joint
  80146. * @param jointType The type of joint
  80147. * @param jointData The data for the joint
  80148. * @returns The physics imposter
  80149. */
  80150. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80151. /**
  80152. * Add a joint to this impostor with a different impostor
  80153. * @param otherImpostor A physics imposter used to add a joint
  80154. * @param joint The joint to add
  80155. * @returns The physics imposter
  80156. */
  80157. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80158. /**
  80159. * Add an anchor to a cloth impostor
  80160. * @param otherImpostor rigid impostor to anchor to
  80161. * @param width ratio across width from 0 to 1
  80162. * @param height ratio up height from 0 to 1
  80163. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80164. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80165. * @returns impostor the soft imposter
  80166. */
  80167. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80168. /**
  80169. * Add a hook to a rope impostor
  80170. * @param otherImpostor rigid impostor to anchor to
  80171. * @param length ratio across rope from 0 to 1
  80172. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80173. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80174. * @returns impostor the rope imposter
  80175. */
  80176. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80177. /**
  80178. * Will keep this body still, in a sleep mode.
  80179. * @returns the physics imposter
  80180. */
  80181. sleep(): PhysicsImpostor;
  80182. /**
  80183. * Wake the body up.
  80184. * @returns The physics imposter
  80185. */
  80186. wakeUp(): PhysicsImpostor;
  80187. /**
  80188. * Clones the physics imposter
  80189. * @param newObject The physics imposter clones to this physics-enabled object
  80190. * @returns A nullable physics imposter
  80191. */
  80192. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80193. /**
  80194. * Disposes the physics imposter
  80195. */
  80196. dispose(): void;
  80197. /**
  80198. * Sets the delta position
  80199. * @param position The delta position amount
  80200. */
  80201. setDeltaPosition(position: Vector3): void;
  80202. /**
  80203. * Sets the delta rotation
  80204. * @param rotation The delta rotation amount
  80205. */
  80206. setDeltaRotation(rotation: Quaternion): void;
  80207. /**
  80208. * Gets the box size of the physics imposter and stores the result in the input parameter
  80209. * @param result Stores the box size
  80210. * @returns The physics imposter
  80211. */
  80212. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80213. /**
  80214. * Gets the radius of the physics imposter
  80215. * @returns Radius of the physics imposter
  80216. */
  80217. getRadius(): number;
  80218. /**
  80219. * Sync a bone with this impostor
  80220. * @param bone The bone to sync to the impostor.
  80221. * @param boneMesh The mesh that the bone is influencing.
  80222. * @param jointPivot The pivot of the joint / bone in local space.
  80223. * @param distToJoint Optional distance from the impostor to the joint.
  80224. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80225. */
  80226. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80227. /**
  80228. * Sync impostor to a bone
  80229. * @param bone The bone that the impostor will be synced to.
  80230. * @param boneMesh The mesh that the bone is influencing.
  80231. * @param jointPivot The pivot of the joint / bone in local space.
  80232. * @param distToJoint Optional distance from the impostor to the joint.
  80233. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80234. * @param boneAxis Optional vector3 axis the bone is aligned with
  80235. */
  80236. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80237. /**
  80238. * No-Imposter type
  80239. */
  80240. static NoImpostor: number;
  80241. /**
  80242. * Sphere-Imposter type
  80243. */
  80244. static SphereImpostor: number;
  80245. /**
  80246. * Box-Imposter type
  80247. */
  80248. static BoxImpostor: number;
  80249. /**
  80250. * Plane-Imposter type
  80251. */
  80252. static PlaneImpostor: number;
  80253. /**
  80254. * Mesh-imposter type
  80255. */
  80256. static MeshImpostor: number;
  80257. /**
  80258. * Cylinder-Imposter type
  80259. */
  80260. static CylinderImpostor: number;
  80261. /**
  80262. * Particle-Imposter type
  80263. */
  80264. static ParticleImpostor: number;
  80265. /**
  80266. * Heightmap-Imposter type
  80267. */
  80268. static HeightmapImpostor: number;
  80269. /**
  80270. * ConvexHull-Impostor type (Ammo.js plugin only)
  80271. */
  80272. static ConvexHullImpostor: number;
  80273. /**
  80274. * Rope-Imposter type
  80275. */
  80276. static RopeImpostor: number;
  80277. /**
  80278. * Cloth-Imposter type
  80279. */
  80280. static ClothImpostor: number;
  80281. /**
  80282. * Softbody-Imposter type
  80283. */
  80284. static SoftbodyImpostor: number;
  80285. }
  80286. }
  80287. declare module BABYLON {
  80288. /**
  80289. * Class used to represent a specific level of detail of a mesh
  80290. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80291. */
  80292. export class MeshLODLevel {
  80293. /** Defines the distance where this level should star being displayed */
  80294. distance: number;
  80295. /** Defines the mesh to use to render this level */
  80296. mesh: Nullable<Mesh>;
  80297. /**
  80298. * Creates a new LOD level
  80299. * @param distance defines the distance where this level should star being displayed
  80300. * @param mesh defines the mesh to use to render this level
  80301. */
  80302. constructor(
  80303. /** Defines the distance where this level should star being displayed */
  80304. distance: number,
  80305. /** Defines the mesh to use to render this level */
  80306. mesh: Nullable<Mesh>);
  80307. }
  80308. /**
  80309. * @hidden
  80310. **/
  80311. export class _CreationDataStorage {
  80312. closePath?: boolean;
  80313. closeArray?: boolean;
  80314. idx: number[];
  80315. dashSize: number;
  80316. gapSize: number;
  80317. path3D: Path3D;
  80318. pathArray: Vector3[][];
  80319. arc: number;
  80320. radius: number;
  80321. cap: number;
  80322. tessellation: number;
  80323. }
  80324. /**
  80325. * @hidden
  80326. **/
  80327. class _InstanceDataStorage {
  80328. visibleInstances: any;
  80329. batchCache: _InstancesBatch;
  80330. instancesBufferSize: number;
  80331. instancesBuffer: Nullable<Buffer>;
  80332. instancesData: Float32Array;
  80333. overridenInstanceCount: number;
  80334. isFrozen: boolean;
  80335. previousBatch: _InstancesBatch;
  80336. hardwareInstancedRendering: boolean;
  80337. sideOrientation: number;
  80338. }
  80339. /**
  80340. * @hidden
  80341. **/
  80342. export class _InstancesBatch {
  80343. mustReturn: boolean;
  80344. visibleInstances: Nullable<InstancedMesh[]>[];
  80345. renderSelf: boolean[];
  80346. hardwareInstancedRendering: boolean[];
  80347. }
  80348. /**
  80349. * Class used to represent renderable models
  80350. */
  80351. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80352. /**
  80353. * Mesh side orientation : usually the external or front surface
  80354. */
  80355. static readonly FRONTSIDE: number;
  80356. /**
  80357. * Mesh side orientation : usually the internal or back surface
  80358. */
  80359. static readonly BACKSIDE: number;
  80360. /**
  80361. * Mesh side orientation : both internal and external or front and back surfaces
  80362. */
  80363. static readonly DOUBLESIDE: number;
  80364. /**
  80365. * Mesh side orientation : by default, `FRONTSIDE`
  80366. */
  80367. static readonly DEFAULTSIDE: number;
  80368. /**
  80369. * Mesh cap setting : no cap
  80370. */
  80371. static readonly NO_CAP: number;
  80372. /**
  80373. * Mesh cap setting : one cap at the beginning of the mesh
  80374. */
  80375. static readonly CAP_START: number;
  80376. /**
  80377. * Mesh cap setting : one cap at the end of the mesh
  80378. */
  80379. static readonly CAP_END: number;
  80380. /**
  80381. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80382. */
  80383. static readonly CAP_ALL: number;
  80384. /**
  80385. * Gets the default side orientation.
  80386. * @param orientation the orientation to value to attempt to get
  80387. * @returns the default orientation
  80388. * @hidden
  80389. */
  80390. static _GetDefaultSideOrientation(orientation?: number): number;
  80391. private _onBeforeRenderObservable;
  80392. private _onBeforeBindObservable;
  80393. private _onAfterRenderObservable;
  80394. private _onBeforeDrawObservable;
  80395. /**
  80396. * An event triggered before rendering the mesh
  80397. */
  80398. readonly onBeforeRenderObservable: Observable<Mesh>;
  80399. /**
  80400. * An event triggered before binding the mesh
  80401. */
  80402. readonly onBeforeBindObservable: Observable<Mesh>;
  80403. /**
  80404. * An event triggered after rendering the mesh
  80405. */
  80406. readonly onAfterRenderObservable: Observable<Mesh>;
  80407. /**
  80408. * An event triggered before drawing the mesh
  80409. */
  80410. readonly onBeforeDrawObservable: Observable<Mesh>;
  80411. private _onBeforeDrawObserver;
  80412. /**
  80413. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80414. */
  80415. onBeforeDraw: () => void;
  80416. /**
  80417. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80418. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80419. */
  80420. delayLoadState: number;
  80421. /**
  80422. * Gets the list of instances created from this mesh
  80423. * it is not supposed to be modified manually.
  80424. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80425. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80426. */
  80427. instances: InstancedMesh[];
  80428. /**
  80429. * Gets the file containing delay loading data for this mesh
  80430. */
  80431. delayLoadingFile: string;
  80432. /** @hidden */
  80433. _binaryInfo: any;
  80434. private _LODLevels;
  80435. /**
  80436. * User defined function used to change how LOD level selection is done
  80437. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80438. */
  80439. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80440. private _morphTargetManager;
  80441. /**
  80442. * Gets or sets the morph target manager
  80443. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80444. */
  80445. morphTargetManager: Nullable<MorphTargetManager>;
  80446. /** @hidden */
  80447. _creationDataStorage: Nullable<_CreationDataStorage>;
  80448. /** @hidden */
  80449. _geometry: Nullable<Geometry>;
  80450. /** @hidden */
  80451. _delayInfo: Array<string>;
  80452. /** @hidden */
  80453. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80454. /** @hidden */
  80455. _instanceDataStorage: _InstanceDataStorage;
  80456. private _effectiveMaterial;
  80457. /** @hidden */
  80458. _shouldGenerateFlatShading: boolean;
  80459. private _preActivateId;
  80460. /** @hidden */
  80461. _originalBuilderSideOrientation: number;
  80462. /**
  80463. * Use this property to change the original side orientation defined at construction time
  80464. */
  80465. overrideMaterialSideOrientation: Nullable<number>;
  80466. private _areNormalsFrozen;
  80467. private _sourcePositions;
  80468. private _sourceNormals;
  80469. private _source;
  80470. private meshMap;
  80471. /**
  80472. * Gets the source mesh (the one used to clone this one from)
  80473. */
  80474. readonly source: Nullable<Mesh>;
  80475. /**
  80476. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80477. */
  80478. isUnIndexed: boolean;
  80479. /**
  80480. * @constructor
  80481. * @param name The value used by scene.getMeshByName() to do a lookup.
  80482. * @param scene The scene to add this mesh to.
  80483. * @param parent The parent of this mesh, if it has one
  80484. * @param source An optional Mesh from which geometry is shared, cloned.
  80485. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80486. * When false, achieved by calling a clone(), also passing False.
  80487. * This will make creation of children, recursive.
  80488. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80489. */
  80490. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80491. /**
  80492. * Gets the class name
  80493. * @returns the string "Mesh".
  80494. */
  80495. getClassName(): string;
  80496. /** @hidden */
  80497. readonly _isMesh: boolean;
  80498. /**
  80499. * Returns a description of this mesh
  80500. * @param fullDetails define if full details about this mesh must be used
  80501. * @returns a descriptive string representing this mesh
  80502. */
  80503. toString(fullDetails?: boolean): string;
  80504. /** @hidden */
  80505. _unBindEffect(): void;
  80506. /**
  80507. * Gets a boolean indicating if this mesh has LOD
  80508. */
  80509. readonly hasLODLevels: boolean;
  80510. /**
  80511. * Gets the list of MeshLODLevel associated with the current mesh
  80512. * @returns an array of MeshLODLevel
  80513. */
  80514. getLODLevels(): MeshLODLevel[];
  80515. private _sortLODLevels;
  80516. /**
  80517. * Add a mesh as LOD level triggered at the given distance.
  80518. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80519. * @param distance The distance from the center of the object to show this level
  80520. * @param mesh The mesh to be added as LOD level (can be null)
  80521. * @return This mesh (for chaining)
  80522. */
  80523. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80524. /**
  80525. * Returns the LOD level mesh at the passed distance or null if not found.
  80526. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80527. * @param distance The distance from the center of the object to show this level
  80528. * @returns a Mesh or `null`
  80529. */
  80530. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80531. /**
  80532. * Remove a mesh from the LOD array
  80533. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80534. * @param mesh defines the mesh to be removed
  80535. * @return This mesh (for chaining)
  80536. */
  80537. removeLODLevel(mesh: Mesh): Mesh;
  80538. /**
  80539. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80540. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80541. * @param camera defines the camera to use to compute distance
  80542. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80543. * @return This mesh (for chaining)
  80544. */
  80545. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80546. /**
  80547. * Gets the mesh internal Geometry object
  80548. */
  80549. readonly geometry: Nullable<Geometry>;
  80550. /**
  80551. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80552. * @returns the total number of vertices
  80553. */
  80554. getTotalVertices(): number;
  80555. /**
  80556. * Returns the content of an associated vertex buffer
  80557. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80558. * - VertexBuffer.PositionKind
  80559. * - VertexBuffer.UVKind
  80560. * - VertexBuffer.UV2Kind
  80561. * - VertexBuffer.UV3Kind
  80562. * - VertexBuffer.UV4Kind
  80563. * - VertexBuffer.UV5Kind
  80564. * - VertexBuffer.UV6Kind
  80565. * - VertexBuffer.ColorKind
  80566. * - VertexBuffer.MatricesIndicesKind
  80567. * - VertexBuffer.MatricesIndicesExtraKind
  80568. * - VertexBuffer.MatricesWeightsKind
  80569. * - VertexBuffer.MatricesWeightsExtraKind
  80570. * @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
  80571. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80572. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80573. */
  80574. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80575. /**
  80576. * Returns the mesh VertexBuffer object from the requested `kind`
  80577. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80578. * - VertexBuffer.PositionKind
  80579. * - VertexBuffer.UVKind
  80580. * - VertexBuffer.UV2Kind
  80581. * - VertexBuffer.UV3Kind
  80582. * - VertexBuffer.UV4Kind
  80583. * - VertexBuffer.UV5Kind
  80584. * - VertexBuffer.UV6Kind
  80585. * - VertexBuffer.ColorKind
  80586. * - VertexBuffer.MatricesIndicesKind
  80587. * - VertexBuffer.MatricesIndicesExtraKind
  80588. * - VertexBuffer.MatricesWeightsKind
  80589. * - VertexBuffer.MatricesWeightsExtraKind
  80590. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80591. */
  80592. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80593. /**
  80594. * Tests if a specific vertex buffer is associated with this mesh
  80595. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80596. * - VertexBuffer.PositionKind
  80597. * - VertexBuffer.UVKind
  80598. * - VertexBuffer.UV2Kind
  80599. * - VertexBuffer.UV3Kind
  80600. * - VertexBuffer.UV4Kind
  80601. * - VertexBuffer.UV5Kind
  80602. * - VertexBuffer.UV6Kind
  80603. * - VertexBuffer.ColorKind
  80604. * - VertexBuffer.MatricesIndicesKind
  80605. * - VertexBuffer.MatricesIndicesExtraKind
  80606. * - VertexBuffer.MatricesWeightsKind
  80607. * - VertexBuffer.MatricesWeightsExtraKind
  80608. * @returns a boolean
  80609. */
  80610. isVerticesDataPresent(kind: string): boolean;
  80611. /**
  80612. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80613. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80614. * - VertexBuffer.PositionKind
  80615. * - VertexBuffer.UVKind
  80616. * - VertexBuffer.UV2Kind
  80617. * - VertexBuffer.UV3Kind
  80618. * - VertexBuffer.UV4Kind
  80619. * - VertexBuffer.UV5Kind
  80620. * - VertexBuffer.UV6Kind
  80621. * - VertexBuffer.ColorKind
  80622. * - VertexBuffer.MatricesIndicesKind
  80623. * - VertexBuffer.MatricesIndicesExtraKind
  80624. * - VertexBuffer.MatricesWeightsKind
  80625. * - VertexBuffer.MatricesWeightsExtraKind
  80626. * @returns a boolean
  80627. */
  80628. isVertexBufferUpdatable(kind: string): boolean;
  80629. /**
  80630. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80631. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80632. * - VertexBuffer.PositionKind
  80633. * - VertexBuffer.UVKind
  80634. * - VertexBuffer.UV2Kind
  80635. * - VertexBuffer.UV3Kind
  80636. * - VertexBuffer.UV4Kind
  80637. * - VertexBuffer.UV5Kind
  80638. * - VertexBuffer.UV6Kind
  80639. * - VertexBuffer.ColorKind
  80640. * - VertexBuffer.MatricesIndicesKind
  80641. * - VertexBuffer.MatricesIndicesExtraKind
  80642. * - VertexBuffer.MatricesWeightsKind
  80643. * - VertexBuffer.MatricesWeightsExtraKind
  80644. * @returns an array of strings
  80645. */
  80646. getVerticesDataKinds(): string[];
  80647. /**
  80648. * Returns a positive integer : the total number of indices in this mesh geometry.
  80649. * @returns the numner of indices or zero if the mesh has no geometry.
  80650. */
  80651. getTotalIndices(): number;
  80652. /**
  80653. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80654. * @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.
  80655. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80656. * @returns the indices array or an empty array if the mesh has no geometry
  80657. */
  80658. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80659. readonly isBlocked: boolean;
  80660. /**
  80661. * Determine if the current mesh is ready to be rendered
  80662. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80663. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  80664. * @returns true if all associated assets are ready (material, textures, shaders)
  80665. */
  80666. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  80667. /**
  80668. * 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.
  80669. */
  80670. readonly areNormalsFrozen: boolean;
  80671. /**
  80672. * 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.
  80673. * @returns the current mesh
  80674. */
  80675. freezeNormals(): Mesh;
  80676. /**
  80677. * 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
  80678. * @returns the current mesh
  80679. */
  80680. unfreezeNormals(): Mesh;
  80681. /**
  80682. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  80683. */
  80684. overridenInstanceCount: number;
  80685. /** @hidden */
  80686. _preActivate(): Mesh;
  80687. /** @hidden */
  80688. _preActivateForIntermediateRendering(renderId: number): Mesh;
  80689. /** @hidden */
  80690. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  80691. /**
  80692. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80693. * This means the mesh underlying bounding box and sphere are recomputed.
  80694. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80695. * @returns the current mesh
  80696. */
  80697. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  80698. /** @hidden */
  80699. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  80700. /**
  80701. * This function will subdivide the mesh into multiple submeshes
  80702. * @param count defines the expected number of submeshes
  80703. */
  80704. subdivide(count: number): void;
  80705. /**
  80706. * Copy a FloatArray into a specific associated vertex buffer
  80707. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80708. * - VertexBuffer.PositionKind
  80709. * - VertexBuffer.UVKind
  80710. * - VertexBuffer.UV2Kind
  80711. * - VertexBuffer.UV3Kind
  80712. * - VertexBuffer.UV4Kind
  80713. * - VertexBuffer.UV5Kind
  80714. * - VertexBuffer.UV6Kind
  80715. * - VertexBuffer.ColorKind
  80716. * - VertexBuffer.MatricesIndicesKind
  80717. * - VertexBuffer.MatricesIndicesExtraKind
  80718. * - VertexBuffer.MatricesWeightsKind
  80719. * - VertexBuffer.MatricesWeightsExtraKind
  80720. * @param data defines the data source
  80721. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80722. * @param stride defines the data stride size (can be null)
  80723. * @returns the current mesh
  80724. */
  80725. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  80726. /**
  80727. * Flags an associated vertex buffer as updatable
  80728. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  80729. * - VertexBuffer.PositionKind
  80730. * - VertexBuffer.UVKind
  80731. * - VertexBuffer.UV2Kind
  80732. * - VertexBuffer.UV3Kind
  80733. * - VertexBuffer.UV4Kind
  80734. * - VertexBuffer.UV5Kind
  80735. * - VertexBuffer.UV6Kind
  80736. * - VertexBuffer.ColorKind
  80737. * - VertexBuffer.MatricesIndicesKind
  80738. * - VertexBuffer.MatricesIndicesExtraKind
  80739. * - VertexBuffer.MatricesWeightsKind
  80740. * - VertexBuffer.MatricesWeightsExtraKind
  80741. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80742. */
  80743. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  80744. /**
  80745. * Sets the mesh global Vertex Buffer
  80746. * @param buffer defines the buffer to use
  80747. * @returns the current mesh
  80748. */
  80749. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  80750. /**
  80751. * Update a specific associated vertex buffer
  80752. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80753. * - VertexBuffer.PositionKind
  80754. * - VertexBuffer.UVKind
  80755. * - VertexBuffer.UV2Kind
  80756. * - VertexBuffer.UV3Kind
  80757. * - VertexBuffer.UV4Kind
  80758. * - VertexBuffer.UV5Kind
  80759. * - VertexBuffer.UV6Kind
  80760. * - VertexBuffer.ColorKind
  80761. * - VertexBuffer.MatricesIndicesKind
  80762. * - VertexBuffer.MatricesIndicesExtraKind
  80763. * - VertexBuffer.MatricesWeightsKind
  80764. * - VertexBuffer.MatricesWeightsExtraKind
  80765. * @param data defines the data source
  80766. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80767. * @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)
  80768. * @returns the current mesh
  80769. */
  80770. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  80771. /**
  80772. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  80773. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  80774. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  80775. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  80776. * @returns the current mesh
  80777. */
  80778. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  80779. /**
  80780. * Creates a un-shared specific occurence of the geometry for the mesh.
  80781. * @returns the current mesh
  80782. */
  80783. makeGeometryUnique(): Mesh;
  80784. /**
  80785. * Set the index buffer of this mesh
  80786. * @param indices defines the source data
  80787. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  80788. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  80789. * @returns the current mesh
  80790. */
  80791. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  80792. /**
  80793. * Update the current index buffer
  80794. * @param indices defines the source data
  80795. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  80796. * @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)
  80797. * @returns the current mesh
  80798. */
  80799. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  80800. /**
  80801. * Invert the geometry to move from a right handed system to a left handed one.
  80802. * @returns the current mesh
  80803. */
  80804. toLeftHanded(): Mesh;
  80805. /** @hidden */
  80806. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  80807. /** @hidden */
  80808. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  80809. /**
  80810. * Registers for this mesh a javascript function called just before the rendering process
  80811. * @param func defines the function to call before rendering this mesh
  80812. * @returns the current mesh
  80813. */
  80814. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80815. /**
  80816. * Disposes a previously registered javascript function called before the rendering
  80817. * @param func defines the function to remove
  80818. * @returns the current mesh
  80819. */
  80820. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80821. /**
  80822. * Registers for this mesh a javascript function called just after the rendering is complete
  80823. * @param func defines the function to call after rendering this mesh
  80824. * @returns the current mesh
  80825. */
  80826. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80827. /**
  80828. * Disposes a previously registered javascript function called after the rendering.
  80829. * @param func defines the function to remove
  80830. * @returns the current mesh
  80831. */
  80832. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80833. /** @hidden */
  80834. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80835. /** @hidden */
  80836. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80837. /** @hidden */
  80838. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80839. /** @hidden */
  80840. _freeze(): void;
  80841. /** @hidden */
  80842. _unFreeze(): void;
  80843. /**
  80844. * 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
  80845. * @param subMesh defines the subMesh to render
  80846. * @param enableAlphaMode defines if alpha mode can be changed
  80847. * @returns the current mesh
  80848. */
  80849. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80850. private _onBeforeDraw;
  80851. /**
  80852. * Renormalize the mesh and patch it up if there are no weights
  80853. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80854. * However in the case of zero weights then we set just a single influence to 1.
  80855. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80856. */
  80857. cleanMatrixWeights(): void;
  80858. private normalizeSkinFourWeights;
  80859. private normalizeSkinWeightsAndExtra;
  80860. /**
  80861. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80862. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80863. * the user know there was an issue with importing the mesh
  80864. * @returns a validation object with skinned, valid and report string
  80865. */
  80866. validateSkinning(): {
  80867. skinned: boolean;
  80868. valid: boolean;
  80869. report: string;
  80870. };
  80871. /** @hidden */
  80872. _checkDelayState(): Mesh;
  80873. private _queueLoad;
  80874. /**
  80875. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80876. * A mesh is in the frustum if its bounding box intersects the frustum
  80877. * @param frustumPlanes defines the frustum to test
  80878. * @returns true if the mesh is in the frustum planes
  80879. */
  80880. isInFrustum(frustumPlanes: Plane[]): boolean;
  80881. /**
  80882. * Sets the mesh material by the material or multiMaterial `id` property
  80883. * @param id is a string identifying the material or the multiMaterial
  80884. * @returns the current mesh
  80885. */
  80886. setMaterialByID(id: string): Mesh;
  80887. /**
  80888. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  80889. * @returns an array of IAnimatable
  80890. */
  80891. getAnimatables(): IAnimatable[];
  80892. /**
  80893. * Modifies the mesh geometry according to the passed transformation matrix.
  80894. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  80895. * The mesh normals are modified using the same transformation.
  80896. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80897. * @param transform defines the transform matrix to use
  80898. * @see http://doc.babylonjs.com/resources/baking_transformations
  80899. * @returns the current mesh
  80900. */
  80901. bakeTransformIntoVertices(transform: Matrix): Mesh;
  80902. /**
  80903. * Modifies the mesh geometry according to its own current World Matrix.
  80904. * The mesh World Matrix is then reset.
  80905. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  80906. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80907. * @see http://doc.babylonjs.com/resources/baking_transformations
  80908. * @returns the current mesh
  80909. */
  80910. bakeCurrentTransformIntoVertices(): Mesh;
  80911. /** @hidden */
  80912. readonly _positions: Nullable<Vector3[]>;
  80913. /** @hidden */
  80914. _resetPointsArrayCache(): Mesh;
  80915. /** @hidden */
  80916. _generatePointsArray(): boolean;
  80917. /**
  80918. * Returns a new Mesh object generated from the current mesh properties.
  80919. * This method must not get confused with createInstance()
  80920. * @param name is a string, the name given to the new mesh
  80921. * @param newParent can be any Node object (default `null`)
  80922. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  80923. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  80924. * @returns a new mesh
  80925. */
  80926. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  80927. /**
  80928. * Releases resources associated with this mesh.
  80929. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80930. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80931. */
  80932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80933. /**
  80934. * Modifies the mesh geometry according to a displacement map.
  80935. * 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.
  80936. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80937. * @param url is a string, the URL from the image file is to be downloaded.
  80938. * @param minHeight is the lower limit of the displacement.
  80939. * @param maxHeight is the upper limit of the displacement.
  80940. * @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.
  80941. * @param uvOffset is an optional vector2 used to offset UV.
  80942. * @param uvScale is an optional vector2 used to scale UV.
  80943. * @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.
  80944. * @returns the Mesh.
  80945. */
  80946. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80947. /**
  80948. * Modifies the mesh geometry according to a displacementMap buffer.
  80949. * 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.
  80950. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80951. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  80952. * @param heightMapWidth is the width of the buffer image.
  80953. * @param heightMapHeight is the height of the buffer image.
  80954. * @param minHeight is the lower limit of the displacement.
  80955. * @param maxHeight is the upper limit of the displacement.
  80956. * @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.
  80957. * @param uvOffset is an optional vector2 used to offset UV.
  80958. * @param uvScale is an optional vector2 used to scale UV.
  80959. * @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.
  80960. * @returns the Mesh.
  80961. */
  80962. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80963. /**
  80964. * Modify the mesh to get a flat shading rendering.
  80965. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  80966. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  80967. * @returns current mesh
  80968. */
  80969. convertToFlatShadedMesh(): Mesh;
  80970. /**
  80971. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  80972. * In other words, more vertices, no more indices and a single bigger VBO.
  80973. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  80974. * @returns current mesh
  80975. */
  80976. convertToUnIndexedMesh(): Mesh;
  80977. /**
  80978. * Inverses facet orientations.
  80979. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80980. * @param flipNormals will also inverts the normals
  80981. * @returns current mesh
  80982. */
  80983. flipFaces(flipNormals?: boolean): Mesh;
  80984. /**
  80985. * Increase the number of facets and hence vertices in a mesh
  80986. * Vertex normals are interpolated from existing vertex normals
  80987. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80988. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  80989. */
  80990. increaseVertices(numberPerEdge: number): void;
  80991. /**
  80992. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  80993. * This will undo any application of covertToFlatShadedMesh
  80994. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80995. */
  80996. forceSharedVertices(): void;
  80997. /** @hidden */
  80998. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  80999. /** @hidden */
  81000. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81001. /**
  81002. * Creates a new InstancedMesh object from the mesh model.
  81003. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81004. * @param name defines the name of the new instance
  81005. * @returns a new InstancedMesh
  81006. */
  81007. createInstance(name: string): InstancedMesh;
  81008. /**
  81009. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81010. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81011. * @returns the current mesh
  81012. */
  81013. synchronizeInstances(): Mesh;
  81014. /**
  81015. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81016. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81017. * This should be used together with the simplification to avoid disappearing triangles.
  81018. * @param successCallback an optional success callback to be called after the optimization finished.
  81019. * @returns the current mesh
  81020. */
  81021. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81022. /**
  81023. * Serialize current mesh
  81024. * @param serializationObject defines the object which will receive the serialization data
  81025. */
  81026. serialize(serializationObject: any): void;
  81027. /** @hidden */
  81028. _syncGeometryWithMorphTargetManager(): void;
  81029. /** @hidden */
  81030. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81031. /**
  81032. * Returns a new Mesh object parsed from the source provided.
  81033. * @param parsedMesh is the source
  81034. * @param scene defines the hosting scene
  81035. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81036. * @returns a new Mesh
  81037. */
  81038. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81039. /**
  81040. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81041. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81042. * @param name defines the name of the mesh to create
  81043. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81044. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81045. * @param closePath creates a seam between the first and the last points of each path of the path array
  81046. * @param offset is taken in account only if the `pathArray` is containing a single path
  81047. * @param scene defines the hosting scene
  81048. * @param updatable defines if the mesh must be flagged as updatable
  81049. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81050. * @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)
  81051. * @returns a new Mesh
  81052. */
  81053. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81054. /**
  81055. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81056. * @param name defines the name of the mesh to create
  81057. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81058. * @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
  81059. * @param scene defines the hosting scene
  81060. * @param updatable defines if the mesh must be flagged as updatable
  81061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81062. * @returns a new Mesh
  81063. */
  81064. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81065. /**
  81066. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81067. * @param name defines the name of the mesh to create
  81068. * @param size sets the size (float) of each box side (default 1)
  81069. * @param scene defines the hosting scene
  81070. * @param updatable defines if the mesh must be flagged as updatable
  81071. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81072. * @returns a new Mesh
  81073. */
  81074. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81075. /**
  81076. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81077. * @param name defines the name of the mesh to create
  81078. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81079. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81080. * @param scene defines the hosting scene
  81081. * @param updatable defines if the mesh must be flagged as updatable
  81082. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81083. * @returns a new Mesh
  81084. */
  81085. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81086. /**
  81087. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81088. * @param name defines the name of the mesh to create
  81089. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81090. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81091. * @param scene defines the hosting scene
  81092. * @returns a new Mesh
  81093. */
  81094. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81095. /**
  81096. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81097. * @param name defines the name of the mesh to create
  81098. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81099. * @param diameterTop set the top cap diameter (floats, default 1)
  81100. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81101. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81102. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81103. * @param scene defines the hosting scene
  81104. * @param updatable defines if the mesh must be flagged as updatable
  81105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81106. * @returns a new Mesh
  81107. */
  81108. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81109. /**
  81110. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81111. * @param name defines the name of the mesh to create
  81112. * @param diameter sets the diameter size (float) of the torus (default 1)
  81113. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81114. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81115. * @param scene defines the hosting scene
  81116. * @param updatable defines if the mesh must be flagged as updatable
  81117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81118. * @returns a new Mesh
  81119. */
  81120. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81121. /**
  81122. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81123. * @param name defines the name of the mesh to create
  81124. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81125. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81126. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81127. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81128. * @param p the number of windings on X axis (positive integers, default 2)
  81129. * @param q the number of windings on Y axis (positive integers, default 3)
  81130. * @param scene defines the hosting scene
  81131. * @param updatable defines if the mesh must be flagged as updatable
  81132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81133. * @returns a new Mesh
  81134. */
  81135. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81136. /**
  81137. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81138. * @param name defines the name of the mesh to create
  81139. * @param points is an array successive Vector3
  81140. * @param scene defines the hosting scene
  81141. * @param updatable defines if the mesh must be flagged as updatable
  81142. * @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).
  81143. * @returns a new Mesh
  81144. */
  81145. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81146. /**
  81147. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81148. * @param name defines the name of the mesh to create
  81149. * @param points is an array successive Vector3
  81150. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81151. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81152. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81153. * @param scene defines the hosting scene
  81154. * @param updatable defines if the mesh must be flagged as updatable
  81155. * @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)
  81156. * @returns a new Mesh
  81157. */
  81158. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81159. /**
  81160. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81161. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81162. * 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.
  81163. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81164. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81165. * Remember you can only change the shape positions, not their number when updating a polygon.
  81166. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81167. * @param name defines the name of the mesh to create
  81168. * @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
  81169. * @param scene defines the hosting scene
  81170. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81171. * @param updatable defines if the mesh must be flagged as updatable
  81172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81173. * @param earcutInjection can be used to inject your own earcut reference
  81174. * @returns a new Mesh
  81175. */
  81176. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81177. /**
  81178. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81179. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81180. * @param name defines the name of the mesh to create
  81181. * @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
  81182. * @param depth defines the height of extrusion
  81183. * @param scene defines the hosting scene
  81184. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81185. * @param updatable defines if the mesh must be flagged as updatable
  81186. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81187. * @param earcutInjection can be used to inject your own earcut reference
  81188. * @returns a new Mesh
  81189. */
  81190. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81191. /**
  81192. * Creates an extruded shape mesh.
  81193. * 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
  81194. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81195. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81196. * @param name defines the name of the mesh to create
  81197. * @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
  81198. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81199. * @param scale is the value to scale the shape
  81200. * @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
  81201. * @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
  81202. * @param scene defines the hosting scene
  81203. * @param updatable defines if the mesh must be flagged as updatable
  81204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81205. * @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)
  81206. * @returns a new Mesh
  81207. */
  81208. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81209. /**
  81210. * Creates an custom extruded shape mesh.
  81211. * The custom extrusion is a parametric shape.
  81212. * It has no predefined shape. Its final shape will depend on the input parameters.
  81213. * Please consider using the same method from the MeshBuilder class instead
  81214. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81215. * @param name defines the name of the mesh to create
  81216. * @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
  81217. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81218. * @param scaleFunction is a custom Javascript function called on each path point
  81219. * @param rotationFunction is a custom Javascript function called on each path point
  81220. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81221. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81222. * @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
  81223. * @param scene defines the hosting scene
  81224. * @param updatable defines if the mesh must be flagged as updatable
  81225. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81226. * @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)
  81227. * @returns a new Mesh
  81228. */
  81229. 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;
  81230. /**
  81231. * Creates lathe mesh.
  81232. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81233. * Please consider using the same method from the MeshBuilder class instead
  81234. * @param name defines the name of the mesh to create
  81235. * @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
  81236. * @param radius is the radius value of the lathe
  81237. * @param tessellation is the side number of the lathe.
  81238. * @param scene defines the hosting scene
  81239. * @param updatable defines if the mesh must be flagged as updatable
  81240. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81241. * @returns a new Mesh
  81242. */
  81243. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81244. /**
  81245. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81246. * @param name defines the name of the mesh to create
  81247. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81248. * @param scene defines the hosting scene
  81249. * @param updatable defines if the mesh must be flagged as updatable
  81250. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81251. * @returns a new Mesh
  81252. */
  81253. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81254. /**
  81255. * Creates a ground mesh.
  81256. * Please consider using the same method from the MeshBuilder class instead
  81257. * @param name defines the name of the mesh to create
  81258. * @param width set the width of the ground
  81259. * @param height set the height of the ground
  81260. * @param subdivisions sets the number of subdivisions per side
  81261. * @param scene defines the hosting scene
  81262. * @param updatable defines if the mesh must be flagged as updatable
  81263. * @returns a new Mesh
  81264. */
  81265. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81266. /**
  81267. * Creates a tiled ground mesh.
  81268. * Please consider using the same method from the MeshBuilder class instead
  81269. * @param name defines the name of the mesh to create
  81270. * @param xmin set the ground minimum X coordinate
  81271. * @param zmin set the ground minimum Y coordinate
  81272. * @param xmax set the ground maximum X coordinate
  81273. * @param zmax set the ground maximum Z coordinate
  81274. * @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
  81275. * @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
  81276. * @param scene defines the hosting scene
  81277. * @param updatable defines if the mesh must be flagged as updatable
  81278. * @returns a new Mesh
  81279. */
  81280. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81281. w: number;
  81282. h: number;
  81283. }, precision: {
  81284. w: number;
  81285. h: number;
  81286. }, scene: Scene, updatable?: boolean): Mesh;
  81287. /**
  81288. * Creates a ground mesh from a height map.
  81289. * Please consider using the same method from the MeshBuilder class instead
  81290. * @see http://doc.babylonjs.com/babylon101/height_map
  81291. * @param name defines the name of the mesh to create
  81292. * @param url sets the URL of the height map image resource
  81293. * @param width set the ground width size
  81294. * @param height set the ground height size
  81295. * @param subdivisions sets the number of subdivision per side
  81296. * @param minHeight is the minimum altitude on the ground
  81297. * @param maxHeight is the maximum altitude on the ground
  81298. * @param scene defines the hosting scene
  81299. * @param updatable defines if the mesh must be flagged as updatable
  81300. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81301. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81302. * @returns a new Mesh
  81303. */
  81304. 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;
  81305. /**
  81306. * Creates a tube mesh.
  81307. * The tube is a parametric shape.
  81308. * It has no predefined shape. Its final shape will depend on the input parameters.
  81309. * Please consider using the same method from the MeshBuilder class instead
  81310. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81311. * @param name defines the name of the mesh to create
  81312. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81313. * @param radius sets the tube radius size
  81314. * @param tessellation is the number of sides on the tubular surface
  81315. * @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
  81316. * @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
  81317. * @param scene defines the hosting scene
  81318. * @param updatable defines if the mesh must be flagged as updatable
  81319. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81320. * @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)
  81321. * @returns a new Mesh
  81322. */
  81323. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81324. (i: number, distance: number): number;
  81325. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81326. /**
  81327. * Creates a polyhedron mesh.
  81328. * Please consider using the same method from the MeshBuilder class instead.
  81329. * * 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
  81330. * * The parameter `size` (positive float, default 1) sets the polygon size
  81331. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81332. * * 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`
  81333. * * 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
  81334. * * 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)`)
  81335. * * 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
  81336. * * 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
  81337. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81338. * * If you create a double-sided mesh, you can choose what parts of 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
  81339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81340. * @param name defines the name of the mesh to create
  81341. * @param options defines the options used to create the mesh
  81342. * @param scene defines the hosting scene
  81343. * @returns a new Mesh
  81344. */
  81345. static CreatePolyhedron(name: string, options: {
  81346. type?: number;
  81347. size?: number;
  81348. sizeX?: number;
  81349. sizeY?: number;
  81350. sizeZ?: number;
  81351. custom?: any;
  81352. faceUV?: Vector4[];
  81353. faceColors?: Color4[];
  81354. updatable?: boolean;
  81355. sideOrientation?: number;
  81356. }, scene: Scene): Mesh;
  81357. /**
  81358. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81359. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81360. * * 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`)
  81361. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81362. * * 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
  81363. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81364. * * If you create a double-sided mesh, you can choose what parts of 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
  81365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81366. * @param name defines the name of the mesh
  81367. * @param options defines the options used to create the mesh
  81368. * @param scene defines the hosting scene
  81369. * @returns a new Mesh
  81370. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81371. */
  81372. static CreateIcoSphere(name: string, options: {
  81373. radius?: number;
  81374. flat?: boolean;
  81375. subdivisions?: number;
  81376. sideOrientation?: number;
  81377. updatable?: boolean;
  81378. }, scene: Scene): Mesh;
  81379. /**
  81380. * Creates a decal mesh.
  81381. * Please consider using the same method from the MeshBuilder class instead.
  81382. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81383. * @param name defines the name of the mesh
  81384. * @param sourceMesh defines the mesh receiving the decal
  81385. * @param position sets the position of the decal in world coordinates
  81386. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81387. * @param size sets the decal scaling
  81388. * @param angle sets the angle to rotate the decal
  81389. * @returns a new Mesh
  81390. */
  81391. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81392. /**
  81393. * Prepare internal position array for software CPU skinning
  81394. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81395. */
  81396. setPositionsForCPUSkinning(): Float32Array;
  81397. /**
  81398. * Prepare internal normal array for software CPU skinning
  81399. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81400. */
  81401. setNormalsForCPUSkinning(): Float32Array;
  81402. /**
  81403. * Updates the vertex buffer by applying transformation from the bones
  81404. * @param skeleton defines the skeleton to apply to current mesh
  81405. * @returns the current mesh
  81406. */
  81407. applySkeleton(skeleton: Skeleton): Mesh;
  81408. /**
  81409. * 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
  81410. * @param meshes defines the list of meshes to scan
  81411. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81412. */
  81413. static MinMax(meshes: AbstractMesh[]): {
  81414. min: Vector3;
  81415. max: Vector3;
  81416. };
  81417. /**
  81418. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81419. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81420. * @returns a vector3
  81421. */
  81422. static Center(meshesOrMinMaxVector: {
  81423. min: Vector3;
  81424. max: Vector3;
  81425. } | AbstractMesh[]): Vector3;
  81426. /**
  81427. * Merge the array of meshes into a single mesh for performance reasons.
  81428. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81429. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81430. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81431. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81432. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81433. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81434. * @returns a new mesh
  81435. */
  81436. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81437. /** @hidden */
  81438. addInstance(instance: InstancedMesh): void;
  81439. /** @hidden */
  81440. removeInstance(instance: InstancedMesh): void;
  81441. }
  81442. }
  81443. declare module BABYLON {
  81444. /**
  81445. * Base class for the main features of a material in Babylon.js
  81446. */
  81447. export class Material implements IAnimatable {
  81448. /**
  81449. * Returns the triangle fill mode
  81450. */
  81451. static readonly TriangleFillMode: number;
  81452. /**
  81453. * Returns the wireframe mode
  81454. */
  81455. static readonly WireFrameFillMode: number;
  81456. /**
  81457. * Returns the point fill mode
  81458. */
  81459. static readonly PointFillMode: number;
  81460. /**
  81461. * Returns the point list draw mode
  81462. */
  81463. static readonly PointListDrawMode: number;
  81464. /**
  81465. * Returns the line list draw mode
  81466. */
  81467. static readonly LineListDrawMode: number;
  81468. /**
  81469. * Returns the line loop draw mode
  81470. */
  81471. static readonly LineLoopDrawMode: number;
  81472. /**
  81473. * Returns the line strip draw mode
  81474. */
  81475. static readonly LineStripDrawMode: number;
  81476. /**
  81477. * Returns the triangle strip draw mode
  81478. */
  81479. static readonly TriangleStripDrawMode: number;
  81480. /**
  81481. * Returns the triangle fan draw mode
  81482. */
  81483. static readonly TriangleFanDrawMode: number;
  81484. /**
  81485. * Stores the clock-wise side orientation
  81486. */
  81487. static readonly ClockWiseSideOrientation: number;
  81488. /**
  81489. * Stores the counter clock-wise side orientation
  81490. */
  81491. static readonly CounterClockWiseSideOrientation: number;
  81492. /**
  81493. * The dirty texture flag value
  81494. */
  81495. static readonly TextureDirtyFlag: number;
  81496. /**
  81497. * The dirty light flag value
  81498. */
  81499. static readonly LightDirtyFlag: number;
  81500. /**
  81501. * The dirty fresnel flag value
  81502. */
  81503. static readonly FresnelDirtyFlag: number;
  81504. /**
  81505. * The dirty attribute flag value
  81506. */
  81507. static readonly AttributesDirtyFlag: number;
  81508. /**
  81509. * The dirty misc flag value
  81510. */
  81511. static readonly MiscDirtyFlag: number;
  81512. /**
  81513. * The all dirty flag value
  81514. */
  81515. static readonly AllDirtyFlag: number;
  81516. /**
  81517. * The ID of the material
  81518. */
  81519. id: string;
  81520. /**
  81521. * Gets or sets the unique id of the material
  81522. */
  81523. uniqueId: number;
  81524. /**
  81525. * The name of the material
  81526. */
  81527. name: string;
  81528. /**
  81529. * Gets or sets user defined metadata
  81530. */
  81531. metadata: any;
  81532. /**
  81533. * For internal use only. Please do not use.
  81534. */
  81535. reservedDataStore: any;
  81536. /**
  81537. * Specifies if the ready state should be checked on each call
  81538. */
  81539. checkReadyOnEveryCall: boolean;
  81540. /**
  81541. * Specifies if the ready state should be checked once
  81542. */
  81543. checkReadyOnlyOnce: boolean;
  81544. /**
  81545. * The state of the material
  81546. */
  81547. state: string;
  81548. /**
  81549. * The alpha value of the material
  81550. */
  81551. protected _alpha: number;
  81552. /**
  81553. * List of inspectable custom properties (used by the Inspector)
  81554. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81555. */
  81556. inspectableCustomProperties: IInspectable[];
  81557. /**
  81558. * Sets the alpha value of the material
  81559. */
  81560. /**
  81561. * Gets the alpha value of the material
  81562. */
  81563. alpha: number;
  81564. /**
  81565. * Specifies if back face culling is enabled
  81566. */
  81567. protected _backFaceCulling: boolean;
  81568. /**
  81569. * Sets the back-face culling state
  81570. */
  81571. /**
  81572. * Gets the back-face culling state
  81573. */
  81574. backFaceCulling: boolean;
  81575. /**
  81576. * Stores the value for side orientation
  81577. */
  81578. sideOrientation: number;
  81579. /**
  81580. * Callback triggered when the material is compiled
  81581. */
  81582. onCompiled: Nullable<(effect: Effect) => void>;
  81583. /**
  81584. * Callback triggered when an error occurs
  81585. */
  81586. onError: Nullable<(effect: Effect, errors: string) => void>;
  81587. /**
  81588. * Callback triggered to get the render target textures
  81589. */
  81590. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  81591. /**
  81592. * Gets a boolean indicating that current material needs to register RTT
  81593. */
  81594. readonly hasRenderTargetTextures: boolean;
  81595. /**
  81596. * Specifies if the material should be serialized
  81597. */
  81598. doNotSerialize: boolean;
  81599. /**
  81600. * @hidden
  81601. */
  81602. _storeEffectOnSubMeshes: boolean;
  81603. /**
  81604. * Stores the animations for the material
  81605. */
  81606. animations: Nullable<Array<Animation>>;
  81607. /**
  81608. * An event triggered when the material is disposed
  81609. */
  81610. onDisposeObservable: Observable<Material>;
  81611. /**
  81612. * An observer which watches for dispose events
  81613. */
  81614. private _onDisposeObserver;
  81615. private _onUnBindObservable;
  81616. /**
  81617. * Called during a dispose event
  81618. */
  81619. onDispose: () => void;
  81620. private _onBindObservable;
  81621. /**
  81622. * An event triggered when the material is bound
  81623. */
  81624. readonly onBindObservable: Observable<AbstractMesh>;
  81625. /**
  81626. * An observer which watches for bind events
  81627. */
  81628. private _onBindObserver;
  81629. /**
  81630. * Called during a bind event
  81631. */
  81632. onBind: (Mesh: AbstractMesh) => void;
  81633. /**
  81634. * An event triggered when the material is unbound
  81635. */
  81636. readonly onUnBindObservable: Observable<Material>;
  81637. /**
  81638. * Stores the value of the alpha mode
  81639. */
  81640. private _alphaMode;
  81641. /**
  81642. * Sets the value of the alpha mode.
  81643. *
  81644. * | Value | Type | Description |
  81645. * | --- | --- | --- |
  81646. * | 0 | ALPHA_DISABLE | |
  81647. * | 1 | ALPHA_ADD | |
  81648. * | 2 | ALPHA_COMBINE | |
  81649. * | 3 | ALPHA_SUBTRACT | |
  81650. * | 4 | ALPHA_MULTIPLY | |
  81651. * | 5 | ALPHA_MAXIMIZED | |
  81652. * | 6 | ALPHA_ONEONE | |
  81653. * | 7 | ALPHA_PREMULTIPLIED | |
  81654. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  81655. * | 9 | ALPHA_INTERPOLATE | |
  81656. * | 10 | ALPHA_SCREENMODE | |
  81657. *
  81658. */
  81659. /**
  81660. * Gets the value of the alpha mode
  81661. */
  81662. alphaMode: number;
  81663. /**
  81664. * Stores the state of the need depth pre-pass value
  81665. */
  81666. private _needDepthPrePass;
  81667. /**
  81668. * Sets the need depth pre-pass value
  81669. */
  81670. /**
  81671. * Gets the depth pre-pass value
  81672. */
  81673. needDepthPrePass: boolean;
  81674. /**
  81675. * Specifies if depth writing should be disabled
  81676. */
  81677. disableDepthWrite: boolean;
  81678. /**
  81679. * Specifies if depth writing should be forced
  81680. */
  81681. forceDepthWrite: boolean;
  81682. /**
  81683. * Specifies if there should be a separate pass for culling
  81684. */
  81685. separateCullingPass: boolean;
  81686. /**
  81687. * Stores the state specifing if fog should be enabled
  81688. */
  81689. private _fogEnabled;
  81690. /**
  81691. * Sets the state for enabling fog
  81692. */
  81693. /**
  81694. * Gets the value of the fog enabled state
  81695. */
  81696. fogEnabled: boolean;
  81697. /**
  81698. * Stores the size of points
  81699. */
  81700. pointSize: number;
  81701. /**
  81702. * Stores the z offset value
  81703. */
  81704. zOffset: number;
  81705. /**
  81706. * Gets a value specifying if wireframe mode is enabled
  81707. */
  81708. /**
  81709. * Sets the state of wireframe mode
  81710. */
  81711. wireframe: boolean;
  81712. /**
  81713. * Gets the value specifying if point clouds are enabled
  81714. */
  81715. /**
  81716. * Sets the state of point cloud mode
  81717. */
  81718. pointsCloud: boolean;
  81719. /**
  81720. * Gets the material fill mode
  81721. */
  81722. /**
  81723. * Sets the material fill mode
  81724. */
  81725. fillMode: number;
  81726. /**
  81727. * @hidden
  81728. * Stores the effects for the material
  81729. */
  81730. _effect: Nullable<Effect>;
  81731. /**
  81732. * @hidden
  81733. * Specifies if the material was previously ready
  81734. */
  81735. _wasPreviouslyReady: boolean;
  81736. /**
  81737. * Specifies if uniform buffers should be used
  81738. */
  81739. private _useUBO;
  81740. /**
  81741. * Stores a reference to the scene
  81742. */
  81743. private _scene;
  81744. /**
  81745. * Stores the fill mode state
  81746. */
  81747. private _fillMode;
  81748. /**
  81749. * Specifies if the depth write state should be cached
  81750. */
  81751. private _cachedDepthWriteState;
  81752. /**
  81753. * Stores the uniform buffer
  81754. */
  81755. protected _uniformBuffer: UniformBuffer;
  81756. /** @hidden */
  81757. _indexInSceneMaterialArray: number;
  81758. /** @hidden */
  81759. meshMap: Nullable<{
  81760. [id: string]: AbstractMesh | undefined;
  81761. }>;
  81762. /**
  81763. * Creates a material instance
  81764. * @param name defines the name of the material
  81765. * @param scene defines the scene to reference
  81766. * @param doNotAdd specifies if the material should be added to the scene
  81767. */
  81768. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  81769. /**
  81770. * Returns a string representation of the current material
  81771. * @param fullDetails defines a boolean indicating which levels of logging is desired
  81772. * @returns a string with material information
  81773. */
  81774. toString(fullDetails?: boolean): string;
  81775. /**
  81776. * Gets the class name of the material
  81777. * @returns a string with the class name of the material
  81778. */
  81779. getClassName(): string;
  81780. /**
  81781. * Specifies if updates for the material been locked
  81782. */
  81783. readonly isFrozen: boolean;
  81784. /**
  81785. * Locks updates for the material
  81786. */
  81787. freeze(): void;
  81788. /**
  81789. * Unlocks updates for the material
  81790. */
  81791. unfreeze(): void;
  81792. /**
  81793. * Specifies if the material is ready to be used
  81794. * @param mesh defines the mesh to check
  81795. * @param useInstances specifies if instances should be used
  81796. * @returns a boolean indicating if the material is ready to be used
  81797. */
  81798. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  81799. /**
  81800. * Specifies that the submesh is ready to be used
  81801. * @param mesh defines the mesh to check
  81802. * @param subMesh defines which submesh to check
  81803. * @param useInstances specifies that instances should be used
  81804. * @returns a boolean indicating that the submesh is ready or not
  81805. */
  81806. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  81807. /**
  81808. * Returns the material effect
  81809. * @returns the effect associated with the material
  81810. */
  81811. getEffect(): Nullable<Effect>;
  81812. /**
  81813. * Returns the current scene
  81814. * @returns a Scene
  81815. */
  81816. getScene(): Scene;
  81817. /**
  81818. * Specifies if the material will require alpha blending
  81819. * @returns a boolean specifying if alpha blending is needed
  81820. */
  81821. needAlphaBlending(): boolean;
  81822. /**
  81823. * Specifies if the mesh will require alpha blending
  81824. * @param mesh defines the mesh to check
  81825. * @returns a boolean specifying if alpha blending is needed for the mesh
  81826. */
  81827. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  81828. /**
  81829. * Specifies if this material should be rendered in alpha test mode
  81830. * @returns a boolean specifying if an alpha test is needed.
  81831. */
  81832. needAlphaTesting(): boolean;
  81833. /**
  81834. * Gets the texture used for the alpha test
  81835. * @returns the texture to use for alpha testing
  81836. */
  81837. getAlphaTestTexture(): Nullable<BaseTexture>;
  81838. /**
  81839. * Marks the material to indicate that it needs to be re-calculated
  81840. */
  81841. markDirty(): void;
  81842. /** @hidden */
  81843. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81844. /**
  81845. * Binds the material to the mesh
  81846. * @param world defines the world transformation matrix
  81847. * @param mesh defines the mesh to bind the material to
  81848. */
  81849. bind(world: Matrix, mesh?: Mesh): void;
  81850. /**
  81851. * Binds the submesh to the material
  81852. * @param world defines the world transformation matrix
  81853. * @param mesh defines the mesh containing the submesh
  81854. * @param subMesh defines the submesh to bind the material to
  81855. */
  81856. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81857. /**
  81858. * Binds the world matrix to the material
  81859. * @param world defines the world transformation matrix
  81860. */
  81861. bindOnlyWorldMatrix(world: Matrix): void;
  81862. /**
  81863. * Binds the scene's uniform buffer to the effect.
  81864. * @param effect defines the effect to bind to the scene uniform buffer
  81865. * @param sceneUbo defines the uniform buffer storing scene data
  81866. */
  81867. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81868. /**
  81869. * Binds the view matrix to the effect
  81870. * @param effect defines the effect to bind the view matrix to
  81871. */
  81872. bindView(effect: Effect): void;
  81873. /**
  81874. * Binds the view projection matrix to the effect
  81875. * @param effect defines the effect to bind the view projection matrix to
  81876. */
  81877. bindViewProjection(effect: Effect): void;
  81878. /**
  81879. * Specifies if material alpha testing should be turned on for the mesh
  81880. * @param mesh defines the mesh to check
  81881. */
  81882. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  81883. /**
  81884. * Processes to execute after binding the material to a mesh
  81885. * @param mesh defines the rendered mesh
  81886. */
  81887. protected _afterBind(mesh?: Mesh): void;
  81888. /**
  81889. * Unbinds the material from the mesh
  81890. */
  81891. unbind(): void;
  81892. /**
  81893. * Gets the active textures from the material
  81894. * @returns an array of textures
  81895. */
  81896. getActiveTextures(): BaseTexture[];
  81897. /**
  81898. * Specifies if the material uses a texture
  81899. * @param texture defines the texture to check against the material
  81900. * @returns a boolean specifying if the material uses the texture
  81901. */
  81902. hasTexture(texture: BaseTexture): boolean;
  81903. /**
  81904. * Makes a duplicate of the material, and gives it a new name
  81905. * @param name defines the new name for the duplicated material
  81906. * @returns the cloned material
  81907. */
  81908. clone(name: string): Nullable<Material>;
  81909. /**
  81910. * Gets the meshes bound to the material
  81911. * @returns an array of meshes bound to the material
  81912. */
  81913. getBindedMeshes(): AbstractMesh[];
  81914. /**
  81915. * Force shader compilation
  81916. * @param mesh defines the mesh associated with this material
  81917. * @param onCompiled defines a function to execute once the material is compiled
  81918. * @param options defines the options to configure the compilation
  81919. */
  81920. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  81921. clipPlane: boolean;
  81922. }>): void;
  81923. /**
  81924. * Force shader compilation
  81925. * @param mesh defines the mesh that will use this material
  81926. * @param options defines additional options for compiling the shaders
  81927. * @returns a promise that resolves when the compilation completes
  81928. */
  81929. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  81930. clipPlane: boolean;
  81931. }>): Promise<void>;
  81932. private static readonly _ImageProcessingDirtyCallBack;
  81933. private static readonly _TextureDirtyCallBack;
  81934. private static readonly _FresnelDirtyCallBack;
  81935. private static readonly _MiscDirtyCallBack;
  81936. private static readonly _LightsDirtyCallBack;
  81937. private static readonly _AttributeDirtyCallBack;
  81938. private static _FresnelAndMiscDirtyCallBack;
  81939. private static _TextureAndMiscDirtyCallBack;
  81940. private static readonly _DirtyCallbackArray;
  81941. private static readonly _RunDirtyCallBacks;
  81942. /**
  81943. * Marks a define in the material to indicate that it needs to be re-computed
  81944. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  81945. */
  81946. markAsDirty(flag: number): void;
  81947. /**
  81948. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  81949. * @param func defines a function which checks material defines against the submeshes
  81950. */
  81951. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  81952. /**
  81953. * Indicates that image processing needs to be re-calculated for all submeshes
  81954. */
  81955. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  81956. /**
  81957. * Indicates that textures need to be re-calculated for all submeshes
  81958. */
  81959. protected _markAllSubMeshesAsTexturesDirty(): void;
  81960. /**
  81961. * Indicates that fresnel needs to be re-calculated for all submeshes
  81962. */
  81963. protected _markAllSubMeshesAsFresnelDirty(): void;
  81964. /**
  81965. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  81966. */
  81967. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  81968. /**
  81969. * Indicates that lights need to be re-calculated for all submeshes
  81970. */
  81971. protected _markAllSubMeshesAsLightsDirty(): void;
  81972. /**
  81973. * Indicates that attributes need to be re-calculated for all submeshes
  81974. */
  81975. protected _markAllSubMeshesAsAttributesDirty(): void;
  81976. /**
  81977. * Indicates that misc needs to be re-calculated for all submeshes
  81978. */
  81979. protected _markAllSubMeshesAsMiscDirty(): void;
  81980. /**
  81981. * Indicates that textures and misc need to be re-calculated for all submeshes
  81982. */
  81983. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  81984. /**
  81985. * Disposes the material
  81986. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81987. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  81988. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  81989. */
  81990. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  81991. /** @hidden */
  81992. private releaseVertexArrayObject;
  81993. /**
  81994. * Serializes this material
  81995. * @returns the serialized material object
  81996. */
  81997. serialize(): any;
  81998. /**
  81999. * Creates a material from parsed material data
  82000. * @param parsedMaterial defines parsed material data
  82001. * @param scene defines the hosting scene
  82002. * @param rootUrl defines the root URL to use to load textures
  82003. * @returns a new material
  82004. */
  82005. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82006. }
  82007. }
  82008. declare module BABYLON {
  82009. /**
  82010. * Base class for submeshes
  82011. */
  82012. export class BaseSubMesh {
  82013. /** @hidden */
  82014. _materialDefines: Nullable<MaterialDefines>;
  82015. /** @hidden */
  82016. _materialEffect: Nullable<Effect>;
  82017. /**
  82018. * Gets associated effect
  82019. */
  82020. readonly effect: Nullable<Effect>;
  82021. /**
  82022. * Sets associated effect (effect used to render this submesh)
  82023. * @param effect defines the effect to associate with
  82024. * @param defines defines the set of defines used to compile this effect
  82025. */
  82026. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82027. }
  82028. /**
  82029. * Defines a subdivision inside a mesh
  82030. */
  82031. export class SubMesh extends BaseSubMesh implements ICullable {
  82032. /** the material index to use */
  82033. materialIndex: number;
  82034. /** vertex index start */
  82035. verticesStart: number;
  82036. /** vertices count */
  82037. verticesCount: number;
  82038. /** index start */
  82039. indexStart: number;
  82040. /** indices count */
  82041. indexCount: number;
  82042. /** @hidden */
  82043. _linesIndexCount: number;
  82044. private _mesh;
  82045. private _renderingMesh;
  82046. private _boundingInfo;
  82047. private _linesIndexBuffer;
  82048. /** @hidden */
  82049. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82050. /** @hidden */
  82051. _trianglePlanes: Plane[];
  82052. /** @hidden */
  82053. _lastColliderTransformMatrix: Nullable<Matrix>;
  82054. /** @hidden */
  82055. _renderId: number;
  82056. /** @hidden */
  82057. _alphaIndex: number;
  82058. /** @hidden */
  82059. _distanceToCamera: number;
  82060. /** @hidden */
  82061. _id: number;
  82062. private _currentMaterial;
  82063. /**
  82064. * Add a new submesh to a mesh
  82065. * @param materialIndex defines the material index to use
  82066. * @param verticesStart defines vertex index start
  82067. * @param verticesCount defines vertices count
  82068. * @param indexStart defines index start
  82069. * @param indexCount defines indices count
  82070. * @param mesh defines the parent mesh
  82071. * @param renderingMesh defines an optional rendering mesh
  82072. * @param createBoundingBox defines if bounding box should be created for this submesh
  82073. * @returns the new submesh
  82074. */
  82075. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82076. /**
  82077. * Creates a new submesh
  82078. * @param materialIndex defines the material index to use
  82079. * @param verticesStart defines vertex index start
  82080. * @param verticesCount defines vertices count
  82081. * @param indexStart defines index start
  82082. * @param indexCount defines indices count
  82083. * @param mesh defines the parent mesh
  82084. * @param renderingMesh defines an optional rendering mesh
  82085. * @param createBoundingBox defines if bounding box should be created for this submesh
  82086. */
  82087. constructor(
  82088. /** the material index to use */
  82089. materialIndex: number,
  82090. /** vertex index start */
  82091. verticesStart: number,
  82092. /** vertices count */
  82093. verticesCount: number,
  82094. /** index start */
  82095. indexStart: number,
  82096. /** indices count */
  82097. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82098. /**
  82099. * Returns true if this submesh covers the entire parent mesh
  82100. * @ignorenaming
  82101. */
  82102. readonly IsGlobal: boolean;
  82103. /**
  82104. * Returns the submesh BoudingInfo object
  82105. * @returns current bounding info (or mesh's one if the submesh is global)
  82106. */
  82107. getBoundingInfo(): BoundingInfo;
  82108. /**
  82109. * Sets the submesh BoundingInfo
  82110. * @param boundingInfo defines the new bounding info to use
  82111. * @returns the SubMesh
  82112. */
  82113. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82114. /**
  82115. * Returns the mesh of the current submesh
  82116. * @return the parent mesh
  82117. */
  82118. getMesh(): AbstractMesh;
  82119. /**
  82120. * Returns the rendering mesh of the submesh
  82121. * @returns the rendering mesh (could be different from parent mesh)
  82122. */
  82123. getRenderingMesh(): Mesh;
  82124. /**
  82125. * Returns the submesh material
  82126. * @returns null or the current material
  82127. */
  82128. getMaterial(): Nullable<Material>;
  82129. /**
  82130. * Sets a new updated BoundingInfo object to the submesh
  82131. * @returns the SubMesh
  82132. */
  82133. refreshBoundingInfo(): SubMesh;
  82134. /** @hidden */
  82135. _checkCollision(collider: Collider): boolean;
  82136. /**
  82137. * Updates the submesh BoundingInfo
  82138. * @param world defines the world matrix to use to update the bounding info
  82139. * @returns the submesh
  82140. */
  82141. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82142. /**
  82143. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82144. * @param frustumPlanes defines the frustum planes
  82145. * @returns true if the submesh is intersecting with the frustum
  82146. */
  82147. isInFrustum(frustumPlanes: Plane[]): boolean;
  82148. /**
  82149. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82150. * @param frustumPlanes defines the frustum planes
  82151. * @returns true if the submesh is inside the frustum
  82152. */
  82153. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82154. /**
  82155. * Renders the submesh
  82156. * @param enableAlphaMode defines if alpha needs to be used
  82157. * @returns the submesh
  82158. */
  82159. render(enableAlphaMode: boolean): SubMesh;
  82160. /**
  82161. * @hidden
  82162. */
  82163. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  82164. /**
  82165. * Checks if the submesh intersects with a ray
  82166. * @param ray defines the ray to test
  82167. * @returns true is the passed ray intersects the submesh bounding box
  82168. */
  82169. canIntersects(ray: Ray): boolean;
  82170. /**
  82171. * Intersects current submesh with a ray
  82172. * @param ray defines the ray to test
  82173. * @param positions defines mesh's positions array
  82174. * @param indices defines mesh's indices array
  82175. * @param fastCheck defines if only bounding info should be used
  82176. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82177. * @returns intersection info or null if no intersection
  82178. */
  82179. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82180. /** @hidden */
  82181. private _intersectLines;
  82182. /** @hidden */
  82183. private _intersectTriangles;
  82184. /** @hidden */
  82185. _rebuild(): void;
  82186. /**
  82187. * Creates a new submesh from the passed mesh
  82188. * @param newMesh defines the new hosting mesh
  82189. * @param newRenderingMesh defines an optional rendering mesh
  82190. * @returns the new submesh
  82191. */
  82192. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82193. /**
  82194. * Release associated resources
  82195. */
  82196. dispose(): void;
  82197. /**
  82198. * Gets the class name
  82199. * @returns the string "SubMesh".
  82200. */
  82201. getClassName(): string;
  82202. /**
  82203. * Creates a new submesh from indices data
  82204. * @param materialIndex the index of the main mesh material
  82205. * @param startIndex the index where to start the copy in the mesh indices array
  82206. * @param indexCount the number of indices to copy then from the startIndex
  82207. * @param mesh the main mesh to create the submesh from
  82208. * @param renderingMesh the optional rendering mesh
  82209. * @returns a new submesh
  82210. */
  82211. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82212. }
  82213. }
  82214. declare module BABYLON {
  82215. /**
  82216. * Class used to store geometry data (vertex buffers + index buffer)
  82217. */
  82218. export class Geometry implements IGetSetVerticesData {
  82219. /**
  82220. * Gets or sets the ID of the geometry
  82221. */
  82222. id: string;
  82223. /**
  82224. * Gets or sets the unique ID of the geometry
  82225. */
  82226. uniqueId: number;
  82227. /**
  82228. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82229. */
  82230. delayLoadState: number;
  82231. /**
  82232. * Gets the file containing the data to load when running in delay load state
  82233. */
  82234. delayLoadingFile: Nullable<string>;
  82235. /**
  82236. * Callback called when the geometry is updated
  82237. */
  82238. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82239. private _scene;
  82240. private _engine;
  82241. private _meshes;
  82242. private _totalVertices;
  82243. /** @hidden */
  82244. _indices: IndicesArray;
  82245. /** @hidden */
  82246. _vertexBuffers: {
  82247. [key: string]: VertexBuffer;
  82248. };
  82249. private _isDisposed;
  82250. private _extend;
  82251. private _boundingBias;
  82252. /** @hidden */
  82253. _delayInfo: Array<string>;
  82254. private _indexBuffer;
  82255. private _indexBufferIsUpdatable;
  82256. /** @hidden */
  82257. _boundingInfo: Nullable<BoundingInfo>;
  82258. /** @hidden */
  82259. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82260. /** @hidden */
  82261. _softwareSkinningFrameId: number;
  82262. private _vertexArrayObjects;
  82263. private _updatable;
  82264. /** @hidden */
  82265. _positions: Nullable<Vector3[]>;
  82266. /**
  82267. * 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
  82268. */
  82269. /**
  82270. * 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
  82271. */
  82272. boundingBias: Vector2;
  82273. /**
  82274. * Static function used to attach a new empty geometry to a mesh
  82275. * @param mesh defines the mesh to attach the geometry to
  82276. * @returns the new Geometry
  82277. */
  82278. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82279. /**
  82280. * Creates a new geometry
  82281. * @param id defines the unique ID
  82282. * @param scene defines the hosting scene
  82283. * @param vertexData defines the VertexData used to get geometry data
  82284. * @param updatable defines if geometry must be updatable (false by default)
  82285. * @param mesh defines the mesh that will be associated with the geometry
  82286. */
  82287. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82288. /**
  82289. * Gets the current extend of the geometry
  82290. */
  82291. readonly extend: {
  82292. minimum: Vector3;
  82293. maximum: Vector3;
  82294. };
  82295. /**
  82296. * Gets the hosting scene
  82297. * @returns the hosting Scene
  82298. */
  82299. getScene(): Scene;
  82300. /**
  82301. * Gets the hosting engine
  82302. * @returns the hosting Engine
  82303. */
  82304. getEngine(): Engine;
  82305. /**
  82306. * Defines if the geometry is ready to use
  82307. * @returns true if the geometry is ready to be used
  82308. */
  82309. isReady(): boolean;
  82310. /**
  82311. * Gets a value indicating that the geometry should not be serialized
  82312. */
  82313. readonly doNotSerialize: boolean;
  82314. /** @hidden */
  82315. _rebuild(): void;
  82316. /**
  82317. * Affects all geometry data in one call
  82318. * @param vertexData defines the geometry data
  82319. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82320. */
  82321. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82322. /**
  82323. * Set specific vertex data
  82324. * @param kind defines the data kind (Position, normal, etc...)
  82325. * @param data defines the vertex data to use
  82326. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82327. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82328. */
  82329. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82330. /**
  82331. * Removes a specific vertex data
  82332. * @param kind defines the data kind (Position, normal, etc...)
  82333. */
  82334. removeVerticesData(kind: string): void;
  82335. /**
  82336. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82337. * @param buffer defines the vertex buffer to use
  82338. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82339. */
  82340. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82341. /**
  82342. * Update a specific vertex buffer
  82343. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  82344. * It will do nothing if the buffer is not updatable
  82345. * @param kind defines the data kind (Position, normal, etc...)
  82346. * @param data defines the data to use
  82347. * @param offset defines the offset in the target buffer where to store the data
  82348. * @param useBytes set to true if the offset is in bytes
  82349. */
  82350. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82351. /**
  82352. * Update a specific vertex buffer
  82353. * This function will create a new buffer if the current one is not updatable
  82354. * @param kind defines the data kind (Position, normal, etc...)
  82355. * @param data defines the data to use
  82356. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82357. */
  82358. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82359. private _updateBoundingInfo;
  82360. /** @hidden */
  82361. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  82362. /**
  82363. * Gets total number of vertices
  82364. * @returns the total number of vertices
  82365. */
  82366. getTotalVertices(): number;
  82367. /**
  82368. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82369. * @param kind defines the data kind (Position, normal, etc...)
  82370. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82371. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82372. * @returns a float array containing vertex data
  82373. */
  82374. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82375. /**
  82376. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82377. * @param kind defines the data kind (Position, normal, etc...)
  82378. * @returns true if the vertex buffer with the specified kind is updatable
  82379. */
  82380. isVertexBufferUpdatable(kind: string): boolean;
  82381. /**
  82382. * Gets a specific vertex buffer
  82383. * @param kind defines the data kind (Position, normal, etc...)
  82384. * @returns a VertexBuffer
  82385. */
  82386. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82387. /**
  82388. * Returns all vertex buffers
  82389. * @return an object holding all vertex buffers indexed by kind
  82390. */
  82391. getVertexBuffers(): Nullable<{
  82392. [key: string]: VertexBuffer;
  82393. }>;
  82394. /**
  82395. * Gets a boolean indicating if specific vertex buffer is present
  82396. * @param kind defines the data kind (Position, normal, etc...)
  82397. * @returns true if data is present
  82398. */
  82399. isVerticesDataPresent(kind: string): boolean;
  82400. /**
  82401. * Gets a list of all attached data kinds (Position, normal, etc...)
  82402. * @returns a list of string containing all kinds
  82403. */
  82404. getVerticesDataKinds(): string[];
  82405. /**
  82406. * Update index buffer
  82407. * @param indices defines the indices to store in the index buffer
  82408. * @param offset defines the offset in the target buffer where to store the data
  82409. * @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)
  82410. */
  82411. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82412. /**
  82413. * Creates a new index buffer
  82414. * @param indices defines the indices to store in the index buffer
  82415. * @param totalVertices defines the total number of vertices (could be null)
  82416. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82417. */
  82418. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82419. /**
  82420. * Return the total number of indices
  82421. * @returns the total number of indices
  82422. */
  82423. getTotalIndices(): number;
  82424. /**
  82425. * Gets the index buffer array
  82426. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82427. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82428. * @returns the index buffer array
  82429. */
  82430. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82431. /**
  82432. * Gets the index buffer
  82433. * @return the index buffer
  82434. */
  82435. getIndexBuffer(): Nullable<WebGLBuffer>;
  82436. /** @hidden */
  82437. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82438. /**
  82439. * Release the associated resources for a specific mesh
  82440. * @param mesh defines the source mesh
  82441. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82442. */
  82443. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82444. /**
  82445. * Apply current geometry to a given mesh
  82446. * @param mesh defines the mesh to apply geometry to
  82447. */
  82448. applyToMesh(mesh: Mesh): void;
  82449. private _updateExtend;
  82450. private _applyToMesh;
  82451. private notifyUpdate;
  82452. /**
  82453. * Load the geometry if it was flagged as delay loaded
  82454. * @param scene defines the hosting scene
  82455. * @param onLoaded defines a callback called when the geometry is loaded
  82456. */
  82457. load(scene: Scene, onLoaded?: () => void): void;
  82458. private _queueLoad;
  82459. /**
  82460. * Invert the geometry to move from a right handed system to a left handed one.
  82461. */
  82462. toLeftHanded(): void;
  82463. /** @hidden */
  82464. _resetPointsArrayCache(): void;
  82465. /** @hidden */
  82466. _generatePointsArray(): boolean;
  82467. /**
  82468. * Gets a value indicating if the geometry is disposed
  82469. * @returns true if the geometry was disposed
  82470. */
  82471. isDisposed(): boolean;
  82472. private _disposeVertexArrayObjects;
  82473. /**
  82474. * Free all associated resources
  82475. */
  82476. dispose(): void;
  82477. /**
  82478. * Clone the current geometry into a new geometry
  82479. * @param id defines the unique ID of the new geometry
  82480. * @returns a new geometry object
  82481. */
  82482. copy(id: string): Geometry;
  82483. /**
  82484. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82485. * @return a JSON representation of the current geometry data (without the vertices data)
  82486. */
  82487. serialize(): any;
  82488. private toNumberArray;
  82489. /**
  82490. * Serialize all vertices data into a JSON oject
  82491. * @returns a JSON representation of the current geometry data
  82492. */
  82493. serializeVerticeData(): any;
  82494. /**
  82495. * Extracts a clone of a mesh geometry
  82496. * @param mesh defines the source mesh
  82497. * @param id defines the unique ID of the new geometry object
  82498. * @returns the new geometry object
  82499. */
  82500. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82501. /**
  82502. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82503. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82504. * Be aware Math.random() could cause collisions, but:
  82505. * "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"
  82506. * @returns a string containing a new GUID
  82507. */
  82508. static RandomId(): string;
  82509. /** @hidden */
  82510. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82511. private static _CleanMatricesWeights;
  82512. /**
  82513. * Create a new geometry from persisted data (Using .babylon file format)
  82514. * @param parsedVertexData defines the persisted data
  82515. * @param scene defines the hosting scene
  82516. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82517. * @returns the new geometry object
  82518. */
  82519. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82520. }
  82521. }
  82522. declare module BABYLON {
  82523. /**
  82524. * Define an interface for all classes that will get and set the data on vertices
  82525. */
  82526. export interface IGetSetVerticesData {
  82527. /**
  82528. * Gets a boolean indicating if specific vertex data is present
  82529. * @param kind defines the vertex data kind to use
  82530. * @returns true is data kind is present
  82531. */
  82532. isVerticesDataPresent(kind: string): boolean;
  82533. /**
  82534. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82535. * @param kind defines the data kind (Position, normal, etc...)
  82536. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82537. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82538. * @returns a float array containing vertex data
  82539. */
  82540. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82541. /**
  82542. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82543. * @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.
  82544. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82545. * @returns the indices array or an empty array if the mesh has no geometry
  82546. */
  82547. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82548. /**
  82549. * Set specific vertex data
  82550. * @param kind defines the data kind (Position, normal, etc...)
  82551. * @param data defines the vertex data to use
  82552. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82553. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82554. */
  82555. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82556. /**
  82557. * Update a specific associated vertex buffer
  82558. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82559. * - VertexBuffer.PositionKind
  82560. * - VertexBuffer.UVKind
  82561. * - VertexBuffer.UV2Kind
  82562. * - VertexBuffer.UV3Kind
  82563. * - VertexBuffer.UV4Kind
  82564. * - VertexBuffer.UV5Kind
  82565. * - VertexBuffer.UV6Kind
  82566. * - VertexBuffer.ColorKind
  82567. * - VertexBuffer.MatricesIndicesKind
  82568. * - VertexBuffer.MatricesIndicesExtraKind
  82569. * - VertexBuffer.MatricesWeightsKind
  82570. * - VertexBuffer.MatricesWeightsExtraKind
  82571. * @param data defines the data source
  82572. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82573. * @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)
  82574. */
  82575. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  82576. /**
  82577. * Creates a new index buffer
  82578. * @param indices defines the indices to store in the index buffer
  82579. * @param totalVertices defines the total number of vertices (could be null)
  82580. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82581. */
  82582. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  82583. }
  82584. /**
  82585. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  82586. */
  82587. export class VertexData {
  82588. /**
  82589. * Mesh side orientation : usually the external or front surface
  82590. */
  82591. static readonly FRONTSIDE: number;
  82592. /**
  82593. * Mesh side orientation : usually the internal or back surface
  82594. */
  82595. static readonly BACKSIDE: number;
  82596. /**
  82597. * Mesh side orientation : both internal and external or front and back surfaces
  82598. */
  82599. static readonly DOUBLESIDE: number;
  82600. /**
  82601. * Mesh side orientation : by default, `FRONTSIDE`
  82602. */
  82603. static readonly DEFAULTSIDE: number;
  82604. /**
  82605. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  82606. */
  82607. positions: Nullable<FloatArray>;
  82608. /**
  82609. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  82610. */
  82611. normals: Nullable<FloatArray>;
  82612. /**
  82613. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  82614. */
  82615. tangents: Nullable<FloatArray>;
  82616. /**
  82617. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82618. */
  82619. uvs: Nullable<FloatArray>;
  82620. /**
  82621. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82622. */
  82623. uvs2: Nullable<FloatArray>;
  82624. /**
  82625. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82626. */
  82627. uvs3: Nullable<FloatArray>;
  82628. /**
  82629. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82630. */
  82631. uvs4: Nullable<FloatArray>;
  82632. /**
  82633. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82634. */
  82635. uvs5: Nullable<FloatArray>;
  82636. /**
  82637. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82638. */
  82639. uvs6: Nullable<FloatArray>;
  82640. /**
  82641. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  82642. */
  82643. colors: Nullable<FloatArray>;
  82644. /**
  82645. * 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).
  82646. */
  82647. matricesIndices: Nullable<FloatArray>;
  82648. /**
  82649. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  82650. */
  82651. matricesWeights: Nullable<FloatArray>;
  82652. /**
  82653. * An array extending the number of possible indices
  82654. */
  82655. matricesIndicesExtra: Nullable<FloatArray>;
  82656. /**
  82657. * An array extending the number of possible weights when the number of indices is extended
  82658. */
  82659. matricesWeightsExtra: Nullable<FloatArray>;
  82660. /**
  82661. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  82662. */
  82663. indices: Nullable<IndicesArray>;
  82664. /**
  82665. * Uses the passed data array to set the set the values for the specified kind of data
  82666. * @param data a linear array of floating numbers
  82667. * @param kind the type of data that is being set, eg positions, colors etc
  82668. */
  82669. set(data: FloatArray, kind: string): void;
  82670. /**
  82671. * Associates the vertexData to the passed Mesh.
  82672. * Sets it as updatable or not (default `false`)
  82673. * @param mesh the mesh the vertexData is applied to
  82674. * @param updatable when used and having the value true allows new data to update the vertexData
  82675. * @returns the VertexData
  82676. */
  82677. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  82678. /**
  82679. * Associates the vertexData to the passed Geometry.
  82680. * Sets it as updatable or not (default `false`)
  82681. * @param geometry the geometry the vertexData is applied to
  82682. * @param updatable when used and having the value true allows new data to update the vertexData
  82683. * @returns VertexData
  82684. */
  82685. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  82686. /**
  82687. * Updates the associated mesh
  82688. * @param mesh the mesh to be updated
  82689. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82690. * @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
  82691. * @returns VertexData
  82692. */
  82693. updateMesh(mesh: Mesh): VertexData;
  82694. /**
  82695. * Updates the associated geometry
  82696. * @param geometry the geometry to be updated
  82697. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82698. * @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
  82699. * @returns VertexData.
  82700. */
  82701. updateGeometry(geometry: Geometry): VertexData;
  82702. private _applyTo;
  82703. private _update;
  82704. /**
  82705. * Transforms each position and each normal of the vertexData according to the passed Matrix
  82706. * @param matrix the transforming matrix
  82707. * @returns the VertexData
  82708. */
  82709. transform(matrix: Matrix): VertexData;
  82710. /**
  82711. * Merges the passed VertexData into the current one
  82712. * @param other the VertexData to be merged into the current one
  82713. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  82714. * @returns the modified VertexData
  82715. */
  82716. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  82717. private _mergeElement;
  82718. private _validate;
  82719. /**
  82720. * Serializes the VertexData
  82721. * @returns a serialized object
  82722. */
  82723. serialize(): any;
  82724. /**
  82725. * Extracts the vertexData from a mesh
  82726. * @param mesh the mesh from which to extract the VertexData
  82727. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  82728. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82729. * @returns the object VertexData associated to the passed mesh
  82730. */
  82731. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82732. /**
  82733. * Extracts the vertexData from the geometry
  82734. * @param geometry the geometry from which to extract the VertexData
  82735. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  82736. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82737. * @returns the object VertexData associated to the passed mesh
  82738. */
  82739. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82740. private static _ExtractFrom;
  82741. /**
  82742. * Creates the VertexData for a Ribbon
  82743. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  82744. * * pathArray array of paths, each of which an array of successive Vector3
  82745. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  82746. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  82747. * * 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
  82748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82749. * * 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)
  82750. * * 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)
  82751. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  82752. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  82753. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  82754. * @returns the VertexData of the ribbon
  82755. */
  82756. static CreateRibbon(options: {
  82757. pathArray: Vector3[][];
  82758. closeArray?: boolean;
  82759. closePath?: boolean;
  82760. offset?: number;
  82761. sideOrientation?: number;
  82762. frontUVs?: Vector4;
  82763. backUVs?: Vector4;
  82764. invertUV?: boolean;
  82765. uvs?: Vector2[];
  82766. colors?: Color4[];
  82767. }): VertexData;
  82768. /**
  82769. * Creates the VertexData for a box
  82770. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82771. * * size sets the width, height and depth of the box to the value of size, optional default 1
  82772. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  82773. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  82774. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  82775. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  82776. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  82777. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82778. * * 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)
  82779. * * 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)
  82780. * @returns the VertexData of the box
  82781. */
  82782. static CreateBox(options: {
  82783. size?: number;
  82784. width?: number;
  82785. height?: number;
  82786. depth?: number;
  82787. faceUV?: Vector4[];
  82788. faceColors?: Color4[];
  82789. sideOrientation?: number;
  82790. frontUVs?: Vector4;
  82791. backUVs?: Vector4;
  82792. }): VertexData;
  82793. /**
  82794. * Creates the VertexData for an ellipsoid, defaults to a sphere
  82795. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82796. * * segments sets the number of horizontal strips optional, default 32
  82797. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  82798. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  82799. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  82800. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  82801. * * 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
  82802. * * 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
  82803. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82804. * * 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)
  82805. * * 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)
  82806. * @returns the VertexData of the ellipsoid
  82807. */
  82808. static CreateSphere(options: {
  82809. segments?: number;
  82810. diameter?: number;
  82811. diameterX?: number;
  82812. diameterY?: number;
  82813. diameterZ?: number;
  82814. arc?: number;
  82815. slice?: number;
  82816. sideOrientation?: number;
  82817. frontUVs?: Vector4;
  82818. backUVs?: Vector4;
  82819. }): VertexData;
  82820. /**
  82821. * Creates the VertexData for a cylinder, cone or prism
  82822. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82823. * * height sets the height (y direction) of the cylinder, optional, default 2
  82824. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  82825. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  82826. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  82827. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82828. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  82829. * * 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
  82830. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82831. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82832. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82833. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82834. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82835. * * 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)
  82836. * * 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)
  82837. * @returns the VertexData of the cylinder, cone or prism
  82838. */
  82839. static CreateCylinder(options: {
  82840. height?: number;
  82841. diameterTop?: number;
  82842. diameterBottom?: number;
  82843. diameter?: number;
  82844. tessellation?: number;
  82845. subdivisions?: number;
  82846. arc?: number;
  82847. faceColors?: Color4[];
  82848. faceUV?: Vector4[];
  82849. hasRings?: boolean;
  82850. enclose?: boolean;
  82851. sideOrientation?: number;
  82852. frontUVs?: Vector4;
  82853. backUVs?: Vector4;
  82854. }): VertexData;
  82855. /**
  82856. * Creates the VertexData for a torus
  82857. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82858. * * diameter the diameter of the torus, optional default 1
  82859. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82860. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82861. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82862. * * 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)
  82863. * * 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)
  82864. * @returns the VertexData of the torus
  82865. */
  82866. static CreateTorus(options: {
  82867. diameter?: number;
  82868. thickness?: number;
  82869. tessellation?: number;
  82870. sideOrientation?: number;
  82871. frontUVs?: Vector4;
  82872. backUVs?: Vector4;
  82873. }): VertexData;
  82874. /**
  82875. * Creates the VertexData of the LineSystem
  82876. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  82877. * - lines an array of lines, each line being an array of successive Vector3
  82878. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  82879. * @returns the VertexData of the LineSystem
  82880. */
  82881. static CreateLineSystem(options: {
  82882. lines: Vector3[][];
  82883. colors?: Nullable<Color4[][]>;
  82884. }): VertexData;
  82885. /**
  82886. * Create the VertexData for a DashedLines
  82887. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  82888. * - points an array successive Vector3
  82889. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  82890. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  82891. * - dashNb the intended total number of dashes, optional, default 200
  82892. * @returns the VertexData for the DashedLines
  82893. */
  82894. static CreateDashedLines(options: {
  82895. points: Vector3[];
  82896. dashSize?: number;
  82897. gapSize?: number;
  82898. dashNb?: number;
  82899. }): VertexData;
  82900. /**
  82901. * Creates the VertexData for a Ground
  82902. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82903. * - width the width (x direction) of the ground, optional, default 1
  82904. * - height the height (z direction) of the ground, optional, default 1
  82905. * - subdivisions the number of subdivisions per side, optional, default 1
  82906. * @returns the VertexData of the Ground
  82907. */
  82908. static CreateGround(options: {
  82909. width?: number;
  82910. height?: number;
  82911. subdivisions?: number;
  82912. subdivisionsX?: number;
  82913. subdivisionsY?: number;
  82914. }): VertexData;
  82915. /**
  82916. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  82917. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82918. * * xmin the ground minimum X coordinate, optional, default -1
  82919. * * zmin the ground minimum Z coordinate, optional, default -1
  82920. * * xmax the ground maximum X coordinate, optional, default 1
  82921. * * zmax the ground maximum Z coordinate, optional, default 1
  82922. * * 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}
  82923. * * 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}
  82924. * @returns the VertexData of the TiledGround
  82925. */
  82926. static CreateTiledGround(options: {
  82927. xmin: number;
  82928. zmin: number;
  82929. xmax: number;
  82930. zmax: number;
  82931. subdivisions?: {
  82932. w: number;
  82933. h: number;
  82934. };
  82935. precision?: {
  82936. w: number;
  82937. h: number;
  82938. };
  82939. }): VertexData;
  82940. /**
  82941. * Creates the VertexData of the Ground designed from a heightmap
  82942. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  82943. * * width the width (x direction) of the ground
  82944. * * height the height (z direction) of the ground
  82945. * * subdivisions the number of subdivisions per side
  82946. * * minHeight the minimum altitude on the ground, optional, default 0
  82947. * * maxHeight the maximum altitude on the ground, optional default 1
  82948. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  82949. * * buffer the array holding the image color data
  82950. * * bufferWidth the width of image
  82951. * * bufferHeight the height of image
  82952. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  82953. * @returns the VertexData of the Ground designed from a heightmap
  82954. */
  82955. static CreateGroundFromHeightMap(options: {
  82956. width: number;
  82957. height: number;
  82958. subdivisions: number;
  82959. minHeight: number;
  82960. maxHeight: number;
  82961. colorFilter: Color3;
  82962. buffer: Uint8Array;
  82963. bufferWidth: number;
  82964. bufferHeight: number;
  82965. alphaFilter: number;
  82966. }): VertexData;
  82967. /**
  82968. * Creates the VertexData for a Plane
  82969. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  82970. * * size sets the width and height of the plane to the value of size, optional default 1
  82971. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  82972. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  82973. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82974. * * 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)
  82975. * * 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)
  82976. * @returns the VertexData of the box
  82977. */
  82978. static CreatePlane(options: {
  82979. size?: number;
  82980. width?: number;
  82981. height?: number;
  82982. sideOrientation?: number;
  82983. frontUVs?: Vector4;
  82984. backUVs?: Vector4;
  82985. }): VertexData;
  82986. /**
  82987. * Creates the VertexData of the Disc or regular Polygon
  82988. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  82989. * * radius the radius of the disc, optional default 0.5
  82990. * * tessellation the number of polygon sides, optional, default 64
  82991. * * 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
  82992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82993. * * 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)
  82994. * * 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)
  82995. * @returns the VertexData of the box
  82996. */
  82997. static CreateDisc(options: {
  82998. radius?: number;
  82999. tessellation?: number;
  83000. arc?: number;
  83001. sideOrientation?: number;
  83002. frontUVs?: Vector4;
  83003. backUVs?: Vector4;
  83004. }): VertexData;
  83005. /**
  83006. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83007. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83008. * @param polygon a mesh built from polygonTriangulation.build()
  83009. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83010. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83011. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83012. * @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)
  83013. * @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)
  83014. * @returns the VertexData of the Polygon
  83015. */
  83016. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83017. /**
  83018. * Creates the VertexData of the IcoSphere
  83019. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83020. * * radius the radius of the IcoSphere, optional default 1
  83021. * * radiusX allows stretching in the x direction, optional, default radius
  83022. * * radiusY allows stretching in the y direction, optional, default radius
  83023. * * radiusZ allows stretching in the z direction, optional, default radius
  83024. * * flat when true creates a flat shaded mesh, optional, default true
  83025. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83027. * * 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)
  83028. * * 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)
  83029. * @returns the VertexData of the IcoSphere
  83030. */
  83031. static CreateIcoSphere(options: {
  83032. radius?: number;
  83033. radiusX?: number;
  83034. radiusY?: number;
  83035. radiusZ?: number;
  83036. flat?: boolean;
  83037. subdivisions?: number;
  83038. sideOrientation?: number;
  83039. frontUVs?: Vector4;
  83040. backUVs?: Vector4;
  83041. }): VertexData;
  83042. /**
  83043. * Creates the VertexData for a Polyhedron
  83044. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83045. * * type provided types are:
  83046. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83047. * * 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)
  83048. * * size the size of the IcoSphere, optional default 1
  83049. * * sizeX allows stretching in the x direction, optional, default size
  83050. * * sizeY allows stretching in the y direction, optional, default size
  83051. * * sizeZ allows stretching in the z direction, optional, default size
  83052. * * 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
  83053. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83054. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83055. * * flat when true creates a flat shaded mesh, optional, default true
  83056. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83057. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83058. * * 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)
  83059. * * 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)
  83060. * @returns the VertexData of the Polyhedron
  83061. */
  83062. static CreatePolyhedron(options: {
  83063. type?: number;
  83064. size?: number;
  83065. sizeX?: number;
  83066. sizeY?: number;
  83067. sizeZ?: number;
  83068. custom?: any;
  83069. faceUV?: Vector4[];
  83070. faceColors?: Color4[];
  83071. flat?: boolean;
  83072. sideOrientation?: number;
  83073. frontUVs?: Vector4;
  83074. backUVs?: Vector4;
  83075. }): VertexData;
  83076. /**
  83077. * Creates the VertexData for a TorusKnot
  83078. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83079. * * radius the radius of the torus knot, optional, default 2
  83080. * * tube the thickness of the tube, optional, default 0.5
  83081. * * radialSegments the number of sides on each tube segments, optional, default 32
  83082. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83083. * * p the number of windings around the z axis, optional, default 2
  83084. * * q the number of windings around the x axis, optional, default 3
  83085. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83086. * * 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)
  83087. * * 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)
  83088. * @returns the VertexData of the Torus Knot
  83089. */
  83090. static CreateTorusKnot(options: {
  83091. radius?: number;
  83092. tube?: number;
  83093. radialSegments?: number;
  83094. tubularSegments?: number;
  83095. p?: number;
  83096. q?: number;
  83097. sideOrientation?: number;
  83098. frontUVs?: Vector4;
  83099. backUVs?: Vector4;
  83100. }): VertexData;
  83101. /**
  83102. * Compute normals for given positions and indices
  83103. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83104. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83105. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83106. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83107. * * facetNormals : optional array of facet normals (vector3)
  83108. * * facetPositions : optional array of facet positions (vector3)
  83109. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83110. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83111. * * bInfo : optional bounding info, required for facetPartitioning computation
  83112. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83113. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83114. * * useRightHandedSystem: optional boolean to for right handed system computation
  83115. * * depthSort : optional boolean to enable the facet depth sort computation
  83116. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83117. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83118. */
  83119. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83120. facetNormals?: any;
  83121. facetPositions?: any;
  83122. facetPartitioning?: any;
  83123. ratio?: number;
  83124. bInfo?: any;
  83125. bbSize?: Vector3;
  83126. subDiv?: any;
  83127. useRightHandedSystem?: boolean;
  83128. depthSort?: boolean;
  83129. distanceTo?: Vector3;
  83130. depthSortedFacets?: any;
  83131. }): void;
  83132. /** @hidden */
  83133. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83134. /**
  83135. * Applies VertexData created from the imported parameters to the geometry
  83136. * @param parsedVertexData the parsed data from an imported file
  83137. * @param geometry the geometry to apply the VertexData to
  83138. */
  83139. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83140. }
  83141. }
  83142. declare module BABYLON {
  83143. /**
  83144. * Class containing static functions to help procedurally build meshes
  83145. */
  83146. export class DiscBuilder {
  83147. /**
  83148. * Creates a plane polygonal mesh. By default, this is a disc
  83149. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83150. * * 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
  83151. * * 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
  83152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83155. * @param name defines the name of the mesh
  83156. * @param options defines the options used to create the mesh
  83157. * @param scene defines the hosting scene
  83158. * @returns the plane polygonal mesh
  83159. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83160. */
  83161. static CreateDisc(name: string, options: {
  83162. radius?: number;
  83163. tessellation?: number;
  83164. arc?: number;
  83165. updatable?: boolean;
  83166. sideOrientation?: number;
  83167. frontUVs?: Vector4;
  83168. backUVs?: Vector4;
  83169. }, scene?: Nullable<Scene>): Mesh;
  83170. }
  83171. }
  83172. declare module BABYLON {
  83173. /**
  83174. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83175. *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.
  83176. * The SPS is also a particle system. It provides some methods to manage the particles.
  83177. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83178. *
  83179. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83180. */
  83181. export class SolidParticleSystem implements IDisposable {
  83182. /**
  83183. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83184. * Example : var p = SPS.particles[i];
  83185. */
  83186. particles: SolidParticle[];
  83187. /**
  83188. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83189. */
  83190. nbParticles: number;
  83191. /**
  83192. * If the particles must ever face the camera (default false). Useful for planar particles.
  83193. */
  83194. billboard: boolean;
  83195. /**
  83196. * Recompute normals when adding a shape
  83197. */
  83198. recomputeNormals: boolean;
  83199. /**
  83200. * This a counter ofr your own usage. It's not set by any SPS functions.
  83201. */
  83202. counter: number;
  83203. /**
  83204. * The SPS name. This name is also given to the underlying mesh.
  83205. */
  83206. name: string;
  83207. /**
  83208. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83209. */
  83210. mesh: Mesh;
  83211. /**
  83212. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83213. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83214. */
  83215. vars: any;
  83216. /**
  83217. * This array is populated when the SPS is set as 'pickable'.
  83218. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83219. * Each element of this array is an object `{idx: int, faceId: int}`.
  83220. * `idx` is the picked particle index in the `SPS.particles` array
  83221. * `faceId` is the picked face index counted within this particle.
  83222. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83223. */
  83224. pickedParticles: {
  83225. idx: number;
  83226. faceId: number;
  83227. }[];
  83228. /**
  83229. * This array is populated when `enableDepthSort` is set to true.
  83230. * Each element of this array is an instance of the class DepthSortedParticle.
  83231. */
  83232. depthSortedParticles: DepthSortedParticle[];
  83233. /**
  83234. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83235. * @hidden
  83236. */
  83237. _bSphereOnly: boolean;
  83238. /**
  83239. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83240. * @hidden
  83241. */
  83242. _bSphereRadiusFactor: number;
  83243. private _scene;
  83244. private _positions;
  83245. private _indices;
  83246. private _normals;
  83247. private _colors;
  83248. private _uvs;
  83249. private _indices32;
  83250. private _positions32;
  83251. private _normals32;
  83252. private _fixedNormal32;
  83253. private _colors32;
  83254. private _uvs32;
  83255. private _index;
  83256. private _updatable;
  83257. private _pickable;
  83258. private _isVisibilityBoxLocked;
  83259. private _alwaysVisible;
  83260. private _depthSort;
  83261. private _shapeCounter;
  83262. private _copy;
  83263. private _color;
  83264. private _computeParticleColor;
  83265. private _computeParticleTexture;
  83266. private _computeParticleRotation;
  83267. private _computeParticleVertex;
  83268. private _computeBoundingBox;
  83269. private _depthSortParticles;
  83270. private _camera;
  83271. private _mustUnrotateFixedNormals;
  83272. private _particlesIntersect;
  83273. private _needs32Bits;
  83274. /**
  83275. * Creates a SPS (Solid Particle System) object.
  83276. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83277. * @param scene (Scene) is the scene in which the SPS is added.
  83278. * @param options defines the options of the sps e.g.
  83279. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83280. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83281. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83282. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83283. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83284. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83285. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83286. */
  83287. constructor(name: string, scene: Scene, options?: {
  83288. updatable?: boolean;
  83289. isPickable?: boolean;
  83290. enableDepthSort?: boolean;
  83291. particleIntersection?: boolean;
  83292. boundingSphereOnly?: boolean;
  83293. bSphereRadiusFactor?: number;
  83294. });
  83295. /**
  83296. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83297. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83298. * @returns the created mesh
  83299. */
  83300. buildMesh(): Mesh;
  83301. /**
  83302. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83303. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83304. * Thus the particles generated from `digest()` have their property `position` set yet.
  83305. * @param mesh ( Mesh ) is the mesh to be digested
  83306. * @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
  83307. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83308. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83309. * @returns the current SPS
  83310. */
  83311. digest(mesh: Mesh, options?: {
  83312. facetNb?: number;
  83313. number?: number;
  83314. delta?: number;
  83315. }): SolidParticleSystem;
  83316. private _unrotateFixedNormals;
  83317. private _resetCopy;
  83318. private _meshBuilder;
  83319. private _posToShape;
  83320. private _uvsToShapeUV;
  83321. private _addParticle;
  83322. /**
  83323. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83324. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83325. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83326. * @param nb (positive integer) the number of particles to be created from this model
  83327. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83328. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83329. * @returns the number of shapes in the system
  83330. */
  83331. addShape(mesh: Mesh, nb: number, options?: {
  83332. positionFunction?: any;
  83333. vertexFunction?: any;
  83334. }): number;
  83335. private _rebuildParticle;
  83336. /**
  83337. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83338. * @returns the SPS.
  83339. */
  83340. rebuildMesh(): SolidParticleSystem;
  83341. /**
  83342. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83343. * This method calls `updateParticle()` for each particle of the SPS.
  83344. * For an animated SPS, it is usually called within the render loop.
  83345. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83346. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83347. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83348. * @returns the SPS.
  83349. */
  83350. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83351. /**
  83352. * Disposes the SPS.
  83353. */
  83354. dispose(): void;
  83355. /**
  83356. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83357. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83358. * @returns the SPS.
  83359. */
  83360. refreshVisibleSize(): SolidParticleSystem;
  83361. /**
  83362. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83363. * @param size the size (float) of the visibility box
  83364. * note : this doesn't lock the SPS mesh bounding box.
  83365. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83366. */
  83367. setVisibilityBox(size: number): void;
  83368. /**
  83369. * Gets whether the SPS as always visible or not
  83370. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83371. */
  83372. /**
  83373. * Sets the SPS as always visible or not
  83374. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83375. */
  83376. isAlwaysVisible: boolean;
  83377. /**
  83378. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83379. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83380. */
  83381. /**
  83382. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83383. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83384. */
  83385. isVisibilityBoxLocked: boolean;
  83386. /**
  83387. * Tells to `setParticles()` to compute the particle rotations or not.
  83388. * Default value : true. The SPS is faster when it's set to false.
  83389. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83390. */
  83391. /**
  83392. * Gets if `setParticles()` computes the particle rotations or not.
  83393. * Default value : true. The SPS is faster when it's set to false.
  83394. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83395. */
  83396. computeParticleRotation: boolean;
  83397. /**
  83398. * Tells to `setParticles()` to compute the particle colors or not.
  83399. * Default value : true. The SPS is faster when it's set to false.
  83400. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83401. */
  83402. /**
  83403. * Gets if `setParticles()` computes the particle colors or not.
  83404. * Default value : true. The SPS is faster when it's set to false.
  83405. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83406. */
  83407. computeParticleColor: boolean;
  83408. /**
  83409. * Gets if `setParticles()` computes the particle textures or not.
  83410. * Default value : true. The SPS is faster when it's set to false.
  83411. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83412. */
  83413. computeParticleTexture: boolean;
  83414. /**
  83415. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83416. * Default value : false. The SPS is faster when it's set to false.
  83417. * Note : the particle custom vertex positions aren't stored values.
  83418. */
  83419. /**
  83420. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83421. * Default value : false. The SPS is faster when it's set to false.
  83422. * Note : the particle custom vertex positions aren't stored values.
  83423. */
  83424. computeParticleVertex: boolean;
  83425. /**
  83426. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83427. */
  83428. /**
  83429. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83430. */
  83431. computeBoundingBox: boolean;
  83432. /**
  83433. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83434. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83435. * Default : `true`
  83436. */
  83437. /**
  83438. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83439. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83440. * Default : `true`
  83441. */
  83442. depthSortParticles: boolean;
  83443. /**
  83444. * This function does nothing. It may be overwritten to set all the particle first values.
  83445. * The SPS doesn't call this function, you may have to call it by your own.
  83446. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83447. */
  83448. initParticles(): void;
  83449. /**
  83450. * This function does nothing. It may be overwritten to recycle a particle.
  83451. * The SPS doesn't call this function, you may have to call it by your own.
  83452. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83453. * @param particle The particle to recycle
  83454. * @returns the recycled particle
  83455. */
  83456. recycleParticle(particle: SolidParticle): SolidParticle;
  83457. /**
  83458. * Updates a particle : this function should be overwritten by the user.
  83459. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83460. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83461. * @example : just set a particle position or velocity and recycle conditions
  83462. * @param particle The particle to update
  83463. * @returns the updated particle
  83464. */
  83465. updateParticle(particle: SolidParticle): SolidParticle;
  83466. /**
  83467. * Updates a vertex of a particle : it can be overwritten by the user.
  83468. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83469. * @param particle the current particle
  83470. * @param vertex the current index of the current particle
  83471. * @param pt the index of the current vertex in the particle shape
  83472. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83473. * @example : just set a vertex particle position
  83474. * @returns the updated vertex
  83475. */
  83476. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83477. /**
  83478. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83479. * This does nothing and may be overwritten by the user.
  83480. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83481. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83482. * @param update the boolean update value actually passed to setParticles()
  83483. */
  83484. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83485. /**
  83486. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83487. * This will be passed three parameters.
  83488. * This does nothing and may be overwritten by the user.
  83489. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83490. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83491. * @param update the boolean update value actually passed to setParticles()
  83492. */
  83493. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83494. }
  83495. }
  83496. declare module BABYLON {
  83497. /**
  83498. * Represents one particle of a solid particle system.
  83499. */
  83500. export class SolidParticle {
  83501. /**
  83502. * particle global index
  83503. */
  83504. idx: number;
  83505. /**
  83506. * The color of the particle
  83507. */
  83508. color: Nullable<Color4>;
  83509. /**
  83510. * The world space position of the particle.
  83511. */
  83512. position: Vector3;
  83513. /**
  83514. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83515. */
  83516. rotation: Vector3;
  83517. /**
  83518. * The world space rotation quaternion of the particle.
  83519. */
  83520. rotationQuaternion: Nullable<Quaternion>;
  83521. /**
  83522. * The scaling of the particle.
  83523. */
  83524. scaling: Vector3;
  83525. /**
  83526. * The uvs of the particle.
  83527. */
  83528. uvs: Vector4;
  83529. /**
  83530. * The current speed of the particle.
  83531. */
  83532. velocity: Vector3;
  83533. /**
  83534. * The pivot point in the particle local space.
  83535. */
  83536. pivot: Vector3;
  83537. /**
  83538. * Must the particle be translated from its pivot point in its local space ?
  83539. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83540. * Default : false
  83541. */
  83542. translateFromPivot: boolean;
  83543. /**
  83544. * Is the particle active or not ?
  83545. */
  83546. alive: boolean;
  83547. /**
  83548. * Is the particle visible or not ?
  83549. */
  83550. isVisible: boolean;
  83551. /**
  83552. * Index of this particle in the global "positions" array (Internal use)
  83553. * @hidden
  83554. */
  83555. _pos: number;
  83556. /**
  83557. * @hidden Index of this particle in the global "indices" array (Internal use)
  83558. */
  83559. _ind: number;
  83560. /**
  83561. * @hidden ModelShape of this particle (Internal use)
  83562. */
  83563. _model: ModelShape;
  83564. /**
  83565. * ModelShape id of this particle
  83566. */
  83567. shapeId: number;
  83568. /**
  83569. * Index of the particle in its shape id (Internal use)
  83570. */
  83571. idxInShape: number;
  83572. /**
  83573. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83574. */
  83575. _modelBoundingInfo: BoundingInfo;
  83576. /**
  83577. * @hidden Particle BoundingInfo object (Internal use)
  83578. */
  83579. _boundingInfo: BoundingInfo;
  83580. /**
  83581. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  83582. */
  83583. _sps: SolidParticleSystem;
  83584. /**
  83585. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  83586. */
  83587. _stillInvisible: boolean;
  83588. /**
  83589. * @hidden Last computed particle rotation matrix
  83590. */
  83591. _rotationMatrix: number[];
  83592. /**
  83593. * Parent particle Id, if any.
  83594. * Default null.
  83595. */
  83596. parentId: Nullable<number>;
  83597. /**
  83598. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  83599. * The possible values are :
  83600. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83601. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83602. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83603. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83604. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83605. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  83606. * */
  83607. cullingStrategy: number;
  83608. /**
  83609. * @hidden Internal global position in the SPS.
  83610. */
  83611. _globalPosition: Vector3;
  83612. /**
  83613. * Creates a Solid Particle object.
  83614. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  83615. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  83616. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  83617. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  83618. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  83619. * @param shapeId (integer) is the model shape identifier in the SPS.
  83620. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  83621. * @param sps defines the sps it is associated to
  83622. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  83623. */
  83624. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  83625. /**
  83626. * Legacy support, changed scale to scaling
  83627. */
  83628. /**
  83629. * Legacy support, changed scale to scaling
  83630. */
  83631. scale: Vector3;
  83632. /**
  83633. * Legacy support, changed quaternion to rotationQuaternion
  83634. */
  83635. /**
  83636. * Legacy support, changed quaternion to rotationQuaternion
  83637. */
  83638. quaternion: Nullable<Quaternion>;
  83639. /**
  83640. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  83641. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  83642. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  83643. * @returns true if it intersects
  83644. */
  83645. intersectsMesh(target: Mesh | SolidParticle): boolean;
  83646. /**
  83647. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  83648. * A particle is in the frustum if its bounding box intersects the frustum
  83649. * @param frustumPlanes defines the frustum to test
  83650. * @returns true if the particle is in the frustum planes
  83651. */
  83652. isInFrustum(frustumPlanes: Plane[]): boolean;
  83653. /**
  83654. * get the rotation matrix of the particle
  83655. * @hidden
  83656. */
  83657. getRotationMatrix(m: Matrix): void;
  83658. }
  83659. /**
  83660. * Represents the shape of the model used by one particle of a solid particle system.
  83661. * SPS internal tool, don't use it manually.
  83662. */
  83663. export class ModelShape {
  83664. /**
  83665. * The shape id
  83666. * @hidden
  83667. */
  83668. shapeID: number;
  83669. /**
  83670. * flat array of model positions (internal use)
  83671. * @hidden
  83672. */
  83673. _shape: Vector3[];
  83674. /**
  83675. * flat array of model UVs (internal use)
  83676. * @hidden
  83677. */
  83678. _shapeUV: number[];
  83679. /**
  83680. * length of the shape in the model indices array (internal use)
  83681. * @hidden
  83682. */
  83683. _indicesLength: number;
  83684. /**
  83685. * Custom position function (internal use)
  83686. * @hidden
  83687. */
  83688. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  83689. /**
  83690. * Custom vertex function (internal use)
  83691. * @hidden
  83692. */
  83693. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  83694. /**
  83695. * 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.
  83696. * SPS internal tool, don't use it manually.
  83697. * @hidden
  83698. */
  83699. 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>);
  83700. }
  83701. /**
  83702. * Represents a Depth Sorted Particle in the solid particle system.
  83703. */
  83704. export class DepthSortedParticle {
  83705. /**
  83706. * Index of the particle in the "indices" array
  83707. */
  83708. ind: number;
  83709. /**
  83710. * Length of the particle shape in the "indices" array
  83711. */
  83712. indicesLength: number;
  83713. /**
  83714. * Squared distance from the particle to the camera
  83715. */
  83716. sqDistance: number;
  83717. }
  83718. }
  83719. declare module BABYLON {
  83720. /**
  83721. * Class used to store all common mesh properties
  83722. */
  83723. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  83724. /** No occlusion */
  83725. static OCCLUSION_TYPE_NONE: number;
  83726. /** Occlusion set to optimisitic */
  83727. static OCCLUSION_TYPE_OPTIMISTIC: number;
  83728. /** Occlusion set to strict */
  83729. static OCCLUSION_TYPE_STRICT: number;
  83730. /** Use an accurante occlusion algorithm */
  83731. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  83732. /** Use a conservative occlusion algorithm */
  83733. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  83734. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83735. * Test order :
  83736. * Is the bounding sphere outside the frustum ?
  83737. * If not, are the bounding box vertices outside the frustum ?
  83738. * It not, then the cullable object is in the frustum.
  83739. */
  83740. static readonly CULLINGSTRATEGY_STANDARD: number;
  83741. /** Culling strategy : Bounding Sphere Only.
  83742. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83743. * It's also less accurate than the standard because some not visible objects can still be selected.
  83744. * Test : is the bounding sphere outside the frustum ?
  83745. * If not, then the cullable object is in the frustum.
  83746. */
  83747. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  83748. /** Culling strategy : Optimistic Inclusion.
  83749. * This in an inclusion test first, then the standard exclusion test.
  83750. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83751. * 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.
  83752. * Anyway, it's as accurate as the standard strategy.
  83753. * Test :
  83754. * Is the cullable object bounding sphere center in the frustum ?
  83755. * If not, apply the default culling strategy.
  83756. */
  83757. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  83758. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83759. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83760. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83761. * 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.
  83762. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83763. * Test :
  83764. * Is the cullable object bounding sphere center in the frustum ?
  83765. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83766. */
  83767. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  83768. /**
  83769. * No billboard
  83770. */
  83771. static readonly BILLBOARDMODE_NONE: number;
  83772. /** Billboard on X axis */
  83773. static readonly BILLBOARDMODE_X: number;
  83774. /** Billboard on Y axis */
  83775. static readonly BILLBOARDMODE_Y: number;
  83776. /** Billboard on Z axis */
  83777. static readonly BILLBOARDMODE_Z: number;
  83778. /** Billboard on all axes */
  83779. static readonly BILLBOARDMODE_ALL: number;
  83780. private _facetData;
  83781. /**
  83782. * The culling strategy to use to check whether the mesh must be rendered or not.
  83783. * This value can be changed at any time and will be used on the next render mesh selection.
  83784. * The possible values are :
  83785. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83786. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83787. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83788. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83789. * Please read each static variable documentation to get details about the culling process.
  83790. * */
  83791. cullingStrategy: number;
  83792. /**
  83793. * Gets the number of facets in the mesh
  83794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83795. */
  83796. readonly facetNb: number;
  83797. /**
  83798. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  83799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83800. */
  83801. partitioningSubdivisions: number;
  83802. /**
  83803. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  83804. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  83805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83806. */
  83807. partitioningBBoxRatio: number;
  83808. /**
  83809. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  83810. * Works only for updatable meshes.
  83811. * Doesn't work with multi-materials
  83812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83813. */
  83814. mustDepthSortFacets: boolean;
  83815. /**
  83816. * The location (Vector3) where the facet depth sort must be computed from.
  83817. * By default, the active camera position.
  83818. * Used only when facet depth sort is enabled
  83819. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83820. */
  83821. facetDepthSortFrom: Vector3;
  83822. /**
  83823. * gets a boolean indicating if facetData is enabled
  83824. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83825. */
  83826. readonly isFacetDataEnabled: boolean;
  83827. /** @hidden */
  83828. _updateNonUniformScalingState(value: boolean): boolean;
  83829. /**
  83830. * An event triggered when this mesh collides with another one
  83831. */
  83832. onCollideObservable: Observable<AbstractMesh>;
  83833. private _onCollideObserver;
  83834. /** Set a function to call when this mesh collides with another one */
  83835. onCollide: () => void;
  83836. /**
  83837. * An event triggered when the collision's position changes
  83838. */
  83839. onCollisionPositionChangeObservable: Observable<Vector3>;
  83840. private _onCollisionPositionChangeObserver;
  83841. /** Set a function to call when the collision's position changes */
  83842. onCollisionPositionChange: () => void;
  83843. /**
  83844. * An event triggered when material is changed
  83845. */
  83846. onMaterialChangedObservable: Observable<AbstractMesh>;
  83847. /**
  83848. * Gets or sets the orientation for POV movement & rotation
  83849. */
  83850. definedFacingForward: boolean;
  83851. /** @hidden */
  83852. _occlusionQuery: Nullable<WebGLQuery>;
  83853. private _visibility;
  83854. /** @hidden */
  83855. _isActive: boolean;
  83856. /** @hidden */
  83857. _renderingGroup: Nullable<RenderingGroup>;
  83858. /**
  83859. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83860. */
  83861. /**
  83862. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83863. */
  83864. visibility: number;
  83865. /** Gets or sets the alpha index used to sort transparent meshes
  83866. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83867. */
  83868. alphaIndex: number;
  83869. /**
  83870. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83871. */
  83872. isVisible: boolean;
  83873. /**
  83874. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83875. */
  83876. isPickable: boolean;
  83877. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83878. showSubMeshesBoundingBox: boolean;
  83879. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83880. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83881. */
  83882. isBlocker: boolean;
  83883. /**
  83884. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83885. */
  83886. enablePointerMoveEvents: boolean;
  83887. /**
  83888. * Specifies the rendering group id for this mesh (0 by default)
  83889. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83890. */
  83891. renderingGroupId: number;
  83892. private _material;
  83893. /** Gets or sets current material */
  83894. material: Nullable<Material>;
  83895. private _receiveShadows;
  83896. /**
  83897. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  83898. * @see http://doc.babylonjs.com/babylon101/shadows
  83899. */
  83900. receiveShadows: boolean;
  83901. /** Defines color to use when rendering outline */
  83902. outlineColor: Color3;
  83903. /** Define width to use when rendering outline */
  83904. outlineWidth: number;
  83905. /** Defines color to use when rendering overlay */
  83906. overlayColor: Color3;
  83907. /** Defines alpha to use when rendering overlay */
  83908. overlayAlpha: number;
  83909. private _hasVertexAlpha;
  83910. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  83911. hasVertexAlpha: boolean;
  83912. private _useVertexColors;
  83913. /** 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) */
  83914. useVertexColors: boolean;
  83915. private _computeBonesUsingShaders;
  83916. /**
  83917. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  83918. */
  83919. computeBonesUsingShaders: boolean;
  83920. private _numBoneInfluencers;
  83921. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  83922. numBoneInfluencers: number;
  83923. private _applyFog;
  83924. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  83925. applyFog: boolean;
  83926. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83927. useOctreeForRenderingSelection: boolean;
  83928. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83929. useOctreeForPicking: boolean;
  83930. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83931. useOctreeForCollisions: boolean;
  83932. private _layerMask;
  83933. /**
  83934. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  83935. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  83936. */
  83937. layerMask: number;
  83938. /**
  83939. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83940. */
  83941. alwaysSelectAsActiveMesh: boolean;
  83942. /**
  83943. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  83944. */
  83945. doNotSyncBoundingInfo: boolean;
  83946. /**
  83947. * Gets or sets the current action manager
  83948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83949. */
  83950. actionManager: Nullable<AbstractActionManager>;
  83951. private _checkCollisions;
  83952. private _collisionMask;
  83953. private _collisionGroup;
  83954. /**
  83955. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83956. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83957. */
  83958. ellipsoid: Vector3;
  83959. /**
  83960. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83961. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83962. */
  83963. ellipsoidOffset: Vector3;
  83964. private _collider;
  83965. private _oldPositionForCollisions;
  83966. private _diffPositionForCollisions;
  83967. /**
  83968. * Gets or sets a collision mask used to mask collisions (default is -1).
  83969. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83970. */
  83971. collisionMask: number;
  83972. /**
  83973. * Gets or sets the current collision group mask (-1 by default).
  83974. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83975. */
  83976. collisionGroup: number;
  83977. /**
  83978. * Defines edge width used when edgesRenderer is enabled
  83979. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83980. */
  83981. edgesWidth: number;
  83982. /**
  83983. * Defines edge color used when edgesRenderer is enabled
  83984. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83985. */
  83986. edgesColor: Color4;
  83987. /** @hidden */
  83988. _edgesRenderer: Nullable<IEdgesRenderer>;
  83989. /** @hidden */
  83990. _masterMesh: Nullable<AbstractMesh>;
  83991. /** @hidden */
  83992. _boundingInfo: Nullable<BoundingInfo>;
  83993. /** @hidden */
  83994. _renderId: number;
  83995. /**
  83996. * Gets or sets the list of subMeshes
  83997. * @see http://doc.babylonjs.com/how_to/multi_materials
  83998. */
  83999. subMeshes: SubMesh[];
  84000. /** @hidden */
  84001. _intersectionsInProgress: AbstractMesh[];
  84002. /** @hidden */
  84003. _unIndexed: boolean;
  84004. /** @hidden */
  84005. _lightSources: Light[];
  84006. /** @hidden */
  84007. readonly _positions: Nullable<Vector3[]>;
  84008. /** @hidden */
  84009. _waitingActions: Nullable<any>;
  84010. /** @hidden */
  84011. _waitingFreezeWorldMatrix: Nullable<boolean>;
  84012. private _skeleton;
  84013. /** @hidden */
  84014. _bonesTransformMatrices: Nullable<Float32Array>;
  84015. /**
  84016. * Gets or sets a skeleton to apply skining transformations
  84017. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84018. */
  84019. skeleton: Nullable<Skeleton>;
  84020. /**
  84021. * An event triggered when the mesh is rebuilt.
  84022. */
  84023. onRebuildObservable: Observable<AbstractMesh>;
  84024. /**
  84025. * Creates a new AbstractMesh
  84026. * @param name defines the name of the mesh
  84027. * @param scene defines the hosting scene
  84028. */
  84029. constructor(name: string, scene?: Nullable<Scene>);
  84030. /**
  84031. * Returns the string "AbstractMesh"
  84032. * @returns "AbstractMesh"
  84033. */
  84034. getClassName(): string;
  84035. /**
  84036. * Gets a string representation of the current mesh
  84037. * @param fullDetails defines a boolean indicating if full details must be included
  84038. * @returns a string representation of the current mesh
  84039. */
  84040. toString(fullDetails?: boolean): string;
  84041. /**
  84042. * @hidden
  84043. */
  84044. protected _getEffectiveParent(): Nullable<Node>;
  84045. /** @hidden */
  84046. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84047. /** @hidden */
  84048. _rebuild(): void;
  84049. /** @hidden */
  84050. _resyncLightSources(): void;
  84051. /** @hidden */
  84052. _resyncLighSource(light: Light): void;
  84053. /** @hidden */
  84054. _unBindEffect(): void;
  84055. /** @hidden */
  84056. _removeLightSource(light: Light): void;
  84057. private _markSubMeshesAsDirty;
  84058. /** @hidden */
  84059. _markSubMeshesAsLightDirty(): void;
  84060. /** @hidden */
  84061. _markSubMeshesAsAttributesDirty(): void;
  84062. /** @hidden */
  84063. _markSubMeshesAsMiscDirty(): void;
  84064. /**
  84065. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84066. */
  84067. scaling: Vector3;
  84068. /**
  84069. * Returns true if the mesh is blocked. Implemented by child classes
  84070. */
  84071. readonly isBlocked: boolean;
  84072. /**
  84073. * Returns the mesh itself by default. Implemented by child classes
  84074. * @param camera defines the camera to use to pick the right LOD level
  84075. * @returns the currentAbstractMesh
  84076. */
  84077. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84078. /**
  84079. * Returns 0 by default. Implemented by child classes
  84080. * @returns an integer
  84081. */
  84082. getTotalVertices(): number;
  84083. /**
  84084. * Returns a positive integer : the total number of indices in this mesh geometry.
  84085. * @returns the numner of indices or zero if the mesh has no geometry.
  84086. */
  84087. getTotalIndices(): number;
  84088. /**
  84089. * Returns null by default. Implemented by child classes
  84090. * @returns null
  84091. */
  84092. getIndices(): Nullable<IndicesArray>;
  84093. /**
  84094. * Returns the array of the requested vertex data kind. Implemented by child classes
  84095. * @param kind defines the vertex data kind to use
  84096. * @returns null
  84097. */
  84098. getVerticesData(kind: string): Nullable<FloatArray>;
  84099. /**
  84100. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84101. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84102. * Note that a new underlying VertexBuffer object is created each call.
  84103. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84104. * @param kind defines vertex data kind:
  84105. * * VertexBuffer.PositionKind
  84106. * * VertexBuffer.UVKind
  84107. * * VertexBuffer.UV2Kind
  84108. * * VertexBuffer.UV3Kind
  84109. * * VertexBuffer.UV4Kind
  84110. * * VertexBuffer.UV5Kind
  84111. * * VertexBuffer.UV6Kind
  84112. * * VertexBuffer.ColorKind
  84113. * * VertexBuffer.MatricesIndicesKind
  84114. * * VertexBuffer.MatricesIndicesExtraKind
  84115. * * VertexBuffer.MatricesWeightsKind
  84116. * * VertexBuffer.MatricesWeightsExtraKind
  84117. * @param data defines the data source
  84118. * @param updatable defines if the data must be flagged as updatable (or static)
  84119. * @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
  84120. * @returns the current mesh
  84121. */
  84122. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84123. /**
  84124. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84125. * If the mesh has no geometry, it is simply returned as it is.
  84126. * @param kind defines vertex data kind:
  84127. * * VertexBuffer.PositionKind
  84128. * * VertexBuffer.UVKind
  84129. * * VertexBuffer.UV2Kind
  84130. * * VertexBuffer.UV3Kind
  84131. * * VertexBuffer.UV4Kind
  84132. * * VertexBuffer.UV5Kind
  84133. * * VertexBuffer.UV6Kind
  84134. * * VertexBuffer.ColorKind
  84135. * * VertexBuffer.MatricesIndicesKind
  84136. * * VertexBuffer.MatricesIndicesExtraKind
  84137. * * VertexBuffer.MatricesWeightsKind
  84138. * * VertexBuffer.MatricesWeightsExtraKind
  84139. * @param data defines the data source
  84140. * @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
  84141. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84142. * @returns the current mesh
  84143. */
  84144. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84145. /**
  84146. * Sets the mesh indices,
  84147. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84148. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84149. * @param totalVertices Defines the total number of vertices
  84150. * @returns the current mesh
  84151. */
  84152. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84153. /**
  84154. * Gets a boolean indicating if specific vertex data is present
  84155. * @param kind defines the vertex data kind to use
  84156. * @returns true is data kind is present
  84157. */
  84158. isVerticesDataPresent(kind: string): boolean;
  84159. /**
  84160. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84161. * @returns a BoundingInfo
  84162. */
  84163. getBoundingInfo(): BoundingInfo;
  84164. /**
  84165. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84166. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84167. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84168. * @returns the current mesh
  84169. */
  84170. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84171. /**
  84172. * Overwrite the current bounding info
  84173. * @param boundingInfo defines the new bounding info
  84174. * @returns the current mesh
  84175. */
  84176. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84177. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84178. readonly useBones: boolean;
  84179. /** @hidden */
  84180. _preActivate(): void;
  84181. /** @hidden */
  84182. _preActivateForIntermediateRendering(renderId: number): void;
  84183. /** @hidden */
  84184. _activate(renderId: number): boolean;
  84185. /** @hidden */
  84186. _freeze(): void;
  84187. /** @hidden */
  84188. _unFreeze(): void;
  84189. /**
  84190. * Gets the current world matrix
  84191. * @returns a Matrix
  84192. */
  84193. getWorldMatrix(): Matrix;
  84194. /** @hidden */
  84195. _getWorldMatrixDeterminant(): number;
  84196. /**
  84197. * Perform relative position change from the point of view of behind the front of the mesh.
  84198. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84199. * Supports definition of mesh facing forward or backward
  84200. * @param amountRight defines the distance on the right axis
  84201. * @param amountUp defines the distance on the up axis
  84202. * @param amountForward defines the distance on the forward axis
  84203. * @returns the current mesh
  84204. */
  84205. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84206. /**
  84207. * Calculate relative position change from the point of view of behind the front of the mesh.
  84208. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84209. * Supports definition of mesh facing forward or backward
  84210. * @param amountRight defines the distance on the right axis
  84211. * @param amountUp defines the distance on the up axis
  84212. * @param amountForward defines the distance on the forward axis
  84213. * @returns the new displacement vector
  84214. */
  84215. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84216. /**
  84217. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84218. * Supports definition of mesh facing forward or backward
  84219. * @param flipBack defines the flip
  84220. * @param twirlClockwise defines the twirl
  84221. * @param tiltRight defines the tilt
  84222. * @returns the current mesh
  84223. */
  84224. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84225. /**
  84226. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84227. * Supports definition of mesh facing forward or backward.
  84228. * @param flipBack defines the flip
  84229. * @param twirlClockwise defines the twirl
  84230. * @param tiltRight defines the tilt
  84231. * @returns the new rotation vector
  84232. */
  84233. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84234. /**
  84235. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84236. * This means the mesh underlying bounding box and sphere are recomputed.
  84237. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84238. * @returns the current mesh
  84239. */
  84240. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84241. /** @hidden */
  84242. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84243. /** @hidden */
  84244. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84245. /** @hidden */
  84246. _updateBoundingInfo(): AbstractMesh;
  84247. /** @hidden */
  84248. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84249. /** @hidden */
  84250. protected _afterComputeWorldMatrix(): void;
  84251. /** @hidden */
  84252. readonly _effectiveMesh: AbstractMesh;
  84253. /**
  84254. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84255. * A mesh is in the frustum if its bounding box intersects the frustum
  84256. * @param frustumPlanes defines the frustum to test
  84257. * @returns true if the mesh is in the frustum planes
  84258. */
  84259. isInFrustum(frustumPlanes: Plane[]): boolean;
  84260. /**
  84261. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84262. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84263. * @param frustumPlanes defines the frustum to test
  84264. * @returns true if the mesh is completely in the frustum planes
  84265. */
  84266. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84267. /**
  84268. * True if the mesh intersects another mesh or a SolidParticle object
  84269. * @param mesh defines a target mesh or SolidParticle to test
  84270. * @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)
  84271. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84272. * @returns true if there is an intersection
  84273. */
  84274. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84275. /**
  84276. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84277. * @param point defines the point to test
  84278. * @returns true if there is an intersection
  84279. */
  84280. intersectsPoint(point: Vector3): boolean;
  84281. /**
  84282. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84283. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84284. */
  84285. checkCollisions: boolean;
  84286. /**
  84287. * Gets Collider object used to compute collisions (not physics)
  84288. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84289. */
  84290. readonly collider: Nullable<Collider>;
  84291. /**
  84292. * Move the mesh using collision engine
  84293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84294. * @param displacement defines the requested displacement vector
  84295. * @returns the current mesh
  84296. */
  84297. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84298. private _onCollisionPositionChange;
  84299. /** @hidden */
  84300. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84301. /** @hidden */
  84302. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84303. /** @hidden */
  84304. _checkCollision(collider: Collider): AbstractMesh;
  84305. /** @hidden */
  84306. _generatePointsArray(): boolean;
  84307. /**
  84308. * Checks if the passed Ray intersects with the mesh
  84309. * @param ray defines the ray to use
  84310. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84311. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84312. * @returns the picking info
  84313. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84314. */
  84315. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84316. /**
  84317. * Clones the current mesh
  84318. * @param name defines the mesh name
  84319. * @param newParent defines the new mesh parent
  84320. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84321. * @returns the new mesh
  84322. */
  84323. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84324. /**
  84325. * Disposes all the submeshes of the current meshnp
  84326. * @returns the current mesh
  84327. */
  84328. releaseSubMeshes(): AbstractMesh;
  84329. /**
  84330. * Releases resources associated with this abstract mesh.
  84331. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84332. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84333. */
  84334. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84335. /**
  84336. * Adds the passed mesh as a child to the current mesh
  84337. * @param mesh defines the child mesh
  84338. * @returns the current mesh
  84339. */
  84340. addChild(mesh: AbstractMesh): AbstractMesh;
  84341. /**
  84342. * Removes the passed mesh from the current mesh children list
  84343. * @param mesh defines the child mesh
  84344. * @returns the current mesh
  84345. */
  84346. removeChild(mesh: AbstractMesh): AbstractMesh;
  84347. /** @hidden */
  84348. private _initFacetData;
  84349. /**
  84350. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84351. * This method can be called within the render loop.
  84352. * 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
  84353. * @returns the current mesh
  84354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84355. */
  84356. updateFacetData(): AbstractMesh;
  84357. /**
  84358. * Returns the facetLocalNormals array.
  84359. * The normals are expressed in the mesh local spac
  84360. * @returns an array of Vector3
  84361. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84362. */
  84363. getFacetLocalNormals(): Vector3[];
  84364. /**
  84365. * Returns the facetLocalPositions array.
  84366. * The facet positions are expressed in the mesh local space
  84367. * @returns an array of Vector3
  84368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84369. */
  84370. getFacetLocalPositions(): Vector3[];
  84371. /**
  84372. * Returns the facetLocalPartioning array
  84373. * @returns an array of array of numbers
  84374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84375. */
  84376. getFacetLocalPartitioning(): number[][];
  84377. /**
  84378. * Returns the i-th facet position in the world system.
  84379. * This method allocates a new Vector3 per call
  84380. * @param i defines the facet index
  84381. * @returns a new Vector3
  84382. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84383. */
  84384. getFacetPosition(i: number): Vector3;
  84385. /**
  84386. * Sets the reference Vector3 with the i-th facet position in the world system
  84387. * @param i defines the facet index
  84388. * @param ref defines the target vector
  84389. * @returns the current mesh
  84390. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84391. */
  84392. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84393. /**
  84394. * Returns the i-th facet normal in the world system.
  84395. * This method allocates a new Vector3 per call
  84396. * @param i defines the facet index
  84397. * @returns a new Vector3
  84398. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84399. */
  84400. getFacetNormal(i: number): Vector3;
  84401. /**
  84402. * Sets the reference Vector3 with the i-th facet normal in the world system
  84403. * @param i defines the facet index
  84404. * @param ref defines the target vector
  84405. * @returns the current mesh
  84406. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84407. */
  84408. getFacetNormalToRef(i: number, ref: Vector3): this;
  84409. /**
  84410. * 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)
  84411. * @param x defines x coordinate
  84412. * @param y defines y coordinate
  84413. * @param z defines z coordinate
  84414. * @returns the array of facet indexes
  84415. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84416. */
  84417. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84418. /**
  84419. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84420. * @param projected sets as the (x,y,z) world projection on the facet
  84421. * @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
  84422. * @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
  84423. * @param x defines x coordinate
  84424. * @param y defines y coordinate
  84425. * @param z defines z coordinate
  84426. * @returns the face index if found (or null instead)
  84427. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84428. */
  84429. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84430. /**
  84431. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84432. * @param projected sets as the (x,y,z) local projection on the facet
  84433. * @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
  84434. * @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
  84435. * @param x defines x coordinate
  84436. * @param y defines y coordinate
  84437. * @param z defines z coordinate
  84438. * @returns the face index if found (or null instead)
  84439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84440. */
  84441. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84442. /**
  84443. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84444. * @returns the parameters
  84445. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84446. */
  84447. getFacetDataParameters(): any;
  84448. /**
  84449. * Disables the feature FacetData and frees the related memory
  84450. * @returns the current mesh
  84451. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84452. */
  84453. disableFacetData(): AbstractMesh;
  84454. /**
  84455. * Updates the AbstractMesh indices array
  84456. * @param indices defines the data source
  84457. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84458. * @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)
  84459. * @returns the current mesh
  84460. */
  84461. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84462. /**
  84463. * Creates new normals data for the mesh
  84464. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84465. * @returns the current mesh
  84466. */
  84467. createNormals(updatable: boolean): AbstractMesh;
  84468. /**
  84469. * Align the mesh with a normal
  84470. * @param normal defines the normal to use
  84471. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84472. * @returns the current mesh
  84473. */
  84474. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84475. /** @hidden */
  84476. _checkOcclusionQuery(): boolean;
  84477. }
  84478. }
  84479. declare module BABYLON {
  84480. /**
  84481. * Interface used to define ActionEvent
  84482. */
  84483. export interface IActionEvent {
  84484. /** The mesh or sprite that triggered the action */
  84485. source: any;
  84486. /** The X mouse cursor position at the time of the event */
  84487. pointerX: number;
  84488. /** The Y mouse cursor position at the time of the event */
  84489. pointerY: number;
  84490. /** The mesh that is currently pointed at (can be null) */
  84491. meshUnderPointer: Nullable<AbstractMesh>;
  84492. /** the original (browser) event that triggered the ActionEvent */
  84493. sourceEvent?: any;
  84494. /** additional data for the event */
  84495. additionalData?: any;
  84496. }
  84497. /**
  84498. * ActionEvent is the event being sent when an action is triggered.
  84499. */
  84500. export class ActionEvent implements IActionEvent {
  84501. /** The mesh or sprite that triggered the action */
  84502. source: any;
  84503. /** The X mouse cursor position at the time of the event */
  84504. pointerX: number;
  84505. /** The Y mouse cursor position at the time of the event */
  84506. pointerY: number;
  84507. /** The mesh that is currently pointed at (can be null) */
  84508. meshUnderPointer: Nullable<AbstractMesh>;
  84509. /** the original (browser) event that triggered the ActionEvent */
  84510. sourceEvent?: any;
  84511. /** additional data for the event */
  84512. additionalData?: any;
  84513. /**
  84514. * Creates a new ActionEvent
  84515. * @param source The mesh or sprite that triggered the action
  84516. * @param pointerX The X mouse cursor position at the time of the event
  84517. * @param pointerY The Y mouse cursor position at the time of the event
  84518. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84519. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84520. * @param additionalData additional data for the event
  84521. */
  84522. constructor(
  84523. /** The mesh or sprite that triggered the action */
  84524. source: any,
  84525. /** The X mouse cursor position at the time of the event */
  84526. pointerX: number,
  84527. /** The Y mouse cursor position at the time of the event */
  84528. pointerY: number,
  84529. /** The mesh that is currently pointed at (can be null) */
  84530. meshUnderPointer: Nullable<AbstractMesh>,
  84531. /** the original (browser) event that triggered the ActionEvent */
  84532. sourceEvent?: any,
  84533. /** additional data for the event */
  84534. additionalData?: any);
  84535. /**
  84536. * Helper function to auto-create an ActionEvent from a source mesh.
  84537. * @param source The source mesh that triggered the event
  84538. * @param evt The original (browser) event
  84539. * @param additionalData additional data for the event
  84540. * @returns the new ActionEvent
  84541. */
  84542. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84543. /**
  84544. * Helper function to auto-create an ActionEvent from a source sprite
  84545. * @param source The source sprite that triggered the event
  84546. * @param scene Scene associated with the sprite
  84547. * @param evt The original (browser) event
  84548. * @param additionalData additional data for the event
  84549. * @returns the new ActionEvent
  84550. */
  84551. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84552. /**
  84553. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84554. * @param scene the scene where the event occurred
  84555. * @param evt The original (browser) event
  84556. * @returns the new ActionEvent
  84557. */
  84558. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84559. /**
  84560. * Helper function to auto-create an ActionEvent from a primitive
  84561. * @param prim defines the target primitive
  84562. * @param pointerPos defines the pointer position
  84563. * @param evt The original (browser) event
  84564. * @param additionalData additional data for the event
  84565. * @returns the new ActionEvent
  84566. */
  84567. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  84568. }
  84569. }
  84570. declare module BABYLON {
  84571. /**
  84572. * Abstract class used to decouple action Manager from scene and meshes.
  84573. * Do not instantiate.
  84574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84575. */
  84576. export abstract class AbstractActionManager implements IDisposable {
  84577. /** Gets the list of active triggers */
  84578. static Triggers: {
  84579. [key: string]: number;
  84580. };
  84581. /** Gets the cursor to use when hovering items */
  84582. hoverCursor: string;
  84583. /** Gets the list of actions */
  84584. actions: IAction[];
  84585. /**
  84586. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  84587. */
  84588. isRecursive: boolean;
  84589. /**
  84590. * Releases all associated resources
  84591. */
  84592. abstract dispose(): void;
  84593. /**
  84594. * Does this action manager has pointer triggers
  84595. */
  84596. abstract readonly hasPointerTriggers: boolean;
  84597. /**
  84598. * Does this action manager has pick triggers
  84599. */
  84600. abstract readonly hasPickTriggers: boolean;
  84601. /**
  84602. * Process a specific trigger
  84603. * @param trigger defines the trigger to process
  84604. * @param evt defines the event details to be processed
  84605. */
  84606. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  84607. /**
  84608. * Does this action manager handles actions of any of the given triggers
  84609. * @param triggers defines the triggers to be tested
  84610. * @return a boolean indicating whether one (or more) of the triggers is handled
  84611. */
  84612. abstract hasSpecificTriggers(triggers: number[]): boolean;
  84613. /**
  84614. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  84615. * speed.
  84616. * @param triggerA defines the trigger to be tested
  84617. * @param triggerB defines the trigger to be tested
  84618. * @return a boolean indicating whether one (or more) of the triggers is handled
  84619. */
  84620. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84621. /**
  84622. * Does this action manager handles actions of a given trigger
  84623. * @param trigger defines the trigger to be tested
  84624. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84625. * @return whether the trigger is handled
  84626. */
  84627. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84628. /**
  84629. * Serialize this manager to a JSON object
  84630. * @param name defines the property name to store this manager
  84631. * @returns a JSON representation of this manager
  84632. */
  84633. abstract serialize(name: string): any;
  84634. /**
  84635. * Registers an action to this action manager
  84636. * @param action defines the action to be registered
  84637. * @return the action amended (prepared) after registration
  84638. */
  84639. abstract registerAction(action: IAction): Nullable<IAction>;
  84640. /**
  84641. * Unregisters an action to this action manager
  84642. * @param action defines the action to be unregistered
  84643. * @return a boolean indicating whether the action has been unregistered
  84644. */
  84645. abstract unregisterAction(action: IAction): Boolean;
  84646. /**
  84647. * Does exist one action manager with at least one trigger
  84648. **/
  84649. static readonly HasTriggers: boolean;
  84650. /**
  84651. * Does exist one action manager with at least one pick trigger
  84652. **/
  84653. static readonly HasPickTriggers: boolean;
  84654. /**
  84655. * Does exist one action manager that handles actions of a given trigger
  84656. * @param trigger defines the trigger to be tested
  84657. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  84658. **/
  84659. static HasSpecificTrigger(trigger: number): boolean;
  84660. }
  84661. }
  84662. declare module BABYLON {
  84663. /**
  84664. * Defines how a node can be built from a string name.
  84665. */
  84666. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  84667. /**
  84668. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  84669. */
  84670. export class Node implements IBehaviorAware<Node> {
  84671. /** @hidden */
  84672. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  84673. private static _NodeConstructors;
  84674. /**
  84675. * Add a new node constructor
  84676. * @param type defines the type name of the node to construct
  84677. * @param constructorFunc defines the constructor function
  84678. */
  84679. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  84680. /**
  84681. * Returns a node constructor based on type name
  84682. * @param type defines the type name
  84683. * @param name defines the new node name
  84684. * @param scene defines the hosting scene
  84685. * @param options defines optional options to transmit to constructors
  84686. * @returns the new constructor or null
  84687. */
  84688. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  84689. /**
  84690. * Gets or sets the name of the node
  84691. */
  84692. name: string;
  84693. /**
  84694. * Gets or sets the id of the node
  84695. */
  84696. id: string;
  84697. /**
  84698. * Gets or sets the unique id of the node
  84699. */
  84700. uniqueId: number;
  84701. /**
  84702. * Gets or sets a string used to store user defined state for the node
  84703. */
  84704. state: string;
  84705. /**
  84706. * Gets or sets an object used to store user defined information for the node
  84707. */
  84708. metadata: any;
  84709. /**
  84710. * For internal use only. Please do not use.
  84711. */
  84712. reservedDataStore: any;
  84713. /**
  84714. * List of inspectable custom properties (used by the Inspector)
  84715. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84716. */
  84717. inspectableCustomProperties: IInspectable[];
  84718. /**
  84719. * Gets or sets a boolean used to define if the node must be serialized
  84720. */
  84721. doNotSerialize: boolean;
  84722. /** @hidden */
  84723. _isDisposed: boolean;
  84724. /**
  84725. * Gets a list of Animations associated with the node
  84726. */
  84727. animations: Animation[];
  84728. protected _ranges: {
  84729. [name: string]: Nullable<AnimationRange>;
  84730. };
  84731. /**
  84732. * Callback raised when the node is ready to be used
  84733. */
  84734. onReady: Nullable<(node: Node) => void>;
  84735. private _isEnabled;
  84736. private _isParentEnabled;
  84737. private _isReady;
  84738. /** @hidden */
  84739. _currentRenderId: number;
  84740. private _parentUpdateId;
  84741. /** @hidden */
  84742. _childUpdateId: number;
  84743. /** @hidden */
  84744. _waitingParentId: Nullable<string>;
  84745. /** @hidden */
  84746. _scene: Scene;
  84747. /** @hidden */
  84748. _cache: any;
  84749. private _parentNode;
  84750. private _children;
  84751. /** @hidden */
  84752. _worldMatrix: Matrix;
  84753. /** @hidden */
  84754. _worldMatrixDeterminant: number;
  84755. /** @hidden */
  84756. _worldMatrixDeterminantIsDirty: boolean;
  84757. /** @hidden */
  84758. private _sceneRootNodesIndex;
  84759. /**
  84760. * Gets a boolean indicating if the node has been disposed
  84761. * @returns true if the node was disposed
  84762. */
  84763. isDisposed(): boolean;
  84764. /**
  84765. * Gets or sets the parent of the node (without keeping the current position in the scene)
  84766. * @see https://doc.babylonjs.com/how_to/parenting
  84767. */
  84768. parent: Nullable<Node>;
  84769. private addToSceneRootNodes;
  84770. private removeFromSceneRootNodes;
  84771. private _animationPropertiesOverride;
  84772. /**
  84773. * Gets or sets the animation properties override
  84774. */
  84775. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  84776. /**
  84777. * Gets a string idenfifying the name of the class
  84778. * @returns "Node" string
  84779. */
  84780. getClassName(): string;
  84781. /** @hidden */
  84782. readonly _isNode: boolean;
  84783. /**
  84784. * An event triggered when the mesh is disposed
  84785. */
  84786. onDisposeObservable: Observable<Node>;
  84787. private _onDisposeObserver;
  84788. /**
  84789. * Sets a callback that will be raised when the node will be disposed
  84790. */
  84791. onDispose: () => void;
  84792. /**
  84793. * Creates a new Node
  84794. * @param name the name and id to be given to this node
  84795. * @param scene the scene this node will be added to
  84796. * @param addToRootNodes the node will be added to scene.rootNodes
  84797. */
  84798. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  84799. /**
  84800. * Gets the scene of the node
  84801. * @returns a scene
  84802. */
  84803. getScene(): Scene;
  84804. /**
  84805. * Gets the engine of the node
  84806. * @returns a Engine
  84807. */
  84808. getEngine(): Engine;
  84809. private _behaviors;
  84810. /**
  84811. * Attach a behavior to the node
  84812. * @see http://doc.babylonjs.com/features/behaviour
  84813. * @param behavior defines the behavior to attach
  84814. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  84815. * @returns the current Node
  84816. */
  84817. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  84818. /**
  84819. * Remove an attached behavior
  84820. * @see http://doc.babylonjs.com/features/behaviour
  84821. * @param behavior defines the behavior to attach
  84822. * @returns the current Node
  84823. */
  84824. removeBehavior(behavior: Behavior<Node>): Node;
  84825. /**
  84826. * Gets the list of attached behaviors
  84827. * @see http://doc.babylonjs.com/features/behaviour
  84828. */
  84829. readonly behaviors: Behavior<Node>[];
  84830. /**
  84831. * Gets an attached behavior by name
  84832. * @param name defines the name of the behavior to look for
  84833. * @see http://doc.babylonjs.com/features/behaviour
  84834. * @returns null if behavior was not found else the requested behavior
  84835. */
  84836. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  84837. /**
  84838. * Returns the latest update of the World matrix
  84839. * @returns a Matrix
  84840. */
  84841. getWorldMatrix(): Matrix;
  84842. /** @hidden */
  84843. _getWorldMatrixDeterminant(): number;
  84844. /**
  84845. * Returns directly the latest state of the mesh World matrix.
  84846. * A Matrix is returned.
  84847. */
  84848. readonly worldMatrixFromCache: Matrix;
  84849. /** @hidden */
  84850. _initCache(): void;
  84851. /** @hidden */
  84852. updateCache(force?: boolean): void;
  84853. /** @hidden */
  84854. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84855. /** @hidden */
  84856. _updateCache(ignoreParentClass?: boolean): void;
  84857. /** @hidden */
  84858. _isSynchronized(): boolean;
  84859. /** @hidden */
  84860. _markSyncedWithParent(): void;
  84861. /** @hidden */
  84862. isSynchronizedWithParent(): boolean;
  84863. /** @hidden */
  84864. isSynchronized(): boolean;
  84865. /**
  84866. * Is this node ready to be used/rendered
  84867. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84868. * @return true if the node is ready
  84869. */
  84870. isReady(completeCheck?: boolean): boolean;
  84871. /**
  84872. * Is this node enabled?
  84873. * 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
  84874. * @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
  84875. * @return whether this node (and its parent) is enabled
  84876. */
  84877. isEnabled(checkAncestors?: boolean): boolean;
  84878. /** @hidden */
  84879. protected _syncParentEnabledState(): void;
  84880. /**
  84881. * Set the enabled state of this node
  84882. * @param value defines the new enabled state
  84883. */
  84884. setEnabled(value: boolean): void;
  84885. /**
  84886. * Is this node a descendant of the given node?
  84887. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  84888. * @param ancestor defines the parent node to inspect
  84889. * @returns a boolean indicating if this node is a descendant of the given node
  84890. */
  84891. isDescendantOf(ancestor: Node): boolean;
  84892. /** @hidden */
  84893. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  84894. /**
  84895. * Will return all nodes that have this node as ascendant
  84896. * @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
  84897. * @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
  84898. * @return all children nodes of all types
  84899. */
  84900. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  84901. /**
  84902. * Get all child-meshes of this node
  84903. * @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)
  84904. * @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
  84905. * @returns an array of AbstractMesh
  84906. */
  84907. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  84908. /**
  84909. * Get all direct children of this node
  84910. * @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
  84911. * @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)
  84912. * @returns an array of Node
  84913. */
  84914. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  84915. /** @hidden */
  84916. _setReady(state: boolean): void;
  84917. /**
  84918. * Get an animation by name
  84919. * @param name defines the name of the animation to look for
  84920. * @returns null if not found else the requested animation
  84921. */
  84922. getAnimationByName(name: string): Nullable<Animation>;
  84923. /**
  84924. * Creates an animation range for this node
  84925. * @param name defines the name of the range
  84926. * @param from defines the starting key
  84927. * @param to defines the end key
  84928. */
  84929. createAnimationRange(name: string, from: number, to: number): void;
  84930. /**
  84931. * Delete a specific animation range
  84932. * @param name defines the name of the range to delete
  84933. * @param deleteFrames defines if animation frames from the range must be deleted as well
  84934. */
  84935. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84936. /**
  84937. * Get an animation range by name
  84938. * @param name defines the name of the animation range to look for
  84939. * @returns null if not found else the requested animation range
  84940. */
  84941. getAnimationRange(name: string): Nullable<AnimationRange>;
  84942. /**
  84943. * Gets the list of all animation ranges defined on this node
  84944. * @returns an array
  84945. */
  84946. getAnimationRanges(): Nullable<AnimationRange>[];
  84947. /**
  84948. * Will start the animation sequence
  84949. * @param name defines the range frames for animation sequence
  84950. * @param loop defines if the animation should loop (false by default)
  84951. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  84952. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  84953. * @returns the object created for this animation. If range does not exist, it will return null
  84954. */
  84955. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84956. /**
  84957. * Serialize animation ranges into a JSON compatible object
  84958. * @returns serialization object
  84959. */
  84960. serializeAnimationRanges(): any;
  84961. /**
  84962. * Computes the world matrix of the node
  84963. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84964. * @returns the world matrix
  84965. */
  84966. computeWorldMatrix(force?: boolean): Matrix;
  84967. /**
  84968. * Releases resources associated with this node.
  84969. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84970. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84971. */
  84972. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84973. /**
  84974. * Parse animation range data from a serialization object and store them into a given node
  84975. * @param node defines where to store the animation ranges
  84976. * @param parsedNode defines the serialization object to read data from
  84977. * @param scene defines the hosting scene
  84978. */
  84979. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  84980. /**
  84981. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  84982. * @param includeDescendants Include bounding info from descendants as well (true by default)
  84983. * @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
  84984. * @returns the new bounding vectors
  84985. */
  84986. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  84987. min: Vector3;
  84988. max: Vector3;
  84989. };
  84990. }
  84991. }
  84992. declare module BABYLON {
  84993. /**
  84994. * @hidden
  84995. */
  84996. export class _IAnimationState {
  84997. key: number;
  84998. repeatCount: number;
  84999. workValue?: any;
  85000. loopMode?: number;
  85001. offsetValue?: any;
  85002. highLimitValue?: any;
  85003. }
  85004. /**
  85005. * Class used to store any kind of animation
  85006. */
  85007. export class Animation {
  85008. /**Name of the animation */
  85009. name: string;
  85010. /**Property to animate */
  85011. targetProperty: string;
  85012. /**The frames per second of the animation */
  85013. framePerSecond: number;
  85014. /**The data type of the animation */
  85015. dataType: number;
  85016. /**The loop mode of the animation */
  85017. loopMode?: number | undefined;
  85018. /**Specifies if blending should be enabled */
  85019. enableBlending?: boolean | undefined;
  85020. /**
  85021. * Use matrix interpolation instead of using direct key value when animating matrices
  85022. */
  85023. static AllowMatricesInterpolation: boolean;
  85024. /**
  85025. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85026. */
  85027. static AllowMatrixDecomposeForInterpolation: boolean;
  85028. /**
  85029. * Stores the key frames of the animation
  85030. */
  85031. private _keys;
  85032. /**
  85033. * Stores the easing function of the animation
  85034. */
  85035. private _easingFunction;
  85036. /**
  85037. * @hidden Internal use only
  85038. */
  85039. _runtimeAnimations: RuntimeAnimation[];
  85040. /**
  85041. * The set of event that will be linked to this animation
  85042. */
  85043. private _events;
  85044. /**
  85045. * Stores an array of target property paths
  85046. */
  85047. targetPropertyPath: string[];
  85048. /**
  85049. * Stores the blending speed of the animation
  85050. */
  85051. blendingSpeed: number;
  85052. /**
  85053. * Stores the animation ranges for the animation
  85054. */
  85055. private _ranges;
  85056. /**
  85057. * @hidden Internal use
  85058. */
  85059. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85060. /**
  85061. * Sets up an animation
  85062. * @param property The property to animate
  85063. * @param animationType The animation type to apply
  85064. * @param framePerSecond The frames per second of the animation
  85065. * @param easingFunction The easing function used in the animation
  85066. * @returns The created animation
  85067. */
  85068. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85069. /**
  85070. * Create and start an animation on a node
  85071. * @param name defines the name of the global animation that will be run on all nodes
  85072. * @param node defines the root node where the animation will take place
  85073. * @param targetProperty defines property to animate
  85074. * @param framePerSecond defines the number of frame per second yo use
  85075. * @param totalFrame defines the number of frames in total
  85076. * @param from defines the initial value
  85077. * @param to defines the final value
  85078. * @param loopMode defines which loop mode you want to use (off by default)
  85079. * @param easingFunction defines the easing function to use (linear by default)
  85080. * @param onAnimationEnd defines the callback to call when animation end
  85081. * @returns the animatable created for this animation
  85082. */
  85083. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85084. /**
  85085. * Create and start an animation on a node and its descendants
  85086. * @param name defines the name of the global animation that will be run on all nodes
  85087. * @param node defines the root node where the animation will take place
  85088. * @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
  85089. * @param targetProperty defines property to animate
  85090. * @param framePerSecond defines the number of frame per second to use
  85091. * @param totalFrame defines the number of frames in total
  85092. * @param from defines the initial value
  85093. * @param to defines the final value
  85094. * @param loopMode defines which loop mode you want to use (off by default)
  85095. * @param easingFunction defines the easing function to use (linear by default)
  85096. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85097. * @returns the list of animatables created for all nodes
  85098. * @example https://www.babylonjs-playground.com/#MH0VLI
  85099. */
  85100. 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[]>;
  85101. /**
  85102. * Creates a new animation, merges it with the existing animations and starts it
  85103. * @param name Name of the animation
  85104. * @param node Node which contains the scene that begins the animations
  85105. * @param targetProperty Specifies which property to animate
  85106. * @param framePerSecond The frames per second of the animation
  85107. * @param totalFrame The total number of frames
  85108. * @param from The frame at the beginning of the animation
  85109. * @param to The frame at the end of the animation
  85110. * @param loopMode Specifies the loop mode of the animation
  85111. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85112. * @param onAnimationEnd Callback to run once the animation is complete
  85113. * @returns Nullable animation
  85114. */
  85115. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85116. /**
  85117. * Transition property of an host to the target Value
  85118. * @param property The property to transition
  85119. * @param targetValue The target Value of the property
  85120. * @param host The object where the property to animate belongs
  85121. * @param scene Scene used to run the animation
  85122. * @param frameRate Framerate (in frame/s) to use
  85123. * @param transition The transition type we want to use
  85124. * @param duration The duration of the animation, in milliseconds
  85125. * @param onAnimationEnd Callback trigger at the end of the animation
  85126. * @returns Nullable animation
  85127. */
  85128. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85129. /**
  85130. * Return the array of runtime animations currently using this animation
  85131. */
  85132. readonly runtimeAnimations: RuntimeAnimation[];
  85133. /**
  85134. * Specifies if any of the runtime animations are currently running
  85135. */
  85136. readonly hasRunningRuntimeAnimations: boolean;
  85137. /**
  85138. * Initializes the animation
  85139. * @param name Name of the animation
  85140. * @param targetProperty Property to animate
  85141. * @param framePerSecond The frames per second of the animation
  85142. * @param dataType The data type of the animation
  85143. * @param loopMode The loop mode of the animation
  85144. * @param enableBlending Specifies if blending should be enabled
  85145. */
  85146. constructor(
  85147. /**Name of the animation */
  85148. name: string,
  85149. /**Property to animate */
  85150. targetProperty: string,
  85151. /**The frames per second of the animation */
  85152. framePerSecond: number,
  85153. /**The data type of the animation */
  85154. dataType: number,
  85155. /**The loop mode of the animation */
  85156. loopMode?: number | undefined,
  85157. /**Specifies if blending should be enabled */
  85158. enableBlending?: boolean | undefined);
  85159. /**
  85160. * Converts the animation to a string
  85161. * @param fullDetails support for multiple levels of logging within scene loading
  85162. * @returns String form of the animation
  85163. */
  85164. toString(fullDetails?: boolean): string;
  85165. /**
  85166. * Add an event to this animation
  85167. * @param event Event to add
  85168. */
  85169. addEvent(event: AnimationEvent): void;
  85170. /**
  85171. * Remove all events found at the given frame
  85172. * @param frame The frame to remove events from
  85173. */
  85174. removeEvents(frame: number): void;
  85175. /**
  85176. * Retrieves all the events from the animation
  85177. * @returns Events from the animation
  85178. */
  85179. getEvents(): AnimationEvent[];
  85180. /**
  85181. * Creates an animation range
  85182. * @param name Name of the animation range
  85183. * @param from Starting frame of the animation range
  85184. * @param to Ending frame of the animation
  85185. */
  85186. createRange(name: string, from: number, to: number): void;
  85187. /**
  85188. * Deletes an animation range by name
  85189. * @param name Name of the animation range to delete
  85190. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85191. */
  85192. deleteRange(name: string, deleteFrames?: boolean): void;
  85193. /**
  85194. * Gets the animation range by name, or null if not defined
  85195. * @param name Name of the animation range
  85196. * @returns Nullable animation range
  85197. */
  85198. getRange(name: string): Nullable<AnimationRange>;
  85199. /**
  85200. * Gets the key frames from the animation
  85201. * @returns The key frames of the animation
  85202. */
  85203. getKeys(): Array<IAnimationKey>;
  85204. /**
  85205. * Gets the highest frame rate of the animation
  85206. * @returns Highest frame rate of the animation
  85207. */
  85208. getHighestFrame(): number;
  85209. /**
  85210. * Gets the easing function of the animation
  85211. * @returns Easing function of the animation
  85212. */
  85213. getEasingFunction(): IEasingFunction;
  85214. /**
  85215. * Sets the easing function of the animation
  85216. * @param easingFunction A custom mathematical formula for animation
  85217. */
  85218. setEasingFunction(easingFunction: EasingFunction): void;
  85219. /**
  85220. * Interpolates a scalar linearly
  85221. * @param startValue Start value of the animation curve
  85222. * @param endValue End value of the animation curve
  85223. * @param gradient Scalar amount to interpolate
  85224. * @returns Interpolated scalar value
  85225. */
  85226. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85227. /**
  85228. * Interpolates a scalar cubically
  85229. * @param startValue Start value of the animation curve
  85230. * @param outTangent End tangent of the animation
  85231. * @param endValue End value of the animation curve
  85232. * @param inTangent Start tangent of the animation curve
  85233. * @param gradient Scalar amount to interpolate
  85234. * @returns Interpolated scalar value
  85235. */
  85236. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85237. /**
  85238. * Interpolates a quaternion using a spherical linear interpolation
  85239. * @param startValue Start value of the animation curve
  85240. * @param endValue End value of the animation curve
  85241. * @param gradient Scalar amount to interpolate
  85242. * @returns Interpolated quaternion value
  85243. */
  85244. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85245. /**
  85246. * Interpolates a quaternion cubically
  85247. * @param startValue Start value of the animation curve
  85248. * @param outTangent End tangent of the animation curve
  85249. * @param endValue End value of the animation curve
  85250. * @param inTangent Start tangent of the animation curve
  85251. * @param gradient Scalar amount to interpolate
  85252. * @returns Interpolated quaternion value
  85253. */
  85254. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85255. /**
  85256. * Interpolates a Vector3 linearl
  85257. * @param startValue Start value of the animation curve
  85258. * @param endValue End value of the animation curve
  85259. * @param gradient Scalar amount to interpolate
  85260. * @returns Interpolated scalar value
  85261. */
  85262. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85263. /**
  85264. * Interpolates a Vector3 cubically
  85265. * @param startValue Start value of the animation curve
  85266. * @param outTangent End tangent of the animation
  85267. * @param endValue End value of the animation curve
  85268. * @param inTangent Start tangent of the animation curve
  85269. * @param gradient Scalar amount to interpolate
  85270. * @returns InterpolatedVector3 value
  85271. */
  85272. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85273. /**
  85274. * Interpolates a Vector2 linearly
  85275. * @param startValue Start value of the animation curve
  85276. * @param endValue End value of the animation curve
  85277. * @param gradient Scalar amount to interpolate
  85278. * @returns Interpolated Vector2 value
  85279. */
  85280. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85281. /**
  85282. * Interpolates a Vector2 cubically
  85283. * @param startValue Start value of the animation curve
  85284. * @param outTangent End tangent of the animation
  85285. * @param endValue End value of the animation curve
  85286. * @param inTangent Start tangent of the animation curve
  85287. * @param gradient Scalar amount to interpolate
  85288. * @returns Interpolated Vector2 value
  85289. */
  85290. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85291. /**
  85292. * Interpolates a size linearly
  85293. * @param startValue Start value of the animation curve
  85294. * @param endValue End value of the animation curve
  85295. * @param gradient Scalar amount to interpolate
  85296. * @returns Interpolated Size value
  85297. */
  85298. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85299. /**
  85300. * Interpolates a Color3 linearly
  85301. * @param startValue Start value of the animation curve
  85302. * @param endValue End value of the animation curve
  85303. * @param gradient Scalar amount to interpolate
  85304. * @returns Interpolated Color3 value
  85305. */
  85306. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85307. /**
  85308. * @hidden Internal use only
  85309. */
  85310. _getKeyValue(value: any): any;
  85311. /**
  85312. * @hidden Internal use only
  85313. */
  85314. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85315. /**
  85316. * Defines the function to use to interpolate matrices
  85317. * @param startValue defines the start matrix
  85318. * @param endValue defines the end matrix
  85319. * @param gradient defines the gradient between both matrices
  85320. * @param result defines an optional target matrix where to store the interpolation
  85321. * @returns the interpolated matrix
  85322. */
  85323. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85324. /**
  85325. * Makes a copy of the animation
  85326. * @returns Cloned animation
  85327. */
  85328. clone(): Animation;
  85329. /**
  85330. * Sets the key frames of the animation
  85331. * @param values The animation key frames to set
  85332. */
  85333. setKeys(values: Array<IAnimationKey>): void;
  85334. /**
  85335. * Serializes the animation to an object
  85336. * @returns Serialized object
  85337. */
  85338. serialize(): any;
  85339. /**
  85340. * Float animation type
  85341. */
  85342. private static _ANIMATIONTYPE_FLOAT;
  85343. /**
  85344. * Vector3 animation type
  85345. */
  85346. private static _ANIMATIONTYPE_VECTOR3;
  85347. /**
  85348. * Quaternion animation type
  85349. */
  85350. private static _ANIMATIONTYPE_QUATERNION;
  85351. /**
  85352. * Matrix animation type
  85353. */
  85354. private static _ANIMATIONTYPE_MATRIX;
  85355. /**
  85356. * Color3 animation type
  85357. */
  85358. private static _ANIMATIONTYPE_COLOR3;
  85359. /**
  85360. * Vector2 animation type
  85361. */
  85362. private static _ANIMATIONTYPE_VECTOR2;
  85363. /**
  85364. * Size animation type
  85365. */
  85366. private static _ANIMATIONTYPE_SIZE;
  85367. /**
  85368. * Relative Loop Mode
  85369. */
  85370. private static _ANIMATIONLOOPMODE_RELATIVE;
  85371. /**
  85372. * Cycle Loop Mode
  85373. */
  85374. private static _ANIMATIONLOOPMODE_CYCLE;
  85375. /**
  85376. * Constant Loop Mode
  85377. */
  85378. private static _ANIMATIONLOOPMODE_CONSTANT;
  85379. /**
  85380. * Get the float animation type
  85381. */
  85382. static readonly ANIMATIONTYPE_FLOAT: number;
  85383. /**
  85384. * Get the Vector3 animation type
  85385. */
  85386. static readonly ANIMATIONTYPE_VECTOR3: number;
  85387. /**
  85388. * Get the Vector2 animation type
  85389. */
  85390. static readonly ANIMATIONTYPE_VECTOR2: number;
  85391. /**
  85392. * Get the Size animation type
  85393. */
  85394. static readonly ANIMATIONTYPE_SIZE: number;
  85395. /**
  85396. * Get the Quaternion animation type
  85397. */
  85398. static readonly ANIMATIONTYPE_QUATERNION: number;
  85399. /**
  85400. * Get the Matrix animation type
  85401. */
  85402. static readonly ANIMATIONTYPE_MATRIX: number;
  85403. /**
  85404. * Get the Color3 animation type
  85405. */
  85406. static readonly ANIMATIONTYPE_COLOR3: number;
  85407. /**
  85408. * Get the Relative Loop Mode
  85409. */
  85410. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85411. /**
  85412. * Get the Cycle Loop Mode
  85413. */
  85414. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85415. /**
  85416. * Get the Constant Loop Mode
  85417. */
  85418. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85419. /** @hidden */
  85420. static _UniversalLerp(left: any, right: any, amount: number): any;
  85421. /**
  85422. * Parses an animation object and creates an animation
  85423. * @param parsedAnimation Parsed animation object
  85424. * @returns Animation object
  85425. */
  85426. static Parse(parsedAnimation: any): Animation;
  85427. /**
  85428. * Appends the serialized animations from the source animations
  85429. * @param source Source containing the animations
  85430. * @param destination Target to store the animations
  85431. */
  85432. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85433. }
  85434. }
  85435. declare module BABYLON {
  85436. /**
  85437. * Base class of all the textures in babylon.
  85438. * It groups all the common properties the materials, post process, lights... might need
  85439. * in order to make a correct use of the texture.
  85440. */
  85441. export class BaseTexture implements IAnimatable {
  85442. /**
  85443. * Default anisotropic filtering level for the application.
  85444. * It is set to 4 as a good tradeoff between perf and quality.
  85445. */
  85446. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85447. /**
  85448. * Gets or sets the unique id of the texture
  85449. */
  85450. uniqueId: number;
  85451. /**
  85452. * Define the name of the texture.
  85453. */
  85454. name: string;
  85455. /**
  85456. * Gets or sets an object used to store user defined information.
  85457. */
  85458. metadata: any;
  85459. /**
  85460. * For internal use only. Please do not use.
  85461. */
  85462. reservedDataStore: any;
  85463. private _hasAlpha;
  85464. /**
  85465. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85466. */
  85467. hasAlpha: boolean;
  85468. /**
  85469. * Defines if the alpha value should be determined via the rgb values.
  85470. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85471. */
  85472. getAlphaFromRGB: boolean;
  85473. /**
  85474. * Intensity or strength of the texture.
  85475. * It is commonly used by materials to fine tune the intensity of the texture
  85476. */
  85477. level: number;
  85478. /**
  85479. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85480. * This is part of the texture as textures usually maps to one uv set.
  85481. */
  85482. coordinatesIndex: number;
  85483. private _coordinatesMode;
  85484. /**
  85485. * How a texture is mapped.
  85486. *
  85487. * | Value | Type | Description |
  85488. * | ----- | ----------------------------------- | ----------- |
  85489. * | 0 | EXPLICIT_MODE | |
  85490. * | 1 | SPHERICAL_MODE | |
  85491. * | 2 | PLANAR_MODE | |
  85492. * | 3 | CUBIC_MODE | |
  85493. * | 4 | PROJECTION_MODE | |
  85494. * | 5 | SKYBOX_MODE | |
  85495. * | 6 | INVCUBIC_MODE | |
  85496. * | 7 | EQUIRECTANGULAR_MODE | |
  85497. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85498. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85499. */
  85500. coordinatesMode: number;
  85501. /**
  85502. * | Value | Type | Description |
  85503. * | ----- | ------------------ | ----------- |
  85504. * | 0 | CLAMP_ADDRESSMODE | |
  85505. * | 1 | WRAP_ADDRESSMODE | |
  85506. * | 2 | MIRROR_ADDRESSMODE | |
  85507. */
  85508. wrapU: number;
  85509. /**
  85510. * | Value | Type | Description |
  85511. * | ----- | ------------------ | ----------- |
  85512. * | 0 | CLAMP_ADDRESSMODE | |
  85513. * | 1 | WRAP_ADDRESSMODE | |
  85514. * | 2 | MIRROR_ADDRESSMODE | |
  85515. */
  85516. wrapV: number;
  85517. /**
  85518. * | Value | Type | Description |
  85519. * | ----- | ------------------ | ----------- |
  85520. * | 0 | CLAMP_ADDRESSMODE | |
  85521. * | 1 | WRAP_ADDRESSMODE | |
  85522. * | 2 | MIRROR_ADDRESSMODE | |
  85523. */
  85524. wrapR: number;
  85525. /**
  85526. * With compliant hardware and browser (supporting anisotropic filtering)
  85527. * this defines the level of anisotropic filtering in the texture.
  85528. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85529. */
  85530. anisotropicFilteringLevel: number;
  85531. /**
  85532. * Define if the texture is a cube texture or if false a 2d texture.
  85533. */
  85534. isCube: boolean;
  85535. /**
  85536. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85537. */
  85538. is3D: boolean;
  85539. /**
  85540. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85541. * HDR texture are usually stored in linear space.
  85542. * This only impacts the PBR and Background materials
  85543. */
  85544. gammaSpace: boolean;
  85545. /**
  85546. * Gets whether or not the texture contains RGBD data.
  85547. */
  85548. readonly isRGBD: boolean;
  85549. /**
  85550. * Is Z inverted in the texture (useful in a cube texture).
  85551. */
  85552. invertZ: boolean;
  85553. /**
  85554. * Are mip maps generated for this texture or not.
  85555. */
  85556. readonly noMipmap: boolean;
  85557. /**
  85558. * @hidden
  85559. */
  85560. lodLevelInAlpha: boolean;
  85561. /**
  85562. * With prefiltered texture, defined the offset used during the prefiltering steps.
  85563. */
  85564. lodGenerationOffset: number;
  85565. /**
  85566. * With prefiltered texture, defined the scale used during the prefiltering steps.
  85567. */
  85568. lodGenerationScale: number;
  85569. /**
  85570. * Define if the texture is a render target.
  85571. */
  85572. isRenderTarget: boolean;
  85573. /**
  85574. * Define the unique id of the texture in the scene.
  85575. */
  85576. readonly uid: string;
  85577. /**
  85578. * Return a string representation of the texture.
  85579. * @returns the texture as a string
  85580. */
  85581. toString(): string;
  85582. /**
  85583. * Get the class name of the texture.
  85584. * @returns "BaseTexture"
  85585. */
  85586. getClassName(): string;
  85587. /**
  85588. * Define the list of animation attached to the texture.
  85589. */
  85590. animations: Animation[];
  85591. /**
  85592. * An event triggered when the texture is disposed.
  85593. */
  85594. onDisposeObservable: Observable<BaseTexture>;
  85595. private _onDisposeObserver;
  85596. /**
  85597. * Callback triggered when the texture has been disposed.
  85598. * Kept for back compatibility, you can use the onDisposeObservable instead.
  85599. */
  85600. onDispose: () => void;
  85601. /**
  85602. * Define the current state of the loading sequence when in delayed load mode.
  85603. */
  85604. delayLoadState: number;
  85605. private _scene;
  85606. /** @hidden */
  85607. _texture: Nullable<InternalTexture>;
  85608. private _uid;
  85609. /**
  85610. * Define if the texture is preventinga material to render or not.
  85611. * If not and the texture is not ready, the engine will use a default black texture instead.
  85612. */
  85613. readonly isBlocking: boolean;
  85614. /**
  85615. * Instantiates a new BaseTexture.
  85616. * Base class of all the textures in babylon.
  85617. * It groups all the common properties the materials, post process, lights... might need
  85618. * in order to make a correct use of the texture.
  85619. * @param scene Define the scene the texture blongs to
  85620. */
  85621. constructor(scene: Nullable<Scene>);
  85622. /**
  85623. * Get the scene the texture belongs to.
  85624. * @returns the scene or null if undefined
  85625. */
  85626. getScene(): Nullable<Scene>;
  85627. /**
  85628. * Get the texture transform matrix used to offset tile the texture for istance.
  85629. * @returns the transformation matrix
  85630. */
  85631. getTextureMatrix(): Matrix;
  85632. /**
  85633. * Get the texture reflection matrix used to rotate/transform the reflection.
  85634. * @returns the reflection matrix
  85635. */
  85636. getReflectionTextureMatrix(): Matrix;
  85637. /**
  85638. * Get the underlying lower level texture from Babylon.
  85639. * @returns the insternal texture
  85640. */
  85641. getInternalTexture(): Nullable<InternalTexture>;
  85642. /**
  85643. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  85644. * @returns true if ready or not blocking
  85645. */
  85646. isReadyOrNotBlocking(): boolean;
  85647. /**
  85648. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  85649. * @returns true if fully ready
  85650. */
  85651. isReady(): boolean;
  85652. private _cachedSize;
  85653. /**
  85654. * Get the size of the texture.
  85655. * @returns the texture size.
  85656. */
  85657. getSize(): ISize;
  85658. /**
  85659. * Get the base size of the texture.
  85660. * It can be different from the size if the texture has been resized for POT for instance
  85661. * @returns the base size
  85662. */
  85663. getBaseSize(): ISize;
  85664. /**
  85665. * Update the sampling mode of the texture.
  85666. * Default is Trilinear mode.
  85667. *
  85668. * | Value | Type | Description |
  85669. * | ----- | ------------------ | ----------- |
  85670. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  85671. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  85672. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  85673. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  85674. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  85675. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  85676. * | 7 | NEAREST_LINEAR | |
  85677. * | 8 | NEAREST_NEAREST | |
  85678. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  85679. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  85680. * | 11 | LINEAR_LINEAR | |
  85681. * | 12 | LINEAR_NEAREST | |
  85682. *
  85683. * > _mag_: magnification filter (close to the viewer)
  85684. * > _min_: minification filter (far from the viewer)
  85685. * > _mip_: filter used between mip map levels
  85686. *@param samplingMode Define the new sampling mode of the texture
  85687. */
  85688. updateSamplingMode(samplingMode: number): void;
  85689. /**
  85690. * Scales the texture if is `canRescale()`
  85691. * @param ratio the resize factor we want to use to rescale
  85692. */
  85693. scale(ratio: number): void;
  85694. /**
  85695. * Get if the texture can rescale.
  85696. */
  85697. readonly canRescale: boolean;
  85698. /** @hidden */
  85699. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  85700. /** @hidden */
  85701. _rebuild(): void;
  85702. /**
  85703. * Triggers the load sequence in delayed load mode.
  85704. */
  85705. delayLoad(): void;
  85706. /**
  85707. * Clones the texture.
  85708. * @returns the cloned texture
  85709. */
  85710. clone(): Nullable<BaseTexture>;
  85711. /**
  85712. * Get the texture underlying type (INT, FLOAT...)
  85713. */
  85714. readonly textureType: number;
  85715. /**
  85716. * Get the texture underlying format (RGB, RGBA...)
  85717. */
  85718. readonly textureFormat: number;
  85719. /**
  85720. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  85721. * This will returns an RGBA array buffer containing either in values (0-255) or
  85722. * float values (0-1) depending of the underlying buffer type.
  85723. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  85724. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  85725. * @param buffer defines a user defined buffer to fill with data (can be null)
  85726. * @returns The Array buffer containing the pixels data.
  85727. */
  85728. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  85729. /**
  85730. * Release and destroy the underlying lower level texture aka internalTexture.
  85731. */
  85732. releaseInternalTexture(): void;
  85733. /**
  85734. * Get the polynomial representation of the texture data.
  85735. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  85736. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  85737. */
  85738. sphericalPolynomial: Nullable<SphericalPolynomial>;
  85739. /** @hidden */
  85740. readonly _lodTextureHigh: Nullable<BaseTexture>;
  85741. /** @hidden */
  85742. readonly _lodTextureMid: Nullable<BaseTexture>;
  85743. /** @hidden */
  85744. readonly _lodTextureLow: Nullable<BaseTexture>;
  85745. /**
  85746. * Dispose the texture and release its associated resources.
  85747. */
  85748. dispose(): void;
  85749. /**
  85750. * Serialize the texture into a JSON representation that can be parsed later on.
  85751. * @returns the JSON representation of the texture
  85752. */
  85753. serialize(): any;
  85754. /**
  85755. * Helper function to be called back once a list of texture contains only ready textures.
  85756. * @param textures Define the list of textures to wait for
  85757. * @param callback Define the callback triggered once the entire list will be ready
  85758. */
  85759. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  85760. }
  85761. }
  85762. declare module BABYLON {
  85763. /**
  85764. * Uniform buffer objects.
  85765. *
  85766. * Handles blocks of uniform on the GPU.
  85767. *
  85768. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85769. *
  85770. * For more information, please refer to :
  85771. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85772. */
  85773. export class UniformBuffer {
  85774. private _engine;
  85775. private _buffer;
  85776. private _data;
  85777. private _bufferData;
  85778. private _dynamic?;
  85779. private _uniformLocations;
  85780. private _uniformSizes;
  85781. private _uniformLocationPointer;
  85782. private _needSync;
  85783. private _noUBO;
  85784. private _currentEffect;
  85785. private static _MAX_UNIFORM_SIZE;
  85786. private static _tempBuffer;
  85787. /**
  85788. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85789. * This is dynamic to allow compat with webgl 1 and 2.
  85790. * You will need to pass the name of the uniform as well as the value.
  85791. */
  85792. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85793. /**
  85794. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85795. * This is dynamic to allow compat with webgl 1 and 2.
  85796. * You will need to pass the name of the uniform as well as the value.
  85797. */
  85798. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85799. /**
  85800. * Lambda to Update a single float in a uniform buffer.
  85801. * This is dynamic to allow compat with webgl 1 and 2.
  85802. * You will need to pass the name of the uniform as well as the value.
  85803. */
  85804. updateFloat: (name: string, x: number) => void;
  85805. /**
  85806. * Lambda to Update a vec2 of float in a uniform buffer.
  85807. * This is dynamic to allow compat with webgl 1 and 2.
  85808. * You will need to pass the name of the uniform as well as the value.
  85809. */
  85810. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85811. /**
  85812. * Lambda to Update a vec3 of float in a uniform buffer.
  85813. * This is dynamic to allow compat with webgl 1 and 2.
  85814. * You will need to pass the name of the uniform as well as the value.
  85815. */
  85816. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85817. /**
  85818. * Lambda to Update a vec4 of float in a uniform buffer.
  85819. * This is dynamic to allow compat with webgl 1 and 2.
  85820. * You will need to pass the name of the uniform as well as the value.
  85821. */
  85822. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85823. /**
  85824. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85825. * This is dynamic to allow compat with webgl 1 and 2.
  85826. * You will need to pass the name of the uniform as well as the value.
  85827. */
  85828. updateMatrix: (name: string, mat: Matrix) => void;
  85829. /**
  85830. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85831. * This is dynamic to allow compat with webgl 1 and 2.
  85832. * You will need to pass the name of the uniform as well as the value.
  85833. */
  85834. updateVector3: (name: string, vector: Vector3) => void;
  85835. /**
  85836. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85837. * This is dynamic to allow compat with webgl 1 and 2.
  85838. * You will need to pass the name of the uniform as well as the value.
  85839. */
  85840. updateVector4: (name: string, vector: Vector4) => void;
  85841. /**
  85842. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85843. * This is dynamic to allow compat with webgl 1 and 2.
  85844. * You will need to pass the name of the uniform as well as the value.
  85845. */
  85846. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85847. /**
  85848. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85849. * This is dynamic to allow compat with webgl 1 and 2.
  85850. * You will need to pass the name of the uniform as well as the value.
  85851. */
  85852. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85853. /**
  85854. * Instantiates a new Uniform buffer objects.
  85855. *
  85856. * Handles blocks of uniform on the GPU.
  85857. *
  85858. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85859. *
  85860. * For more information, please refer to :
  85861. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85862. * @param engine Define the engine the buffer is associated with
  85863. * @param data Define the data contained in the buffer
  85864. * @param dynamic Define if the buffer is updatable
  85865. */
  85866. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85867. /**
  85868. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85869. * or just falling back on setUniformXXX calls.
  85870. */
  85871. readonly useUbo: boolean;
  85872. /**
  85873. * Indicates if the WebGL underlying uniform buffer is in sync
  85874. * with the javascript cache data.
  85875. */
  85876. readonly isSync: boolean;
  85877. /**
  85878. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85879. * Also, a dynamic UniformBuffer will disable cache verification and always
  85880. * update the underlying WebGL uniform buffer to the GPU.
  85881. * @returns if Dynamic, otherwise false
  85882. */
  85883. isDynamic(): boolean;
  85884. /**
  85885. * The data cache on JS side.
  85886. * @returns the underlying data as a float array
  85887. */
  85888. getData(): Float32Array;
  85889. /**
  85890. * The underlying WebGL Uniform buffer.
  85891. * @returns the webgl buffer
  85892. */
  85893. getBuffer(): Nullable<WebGLBuffer>;
  85894. /**
  85895. * std140 layout specifies how to align data within an UBO structure.
  85896. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85897. * for specs.
  85898. */
  85899. private _fillAlignment;
  85900. /**
  85901. * Adds an uniform in the buffer.
  85902. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85903. * for the layout to be correct !
  85904. * @param name Name of the uniform, as used in the uniform block in the shader.
  85905. * @param size Data size, or data directly.
  85906. */
  85907. addUniform(name: string, size: number | number[]): void;
  85908. /**
  85909. * Adds a Matrix 4x4 to the uniform buffer.
  85910. * @param name Name of the uniform, as used in the uniform block in the shader.
  85911. * @param mat A 4x4 matrix.
  85912. */
  85913. addMatrix(name: string, mat: Matrix): void;
  85914. /**
  85915. * Adds a vec2 to the uniform buffer.
  85916. * @param name Name of the uniform, as used in the uniform block in the shader.
  85917. * @param x Define the x component value of the vec2
  85918. * @param y Define the y component value of the vec2
  85919. */
  85920. addFloat2(name: string, x: number, y: number): void;
  85921. /**
  85922. * Adds a vec3 to the uniform buffer.
  85923. * @param name Name of the uniform, as used in the uniform block in the shader.
  85924. * @param x Define the x component value of the vec3
  85925. * @param y Define the y component value of the vec3
  85926. * @param z Define the z component value of the vec3
  85927. */
  85928. addFloat3(name: string, x: number, y: number, z: number): void;
  85929. /**
  85930. * Adds a vec3 to the uniform buffer.
  85931. * @param name Name of the uniform, as used in the uniform block in the shader.
  85932. * @param color Define the vec3 from a Color
  85933. */
  85934. addColor3(name: string, color: Color3): void;
  85935. /**
  85936. * Adds a vec4 to the uniform buffer.
  85937. * @param name Name of the uniform, as used in the uniform block in the shader.
  85938. * @param color Define the rgb components from a Color
  85939. * @param alpha Define the a component of the vec4
  85940. */
  85941. addColor4(name: string, color: Color3, alpha: number): void;
  85942. /**
  85943. * Adds a vec3 to the uniform buffer.
  85944. * @param name Name of the uniform, as used in the uniform block in the shader.
  85945. * @param vector Define the vec3 components from a Vector
  85946. */
  85947. addVector3(name: string, vector: Vector3): void;
  85948. /**
  85949. * Adds a Matrix 3x3 to the uniform buffer.
  85950. * @param name Name of the uniform, as used in the uniform block in the shader.
  85951. */
  85952. addMatrix3x3(name: string): void;
  85953. /**
  85954. * Adds a Matrix 2x2 to the uniform buffer.
  85955. * @param name Name of the uniform, as used in the uniform block in the shader.
  85956. */
  85957. addMatrix2x2(name: string): void;
  85958. /**
  85959. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85960. */
  85961. create(): void;
  85962. /** @hidden */
  85963. _rebuild(): void;
  85964. /**
  85965. * Updates the WebGL Uniform Buffer on the GPU.
  85966. * If the `dynamic` flag is set to true, no cache comparison is done.
  85967. * Otherwise, the buffer will be updated only if the cache differs.
  85968. */
  85969. update(): void;
  85970. /**
  85971. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85972. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85973. * @param data Define the flattened data
  85974. * @param size Define the size of the data.
  85975. */
  85976. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85977. private _updateMatrix3x3ForUniform;
  85978. private _updateMatrix3x3ForEffect;
  85979. private _updateMatrix2x2ForEffect;
  85980. private _updateMatrix2x2ForUniform;
  85981. private _updateFloatForEffect;
  85982. private _updateFloatForUniform;
  85983. private _updateFloat2ForEffect;
  85984. private _updateFloat2ForUniform;
  85985. private _updateFloat3ForEffect;
  85986. private _updateFloat3ForUniform;
  85987. private _updateFloat4ForEffect;
  85988. private _updateFloat4ForUniform;
  85989. private _updateMatrixForEffect;
  85990. private _updateMatrixForUniform;
  85991. private _updateVector3ForEffect;
  85992. private _updateVector3ForUniform;
  85993. private _updateVector4ForEffect;
  85994. private _updateVector4ForUniform;
  85995. private _updateColor3ForEffect;
  85996. private _updateColor3ForUniform;
  85997. private _updateColor4ForEffect;
  85998. private _updateColor4ForUniform;
  85999. /**
  86000. * Sets a sampler uniform on the effect.
  86001. * @param name Define the name of the sampler.
  86002. * @param texture Define the texture to set in the sampler
  86003. */
  86004. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86005. /**
  86006. * Directly updates the value of the uniform in the cache AND on the GPU.
  86007. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86008. * @param data Define the flattened data
  86009. */
  86010. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86011. /**
  86012. * Binds this uniform buffer to an effect.
  86013. * @param effect Define the effect to bind the buffer to
  86014. * @param name Name of the uniform block in the shader.
  86015. */
  86016. bindToEffect(effect: Effect, name: string): void;
  86017. /**
  86018. * Disposes the uniform buffer.
  86019. */
  86020. dispose(): void;
  86021. }
  86022. }
  86023. declare module BABYLON {
  86024. /**
  86025. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86027. */
  86028. export class Analyser {
  86029. /**
  86030. * Gets or sets the smoothing
  86031. * @ignorenaming
  86032. */
  86033. SMOOTHING: number;
  86034. /**
  86035. * Gets or sets the FFT table size
  86036. * @ignorenaming
  86037. */
  86038. FFT_SIZE: number;
  86039. /**
  86040. * Gets or sets the bar graph amplitude
  86041. * @ignorenaming
  86042. */
  86043. BARGRAPHAMPLITUDE: number;
  86044. /**
  86045. * Gets or sets the position of the debug canvas
  86046. * @ignorenaming
  86047. */
  86048. DEBUGCANVASPOS: {
  86049. x: number;
  86050. y: number;
  86051. };
  86052. /**
  86053. * Gets or sets the debug canvas size
  86054. * @ignorenaming
  86055. */
  86056. DEBUGCANVASSIZE: {
  86057. width: number;
  86058. height: number;
  86059. };
  86060. private _byteFreqs;
  86061. private _byteTime;
  86062. private _floatFreqs;
  86063. private _webAudioAnalyser;
  86064. private _debugCanvas;
  86065. private _debugCanvasContext;
  86066. private _scene;
  86067. private _registerFunc;
  86068. private _audioEngine;
  86069. /**
  86070. * Creates a new analyser
  86071. * @param scene defines hosting scene
  86072. */
  86073. constructor(scene: Scene);
  86074. /**
  86075. * Get the number of data values you will have to play with for the visualization
  86076. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86077. * @returns a number
  86078. */
  86079. getFrequencyBinCount(): number;
  86080. /**
  86081. * Gets the current frequency data as a byte array
  86082. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86083. * @returns a Uint8Array
  86084. */
  86085. getByteFrequencyData(): Uint8Array;
  86086. /**
  86087. * Gets the current waveform as a byte array
  86088. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86089. * @returns a Uint8Array
  86090. */
  86091. getByteTimeDomainData(): Uint8Array;
  86092. /**
  86093. * Gets the current frequency data as a float array
  86094. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86095. * @returns a Float32Array
  86096. */
  86097. getFloatFrequencyData(): Float32Array;
  86098. /**
  86099. * Renders the debug canvas
  86100. */
  86101. drawDebugCanvas(): void;
  86102. /**
  86103. * Stops rendering the debug canvas and removes it
  86104. */
  86105. stopDebugCanvas(): void;
  86106. /**
  86107. * Connects two audio nodes
  86108. * @param inputAudioNode defines first node to connect
  86109. * @param outputAudioNode defines second node to connect
  86110. */
  86111. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86112. /**
  86113. * Releases all associated resources
  86114. */
  86115. dispose(): void;
  86116. }
  86117. }
  86118. declare module BABYLON {
  86119. /**
  86120. * This represents an audio engine and it is responsible
  86121. * to play, synchronize and analyse sounds throughout the application.
  86122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86123. */
  86124. export interface IAudioEngine extends IDisposable {
  86125. /**
  86126. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86127. */
  86128. readonly canUseWebAudio: boolean;
  86129. /**
  86130. * Gets the current AudioContext if available.
  86131. */
  86132. readonly audioContext: Nullable<AudioContext>;
  86133. /**
  86134. * The master gain node defines the global audio volume of your audio engine.
  86135. */
  86136. readonly masterGain: GainNode;
  86137. /**
  86138. * Gets whether or not mp3 are supported by your browser.
  86139. */
  86140. readonly isMP3supported: boolean;
  86141. /**
  86142. * Gets whether or not ogg are supported by your browser.
  86143. */
  86144. readonly isOGGsupported: boolean;
  86145. /**
  86146. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86147. * @ignoreNaming
  86148. */
  86149. WarnedWebAudioUnsupported: boolean;
  86150. /**
  86151. * Defines if the audio engine relies on a custom unlocked button.
  86152. * In this case, the embedded button will not be displayed.
  86153. */
  86154. useCustomUnlockedButton: boolean;
  86155. /**
  86156. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86157. */
  86158. readonly unlocked: boolean;
  86159. /**
  86160. * Event raised when audio has been unlocked on the browser.
  86161. */
  86162. onAudioUnlockedObservable: Observable<AudioEngine>;
  86163. /**
  86164. * Event raised when audio has been locked on the browser.
  86165. */
  86166. onAudioLockedObservable: Observable<AudioEngine>;
  86167. /**
  86168. * Flags the audio engine in Locked state.
  86169. * This happens due to new browser policies preventing audio to autoplay.
  86170. */
  86171. lock(): void;
  86172. /**
  86173. * Unlocks the audio engine once a user action has been done on the dom.
  86174. * This is helpful to resume play once browser policies have been satisfied.
  86175. */
  86176. unlock(): void;
  86177. }
  86178. /**
  86179. * This represents the default audio engine used in babylon.
  86180. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86182. */
  86183. export class AudioEngine implements IAudioEngine {
  86184. private _audioContext;
  86185. private _audioContextInitialized;
  86186. private _muteButton;
  86187. private _hostElement;
  86188. /**
  86189. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86190. */
  86191. canUseWebAudio: boolean;
  86192. /**
  86193. * The master gain node defines the global audio volume of your audio engine.
  86194. */
  86195. masterGain: GainNode;
  86196. /**
  86197. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86198. * @ignoreNaming
  86199. */
  86200. WarnedWebAudioUnsupported: boolean;
  86201. /**
  86202. * Gets whether or not mp3 are supported by your browser.
  86203. */
  86204. isMP3supported: boolean;
  86205. /**
  86206. * Gets whether or not ogg are supported by your browser.
  86207. */
  86208. isOGGsupported: boolean;
  86209. /**
  86210. * Gets whether audio has been unlocked on the device.
  86211. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86212. * a user interaction has happened.
  86213. */
  86214. unlocked: boolean;
  86215. /**
  86216. * Defines if the audio engine relies on a custom unlocked button.
  86217. * In this case, the embedded button will not be displayed.
  86218. */
  86219. useCustomUnlockedButton: boolean;
  86220. /**
  86221. * Event raised when audio has been unlocked on the browser.
  86222. */
  86223. onAudioUnlockedObservable: Observable<AudioEngine>;
  86224. /**
  86225. * Event raised when audio has been locked on the browser.
  86226. */
  86227. onAudioLockedObservable: Observable<AudioEngine>;
  86228. /**
  86229. * Gets the current AudioContext if available.
  86230. */
  86231. readonly audioContext: Nullable<AudioContext>;
  86232. private _connectedAnalyser;
  86233. /**
  86234. * Instantiates a new audio engine.
  86235. *
  86236. * There should be only one per page as some browsers restrict the number
  86237. * of audio contexts you can create.
  86238. * @param hostElement defines the host element where to display the mute icon if necessary
  86239. */
  86240. constructor(hostElement?: Nullable<HTMLElement>);
  86241. /**
  86242. * Flags the audio engine in Locked state.
  86243. * This happens due to new browser policies preventing audio to autoplay.
  86244. */
  86245. lock(): void;
  86246. /**
  86247. * Unlocks the audio engine once a user action has been done on the dom.
  86248. * This is helpful to resume play once browser policies have been satisfied.
  86249. */
  86250. unlock(): void;
  86251. private _resumeAudioContext;
  86252. private _initializeAudioContext;
  86253. private _tryToRun;
  86254. private _triggerRunningState;
  86255. private _triggerSuspendedState;
  86256. private _displayMuteButton;
  86257. private _moveButtonToTopLeft;
  86258. private _onResize;
  86259. private _hideMuteButton;
  86260. /**
  86261. * Destroy and release the resources associated with the audio ccontext.
  86262. */
  86263. dispose(): void;
  86264. /**
  86265. * Gets the global volume sets on the master gain.
  86266. * @returns the global volume if set or -1 otherwise
  86267. */
  86268. getGlobalVolume(): number;
  86269. /**
  86270. * Sets the global volume of your experience (sets on the master gain).
  86271. * @param newVolume Defines the new global volume of the application
  86272. */
  86273. setGlobalVolume(newVolume: number): void;
  86274. /**
  86275. * Connect the audio engine to an audio analyser allowing some amazing
  86276. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86278. * @param analyser The analyser to connect to the engine
  86279. */
  86280. connectToAnalyser(analyser: Analyser): void;
  86281. }
  86282. }
  86283. declare module BABYLON {
  86284. /**
  86285. * Interface used to present a loading screen while loading a scene
  86286. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86287. */
  86288. export interface ILoadingScreen {
  86289. /**
  86290. * Function called to display the loading screen
  86291. */
  86292. displayLoadingUI: () => void;
  86293. /**
  86294. * Function called to hide the loading screen
  86295. */
  86296. hideLoadingUI: () => void;
  86297. /**
  86298. * Gets or sets the color to use for the background
  86299. */
  86300. loadingUIBackgroundColor: string;
  86301. /**
  86302. * Gets or sets the text to display while loading
  86303. */
  86304. loadingUIText: string;
  86305. }
  86306. /**
  86307. * Class used for the default loading screen
  86308. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86309. */
  86310. export class DefaultLoadingScreen implements ILoadingScreen {
  86311. private _renderingCanvas;
  86312. private _loadingText;
  86313. private _loadingDivBackgroundColor;
  86314. private _loadingDiv;
  86315. private _loadingTextDiv;
  86316. /**
  86317. * Creates a new default loading screen
  86318. * @param _renderingCanvas defines the canvas used to render the scene
  86319. * @param _loadingText defines the default text to display
  86320. * @param _loadingDivBackgroundColor defines the default background color
  86321. */
  86322. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86323. /**
  86324. * Function called to display the loading screen
  86325. */
  86326. displayLoadingUI(): void;
  86327. /**
  86328. * Function called to hide the loading screen
  86329. */
  86330. hideLoadingUI(): void;
  86331. /**
  86332. * Gets or sets the text to display while loading
  86333. */
  86334. loadingUIText: string;
  86335. /**
  86336. * Gets or sets the color to use for the background
  86337. */
  86338. loadingUIBackgroundColor: string;
  86339. private _resizeLoadingUI;
  86340. }
  86341. }
  86342. declare module BABYLON {
  86343. /**
  86344. * Settings for finer control over video usage
  86345. */
  86346. export interface VideoTextureSettings {
  86347. /**
  86348. * Applies `autoplay` to video, if specified
  86349. */
  86350. autoPlay?: boolean;
  86351. /**
  86352. * Applies `loop` to video, if specified
  86353. */
  86354. loop?: boolean;
  86355. /**
  86356. * Automatically updates internal texture from video at every frame in the render loop
  86357. */
  86358. autoUpdateTexture: boolean;
  86359. /**
  86360. * Image src displayed during the video loading or until the user interacts with the video.
  86361. */
  86362. poster?: string;
  86363. }
  86364. /**
  86365. * If you want to display a video in your scene, this is the special texture for that.
  86366. * This special texture works similar to other textures, with the exception of a few parameters.
  86367. * @see https://doc.babylonjs.com/how_to/video_texture
  86368. */
  86369. export class VideoTexture extends Texture {
  86370. /**
  86371. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86372. */
  86373. readonly autoUpdateTexture: boolean;
  86374. /**
  86375. * The video instance used by the texture internally
  86376. */
  86377. readonly video: HTMLVideoElement;
  86378. private _onUserActionRequestedObservable;
  86379. /**
  86380. * Event triggerd when a dom action is required by the user to play the video.
  86381. * This happens due to recent changes in browser policies preventing video to auto start.
  86382. */
  86383. readonly onUserActionRequestedObservable: Observable<Texture>;
  86384. private _generateMipMaps;
  86385. private _engine;
  86386. private _stillImageCaptured;
  86387. private _displayingPosterTexture;
  86388. private _settings;
  86389. private _createInternalTextureOnEvent;
  86390. /**
  86391. * Creates a video texture.
  86392. * If you want to display a video in your scene, this is the special texture for that.
  86393. * This special texture works similar to other textures, with the exception of a few parameters.
  86394. * @see https://doc.babylonjs.com/how_to/video_texture
  86395. * @param name optional name, will detect from video source, if not defined
  86396. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86397. * @param scene is obviously the current scene.
  86398. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86399. * @param invertY is false by default but can be used to invert video on Y axis
  86400. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86401. * @param settings allows finer control over video usage
  86402. */
  86403. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86404. private _getName;
  86405. private _getVideo;
  86406. private _createInternalTexture;
  86407. private reset;
  86408. /**
  86409. * @hidden Internal method to initiate `update`.
  86410. */
  86411. _rebuild(): void;
  86412. /**
  86413. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86414. */
  86415. update(): void;
  86416. /**
  86417. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86418. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86419. */
  86420. updateTexture(isVisible: boolean): void;
  86421. protected _updateInternalTexture: () => void;
  86422. /**
  86423. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86424. * @param url New url.
  86425. */
  86426. updateURL(url: string): void;
  86427. /**
  86428. * Dispose the texture and release its associated resources.
  86429. */
  86430. dispose(): void;
  86431. /**
  86432. * Creates a video texture straight from a stream.
  86433. * @param scene Define the scene the texture should be created in
  86434. * @param stream Define the stream the texture should be created from
  86435. * @returns The created video texture as a promise
  86436. */
  86437. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86438. /**
  86439. * Creates a video texture straight from your WebCam video feed.
  86440. * @param scene Define the scene the texture should be created in
  86441. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86442. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86443. * @returns The created video texture as a promise
  86444. */
  86445. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86446. minWidth: number;
  86447. maxWidth: number;
  86448. minHeight: number;
  86449. maxHeight: number;
  86450. deviceId: string;
  86451. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86452. /**
  86453. * Creates a video texture straight from your WebCam video feed.
  86454. * @param scene Define the scene the texture should be created in
  86455. * @param onReady Define a callback to triggered once the texture will be ready
  86456. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86457. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86458. */
  86459. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86460. minWidth: number;
  86461. maxWidth: number;
  86462. minHeight: number;
  86463. maxHeight: number;
  86464. deviceId: string;
  86465. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86466. }
  86467. }
  86468. declare module BABYLON {
  86469. /**
  86470. * Interface for attribute information associated with buffer instanciation
  86471. */
  86472. export class InstancingAttributeInfo {
  86473. /**
  86474. * Index/offset of the attribute in the vertex shader
  86475. */
  86476. index: number;
  86477. /**
  86478. * size of the attribute, 1, 2, 3 or 4
  86479. */
  86480. attributeSize: number;
  86481. /**
  86482. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86483. * default is FLOAT
  86484. */
  86485. attribyteType: number;
  86486. /**
  86487. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86488. */
  86489. normalized: boolean;
  86490. /**
  86491. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86492. */
  86493. offset: number;
  86494. /**
  86495. * Name of the GLSL attribute, for debugging purpose only
  86496. */
  86497. attributeName: string;
  86498. }
  86499. /**
  86500. * Define options used to create a depth texture
  86501. */
  86502. export class DepthTextureCreationOptions {
  86503. /** Specifies whether or not a stencil should be allocated in the texture */
  86504. generateStencil?: boolean;
  86505. /** Specifies whether or not bilinear filtering is enable on the texture */
  86506. bilinearFiltering?: boolean;
  86507. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86508. comparisonFunction?: number;
  86509. /** Specifies if the created texture is a cube texture */
  86510. isCube?: boolean;
  86511. }
  86512. /**
  86513. * Class used to describe the capabilities of the engine relatively to the current browser
  86514. */
  86515. export class EngineCapabilities {
  86516. /** Maximum textures units per fragment shader */
  86517. maxTexturesImageUnits: number;
  86518. /** Maximum texture units per vertex shader */
  86519. maxVertexTextureImageUnits: number;
  86520. /** Maximum textures units in the entire pipeline */
  86521. maxCombinedTexturesImageUnits: number;
  86522. /** Maximum texture size */
  86523. maxTextureSize: number;
  86524. /** Maximum cube texture size */
  86525. maxCubemapTextureSize: number;
  86526. /** Maximum render texture size */
  86527. maxRenderTextureSize: number;
  86528. /** Maximum number of vertex attributes */
  86529. maxVertexAttribs: number;
  86530. /** Maximum number of varyings */
  86531. maxVaryingVectors: number;
  86532. /** Maximum number of uniforms per vertex shader */
  86533. maxVertexUniformVectors: number;
  86534. /** Maximum number of uniforms per fragment shader */
  86535. maxFragmentUniformVectors: number;
  86536. /** Defines if standard derivates (dx/dy) are supported */
  86537. standardDerivatives: boolean;
  86538. /** Defines if s3tc texture compression is supported */
  86539. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86540. /** Defines if pvrtc texture compression is supported */
  86541. pvrtc: any;
  86542. /** Defines if etc1 texture compression is supported */
  86543. etc1: any;
  86544. /** Defines if etc2 texture compression is supported */
  86545. etc2: any;
  86546. /** Defines if astc texture compression is supported */
  86547. astc: any;
  86548. /** Defines if float textures are supported */
  86549. textureFloat: boolean;
  86550. /** Defines if vertex array objects are supported */
  86551. vertexArrayObject: boolean;
  86552. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  86553. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  86554. /** Gets the maximum level of anisotropy supported */
  86555. maxAnisotropy: number;
  86556. /** Defines if instancing is supported */
  86557. instancedArrays: boolean;
  86558. /** Defines if 32 bits indices are supported */
  86559. uintIndices: boolean;
  86560. /** Defines if high precision shaders are supported */
  86561. highPrecisionShaderSupported: boolean;
  86562. /** Defines if depth reading in the fragment shader is supported */
  86563. fragmentDepthSupported: boolean;
  86564. /** Defines if float texture linear filtering is supported*/
  86565. textureFloatLinearFiltering: boolean;
  86566. /** Defines if rendering to float textures is supported */
  86567. textureFloatRender: boolean;
  86568. /** Defines if half float textures are supported*/
  86569. textureHalfFloat: boolean;
  86570. /** Defines if half float texture linear filtering is supported*/
  86571. textureHalfFloatLinearFiltering: boolean;
  86572. /** Defines if rendering to half float textures is supported */
  86573. textureHalfFloatRender: boolean;
  86574. /** Defines if textureLOD shader command is supported */
  86575. textureLOD: boolean;
  86576. /** Defines if draw buffers extension is supported */
  86577. drawBuffersExtension: boolean;
  86578. /** Defines if depth textures are supported */
  86579. depthTextureExtension: boolean;
  86580. /** Defines if float color buffer are supported */
  86581. colorBufferFloat: boolean;
  86582. /** Gets disjoint timer query extension (null if not supported) */
  86583. timerQuery: EXT_disjoint_timer_query;
  86584. /** Defines if timestamp can be used with timer query */
  86585. canUseTimestampForTimerQuery: boolean;
  86586. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  86587. multiview: any;
  86588. /** Function used to let the system compiles shaders in background */
  86589. parallelShaderCompile: {
  86590. COMPLETION_STATUS_KHR: number;
  86591. };
  86592. }
  86593. /** Interface defining initialization parameters for Engine class */
  86594. export interface EngineOptions extends WebGLContextAttributes {
  86595. /**
  86596. * Defines if the engine should no exceed a specified device ratio
  86597. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  86598. */
  86599. limitDeviceRatio?: number;
  86600. /**
  86601. * Defines if webvr should be enabled automatically
  86602. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86603. */
  86604. autoEnableWebVR?: boolean;
  86605. /**
  86606. * Defines if webgl2 should be turned off even if supported
  86607. * @see http://doc.babylonjs.com/features/webgl2
  86608. */
  86609. disableWebGL2Support?: boolean;
  86610. /**
  86611. * Defines if webaudio should be initialized as well
  86612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86613. */
  86614. audioEngine?: boolean;
  86615. /**
  86616. * Defines if animations should run using a deterministic lock step
  86617. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86618. */
  86619. deterministicLockstep?: boolean;
  86620. /** Defines the maximum steps to use with deterministic lock step mode */
  86621. lockstepMaxSteps?: number;
  86622. /**
  86623. * Defines that engine should ignore context lost events
  86624. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  86625. */
  86626. doNotHandleContextLost?: boolean;
  86627. /**
  86628. * Defines that engine should ignore modifying touch action attribute and style
  86629. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  86630. */
  86631. doNotHandleTouchAction?: boolean;
  86632. /**
  86633. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  86634. */
  86635. useHighPrecisionFloats?: boolean;
  86636. }
  86637. /**
  86638. * Defines the interface used by display changed events
  86639. */
  86640. export interface IDisplayChangedEventArgs {
  86641. /** Gets the vrDisplay object (if any) */
  86642. vrDisplay: Nullable<any>;
  86643. /** Gets a boolean indicating if webVR is supported */
  86644. vrSupported: boolean;
  86645. }
  86646. /**
  86647. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  86648. */
  86649. export class Engine {
  86650. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  86651. static ExceptionList: ({
  86652. key: string;
  86653. capture: string;
  86654. captureConstraint: number;
  86655. targets: string[];
  86656. } | {
  86657. key: string;
  86658. capture: null;
  86659. captureConstraint: null;
  86660. targets: string[];
  86661. })[];
  86662. /** Gets the list of created engines */
  86663. static readonly Instances: Engine[];
  86664. /**
  86665. * Gets the latest created engine
  86666. */
  86667. static readonly LastCreatedEngine: Nullable<Engine>;
  86668. /**
  86669. * Gets the latest created scene
  86670. */
  86671. static readonly LastCreatedScene: Nullable<Scene>;
  86672. /**
  86673. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  86674. * @param flag defines which part of the materials must be marked as dirty
  86675. * @param predicate defines a predicate used to filter which materials should be affected
  86676. */
  86677. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  86678. /**
  86679. * Hidden
  86680. */
  86681. static _TextureLoaders: IInternalTextureLoader[];
  86682. /** Defines that alpha blending is disabled */
  86683. static readonly ALPHA_DISABLE: number;
  86684. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  86685. static readonly ALPHA_ADD: number;
  86686. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86687. static readonly ALPHA_COMBINE: number;
  86688. /** Defines that alpha blending to DEST - SRC * DEST */
  86689. static readonly ALPHA_SUBTRACT: number;
  86690. /** Defines that alpha blending to SRC * DEST */
  86691. static readonly ALPHA_MULTIPLY: number;
  86692. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  86693. static readonly ALPHA_MAXIMIZED: number;
  86694. /** Defines that alpha blending to SRC + DEST */
  86695. static readonly ALPHA_ONEONE: number;
  86696. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  86697. static readonly ALPHA_PREMULTIPLIED: number;
  86698. /**
  86699. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86700. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86701. */
  86702. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86703. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86704. static readonly ALPHA_INTERPOLATE: number;
  86705. /**
  86706. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86707. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86708. */
  86709. static readonly ALPHA_SCREENMODE: number;
  86710. /** Defines that the ressource is not delayed*/
  86711. static readonly DELAYLOADSTATE_NONE: number;
  86712. /** Defines that the ressource was successfully delay loaded */
  86713. static readonly DELAYLOADSTATE_LOADED: number;
  86714. /** Defines that the ressource is currently delay loading */
  86715. static readonly DELAYLOADSTATE_LOADING: number;
  86716. /** Defines that the ressource is delayed and has not started loading */
  86717. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86718. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86719. static readonly NEVER: number;
  86720. /** 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 */
  86721. static readonly ALWAYS: number;
  86722. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86723. static readonly LESS: number;
  86724. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86725. static readonly EQUAL: number;
  86726. /** 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 */
  86727. static readonly LEQUAL: number;
  86728. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86729. static readonly GREATER: number;
  86730. /** 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 */
  86731. static readonly GEQUAL: number;
  86732. /** 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 */
  86733. static readonly NOTEQUAL: number;
  86734. /** Passed to stencilOperation to specify that stencil value must be kept */
  86735. static readonly KEEP: number;
  86736. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86737. static readonly REPLACE: number;
  86738. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86739. static readonly INCR: number;
  86740. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86741. static readonly DECR: number;
  86742. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86743. static readonly INVERT: number;
  86744. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86745. static readonly INCR_WRAP: number;
  86746. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86747. static readonly DECR_WRAP: number;
  86748. /** Texture is not repeating outside of 0..1 UVs */
  86749. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86750. /** Texture is repeating outside of 0..1 UVs */
  86751. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86752. /** Texture is repeating and mirrored */
  86753. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86754. /** ALPHA */
  86755. static readonly TEXTUREFORMAT_ALPHA: number;
  86756. /** LUMINANCE */
  86757. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86758. /** LUMINANCE_ALPHA */
  86759. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86760. /** RGB */
  86761. static readonly TEXTUREFORMAT_RGB: number;
  86762. /** RGBA */
  86763. static readonly TEXTUREFORMAT_RGBA: number;
  86764. /** RED */
  86765. static readonly TEXTUREFORMAT_RED: number;
  86766. /** RED (2nd reference) */
  86767. static readonly TEXTUREFORMAT_R: number;
  86768. /** RG */
  86769. static readonly TEXTUREFORMAT_RG: number;
  86770. /** RED_INTEGER */
  86771. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86772. /** RED_INTEGER (2nd reference) */
  86773. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86774. /** RG_INTEGER */
  86775. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86776. /** RGB_INTEGER */
  86777. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86778. /** RGBA_INTEGER */
  86779. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86780. /** UNSIGNED_BYTE */
  86781. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86782. /** UNSIGNED_BYTE (2nd reference) */
  86783. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86784. /** FLOAT */
  86785. static readonly TEXTURETYPE_FLOAT: number;
  86786. /** HALF_FLOAT */
  86787. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86788. /** BYTE */
  86789. static readonly TEXTURETYPE_BYTE: number;
  86790. /** SHORT */
  86791. static readonly TEXTURETYPE_SHORT: number;
  86792. /** UNSIGNED_SHORT */
  86793. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86794. /** INT */
  86795. static readonly TEXTURETYPE_INT: number;
  86796. /** UNSIGNED_INT */
  86797. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86798. /** UNSIGNED_SHORT_4_4_4_4 */
  86799. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86800. /** UNSIGNED_SHORT_5_5_5_1 */
  86801. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86802. /** UNSIGNED_SHORT_5_6_5 */
  86803. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86804. /** UNSIGNED_INT_2_10_10_10_REV */
  86805. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86806. /** UNSIGNED_INT_24_8 */
  86807. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86808. /** UNSIGNED_INT_10F_11F_11F_REV */
  86809. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86810. /** UNSIGNED_INT_5_9_9_9_REV */
  86811. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86812. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86813. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86814. /** nearest is mag = nearest and min = nearest and mip = linear */
  86815. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86816. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86817. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86818. /** Trilinear is mag = linear and min = linear and mip = linear */
  86819. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86820. /** nearest is mag = nearest and min = nearest and mip = linear */
  86821. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86822. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86823. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86824. /** Trilinear is mag = linear and min = linear and mip = linear */
  86825. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86826. /** mag = nearest and min = nearest and mip = nearest */
  86827. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86828. /** mag = nearest and min = linear and mip = nearest */
  86829. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86830. /** mag = nearest and min = linear and mip = linear */
  86831. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86832. /** mag = nearest and min = linear and mip = none */
  86833. static readonly TEXTURE_NEAREST_LINEAR: number;
  86834. /** mag = nearest and min = nearest and mip = none */
  86835. static readonly TEXTURE_NEAREST_NEAREST: number;
  86836. /** mag = linear and min = nearest and mip = nearest */
  86837. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86838. /** mag = linear and min = nearest and mip = linear */
  86839. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86840. /** mag = linear and min = linear and mip = none */
  86841. static readonly TEXTURE_LINEAR_LINEAR: number;
  86842. /** mag = linear and min = nearest and mip = none */
  86843. static readonly TEXTURE_LINEAR_NEAREST: number;
  86844. /** Explicit coordinates mode */
  86845. static readonly TEXTURE_EXPLICIT_MODE: number;
  86846. /** Spherical coordinates mode */
  86847. static readonly TEXTURE_SPHERICAL_MODE: number;
  86848. /** Planar coordinates mode */
  86849. static readonly TEXTURE_PLANAR_MODE: number;
  86850. /** Cubic coordinates mode */
  86851. static readonly TEXTURE_CUBIC_MODE: number;
  86852. /** Projection coordinates mode */
  86853. static readonly TEXTURE_PROJECTION_MODE: number;
  86854. /** Skybox coordinates mode */
  86855. static readonly TEXTURE_SKYBOX_MODE: number;
  86856. /** Inverse Cubic coordinates mode */
  86857. static readonly TEXTURE_INVCUBIC_MODE: number;
  86858. /** Equirectangular coordinates mode */
  86859. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86860. /** Equirectangular Fixed coordinates mode */
  86861. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86862. /** Equirectangular Fixed Mirrored coordinates mode */
  86863. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86864. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86865. static readonly SCALEMODE_FLOOR: number;
  86866. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86867. static readonly SCALEMODE_NEAREST: number;
  86868. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86869. static readonly SCALEMODE_CEILING: number;
  86870. /**
  86871. * Returns the current npm package of the sdk
  86872. */
  86873. static readonly NpmPackage: string;
  86874. /**
  86875. * Returns the current version of the framework
  86876. */
  86877. static readonly Version: string;
  86878. /**
  86879. * Returns a string describing the current engine
  86880. */
  86881. readonly description: string;
  86882. /**
  86883. * Gets or sets the epsilon value used by collision engine
  86884. */
  86885. static CollisionsEpsilon: number;
  86886. /**
  86887. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86888. */
  86889. static ShadersRepository: string;
  86890. /**
  86891. * Method called to create the default loading screen.
  86892. * This can be overriden in your own app.
  86893. * @param canvas The rendering canvas element
  86894. * @returns The loading screen
  86895. */
  86896. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  86897. /**
  86898. * Method called to create the default rescale post process on each engine.
  86899. */
  86900. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  86901. /**
  86902. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  86903. */
  86904. forcePOTTextures: boolean;
  86905. /**
  86906. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  86907. */
  86908. isFullscreen: boolean;
  86909. /**
  86910. * Gets a boolean indicating if the pointer is currently locked
  86911. */
  86912. isPointerLock: boolean;
  86913. /**
  86914. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  86915. */
  86916. cullBackFaces: boolean;
  86917. /**
  86918. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  86919. */
  86920. renderEvenInBackground: boolean;
  86921. /**
  86922. * Gets or sets a boolean indicating that cache can be kept between frames
  86923. */
  86924. preventCacheWipeBetweenFrames: boolean;
  86925. /**
  86926. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  86927. **/
  86928. enableOfflineSupport: boolean;
  86929. /**
  86930. * 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)
  86931. **/
  86932. disableManifestCheck: boolean;
  86933. /**
  86934. * Gets the list of created scenes
  86935. */
  86936. scenes: Scene[];
  86937. /**
  86938. * Event raised when a new scene is created
  86939. */
  86940. onNewSceneAddedObservable: Observable<Scene>;
  86941. /**
  86942. * Gets the list of created postprocesses
  86943. */
  86944. postProcesses: PostProcess[];
  86945. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  86946. validateShaderPrograms: boolean;
  86947. /**
  86948. * Observable event triggered each time the rendering canvas is resized
  86949. */
  86950. onResizeObservable: Observable<Engine>;
  86951. /**
  86952. * Observable event triggered each time the canvas loses focus
  86953. */
  86954. onCanvasBlurObservable: Observable<Engine>;
  86955. /**
  86956. * Observable event triggered each time the canvas gains focus
  86957. */
  86958. onCanvasFocusObservable: Observable<Engine>;
  86959. /**
  86960. * Observable event triggered each time the canvas receives pointerout event
  86961. */
  86962. onCanvasPointerOutObservable: Observable<PointerEvent>;
  86963. /**
  86964. * Observable event triggered before each texture is initialized
  86965. */
  86966. onBeforeTextureInitObservable: Observable<Texture>;
  86967. private _vrDisplay;
  86968. private _vrSupported;
  86969. private _oldSize;
  86970. private _oldHardwareScaleFactor;
  86971. private _vrExclusivePointerMode;
  86972. private _webVRInitPromise;
  86973. /**
  86974. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86975. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86976. */
  86977. readonly isInVRExclusivePointerMode: boolean;
  86978. /**
  86979. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  86980. */
  86981. disableUniformBuffers: boolean;
  86982. /** @hidden */
  86983. _uniformBuffers: UniformBuffer[];
  86984. /**
  86985. * Gets a boolean indicating that the engine supports uniform buffers
  86986. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86987. */
  86988. readonly supportsUniformBuffers: boolean;
  86989. /**
  86990. * Observable raised when the engine begins a new frame
  86991. */
  86992. onBeginFrameObservable: Observable<Engine>;
  86993. /**
  86994. * If set, will be used to request the next animation frame for the render loop
  86995. */
  86996. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  86997. /**
  86998. * Observable raised when the engine ends the current frame
  86999. */
  87000. onEndFrameObservable: Observable<Engine>;
  87001. /**
  87002. * Observable raised when the engine is about to compile a shader
  87003. */
  87004. onBeforeShaderCompilationObservable: Observable<Engine>;
  87005. /**
  87006. * Observable raised when the engine has jsut compiled a shader
  87007. */
  87008. onAfterShaderCompilationObservable: Observable<Engine>;
  87009. /** @hidden */
  87010. _gl: WebGLRenderingContext;
  87011. private _renderingCanvas;
  87012. private _windowIsBackground;
  87013. private _webGLVersion;
  87014. protected _highPrecisionShadersAllowed: boolean;
  87015. /** @hidden */
  87016. readonly _shouldUseHighPrecisionShader: boolean;
  87017. /**
  87018. * Gets a boolean indicating that only power of 2 textures are supported
  87019. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87020. */
  87021. readonly needPOTTextures: boolean;
  87022. /** @hidden */
  87023. _badOS: boolean;
  87024. /** @hidden */
  87025. _badDesktopOS: boolean;
  87026. /**
  87027. * Gets the audio engine
  87028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87029. * @ignorenaming
  87030. */
  87031. static audioEngine: IAudioEngine;
  87032. /**
  87033. * Default AudioEngine factory responsible of creating the Audio Engine.
  87034. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87035. */
  87036. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87037. /**
  87038. * Default offline support factory responsible of creating a tool used to store data locally.
  87039. * By default, this will create a Database object if the workload has been embedded.
  87040. */
  87041. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87042. private _onFocus;
  87043. private _onBlur;
  87044. private _onCanvasPointerOut;
  87045. private _onCanvasBlur;
  87046. private _onCanvasFocus;
  87047. private _onFullscreenChange;
  87048. private _onPointerLockChange;
  87049. private _onVRDisplayPointerRestricted;
  87050. private _onVRDisplayPointerUnrestricted;
  87051. private _onVrDisplayConnect;
  87052. private _onVrDisplayDisconnect;
  87053. private _onVrDisplayPresentChange;
  87054. /**
  87055. * Observable signaled when VR display mode changes
  87056. */
  87057. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  87058. /**
  87059. * Observable signaled when VR request present is complete
  87060. */
  87061. onVRRequestPresentComplete: Observable<boolean>;
  87062. /**
  87063. * Observable signaled when VR request present starts
  87064. */
  87065. onVRRequestPresentStart: Observable<Engine>;
  87066. private _hardwareScalingLevel;
  87067. /** @hidden */
  87068. _caps: EngineCapabilities;
  87069. private _pointerLockRequested;
  87070. private _isStencilEnable;
  87071. private _colorWrite;
  87072. private _loadingScreen;
  87073. /** @hidden */
  87074. _drawCalls: PerfCounter;
  87075. private _glVersion;
  87076. private _glRenderer;
  87077. private _glVendor;
  87078. private _videoTextureSupported;
  87079. private _renderingQueueLaunched;
  87080. private _activeRenderLoops;
  87081. private _deterministicLockstep;
  87082. private _lockstepMaxSteps;
  87083. /**
  87084. * Observable signaled when a context lost event is raised
  87085. */
  87086. onContextLostObservable: Observable<Engine>;
  87087. /**
  87088. * Observable signaled when a context restored event is raised
  87089. */
  87090. onContextRestoredObservable: Observable<Engine>;
  87091. private _onContextLost;
  87092. private _onContextRestored;
  87093. private _contextWasLost;
  87094. /** @hidden */
  87095. _doNotHandleContextLost: boolean;
  87096. /**
  87097. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87098. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87099. */
  87100. doNotHandleContextLost: boolean;
  87101. private _performanceMonitor;
  87102. private _fps;
  87103. private _deltaTime;
  87104. /**
  87105. * Turn this value on if you want to pause FPS computation when in background
  87106. */
  87107. disablePerformanceMonitorInBackground: boolean;
  87108. /**
  87109. * Gets the performance monitor attached to this engine
  87110. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87111. */
  87112. readonly performanceMonitor: PerformanceMonitor;
  87113. /**
  87114. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87115. */
  87116. disableVertexArrayObjects: boolean;
  87117. /** @hidden */
  87118. protected _depthCullingState: _DepthCullingState;
  87119. /** @hidden */
  87120. protected _stencilState: _StencilState;
  87121. /** @hidden */
  87122. protected _alphaState: _AlphaState;
  87123. /** @hidden */
  87124. protected _alphaMode: number;
  87125. /** @hidden */
  87126. _internalTexturesCache: InternalTexture[];
  87127. /** @hidden */
  87128. protected _activeChannel: number;
  87129. private _currentTextureChannel;
  87130. /** @hidden */
  87131. protected _boundTexturesCache: {
  87132. [key: string]: Nullable<InternalTexture>;
  87133. };
  87134. /** @hidden */
  87135. protected _currentEffect: Nullable<Effect>;
  87136. /** @hidden */
  87137. protected _currentProgram: Nullable<WebGLProgram>;
  87138. private _compiledEffects;
  87139. private _vertexAttribArraysEnabled;
  87140. /** @hidden */
  87141. protected _cachedViewport: Nullable<Viewport>;
  87142. private _cachedVertexArrayObject;
  87143. /** @hidden */
  87144. protected _cachedVertexBuffers: any;
  87145. /** @hidden */
  87146. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  87147. /** @hidden */
  87148. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87149. /** @hidden */
  87150. _currentRenderTarget: Nullable<InternalTexture>;
  87151. private _uintIndicesCurrentlySet;
  87152. private _currentBoundBuffer;
  87153. /** @hidden */
  87154. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87155. private _currentBufferPointers;
  87156. private _currentInstanceLocations;
  87157. private _currentInstanceBuffers;
  87158. private _textureUnits;
  87159. /** @hidden */
  87160. _workingCanvas: Nullable<HTMLCanvasElement>;
  87161. /** @hidden */
  87162. _workingContext: Nullable<CanvasRenderingContext2D>;
  87163. private _rescalePostProcess;
  87164. private _dummyFramebuffer;
  87165. private _externalData;
  87166. private _bindedRenderFunction;
  87167. private _vaoRecordInProgress;
  87168. private _mustWipeVertexAttributes;
  87169. private _emptyTexture;
  87170. private _emptyCubeTexture;
  87171. private _emptyTexture3D;
  87172. /** @hidden */
  87173. _frameHandler: number;
  87174. private _nextFreeTextureSlots;
  87175. private _maxSimultaneousTextures;
  87176. private _activeRequests;
  87177. private _texturesSupported;
  87178. /** @hidden */
  87179. _textureFormatInUse: Nullable<string>;
  87180. /**
  87181. * Gets the list of texture formats supported
  87182. */
  87183. readonly texturesSupported: Array<string>;
  87184. /**
  87185. * Gets the list of texture formats in use
  87186. */
  87187. readonly textureFormatInUse: Nullable<string>;
  87188. /**
  87189. * Gets the current viewport
  87190. */
  87191. readonly currentViewport: Nullable<Viewport>;
  87192. /**
  87193. * Gets the default empty texture
  87194. */
  87195. readonly emptyTexture: InternalTexture;
  87196. /**
  87197. * Gets the default empty 3D texture
  87198. */
  87199. readonly emptyTexture3D: InternalTexture;
  87200. /**
  87201. * Gets the default empty cube texture
  87202. */
  87203. readonly emptyCubeTexture: InternalTexture;
  87204. /**
  87205. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87206. */
  87207. readonly premultipliedAlpha: boolean;
  87208. /**
  87209. * Creates a new engine
  87210. * @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
  87211. * @param antialias defines enable antialiasing (default: false)
  87212. * @param options defines further options to be sent to the getContext() function
  87213. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87214. */
  87215. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87216. private _disableTouchAction;
  87217. private _rebuildInternalTextures;
  87218. private _rebuildEffects;
  87219. /**
  87220. * Gets a boolean indicating if all created effects are ready
  87221. * @returns true if all effects are ready
  87222. */
  87223. areAllEffectsReady(): boolean;
  87224. private _rebuildBuffers;
  87225. private _initGLContext;
  87226. /**
  87227. * Gets version of the current webGL context
  87228. */
  87229. readonly webGLVersion: number;
  87230. /**
  87231. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87232. */
  87233. readonly isStencilEnable: boolean;
  87234. /** @hidden */
  87235. _prepareWorkingCanvas(): void;
  87236. /**
  87237. * Reset the texture cache to empty state
  87238. */
  87239. resetTextureCache(): void;
  87240. /**
  87241. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87242. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87243. * @returns true if engine is in deterministic lock step mode
  87244. */
  87245. isDeterministicLockStep(): boolean;
  87246. /**
  87247. * Gets the max steps when engine is running in deterministic lock step
  87248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87249. * @returns the max steps
  87250. */
  87251. getLockstepMaxSteps(): number;
  87252. /**
  87253. * Gets an object containing information about the current webGL context
  87254. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87255. */
  87256. getGlInfo(): {
  87257. vendor: string;
  87258. renderer: string;
  87259. version: string;
  87260. };
  87261. /**
  87262. * Gets current aspect ratio
  87263. * @param camera defines the camera to use to get the aspect ratio
  87264. * @param useScreen defines if screen size must be used (or the current render target if any)
  87265. * @returns a number defining the aspect ratio
  87266. */
  87267. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87268. /**
  87269. * Gets current screen aspect ratio
  87270. * @returns a number defining the aspect ratio
  87271. */
  87272. getScreenAspectRatio(): number;
  87273. /**
  87274. * Gets the current render width
  87275. * @param useScreen defines if screen size must be used (or the current render target if any)
  87276. * @returns a number defining the current render width
  87277. */
  87278. getRenderWidth(useScreen?: boolean): number;
  87279. /**
  87280. * Gets the current render height
  87281. * @param useScreen defines if screen size must be used (or the current render target if any)
  87282. * @returns a number defining the current render height
  87283. */
  87284. getRenderHeight(useScreen?: boolean): number;
  87285. /**
  87286. * Gets the HTML canvas attached with the current webGL context
  87287. * @returns a HTML canvas
  87288. */
  87289. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87290. /**
  87291. * Gets the client rect of the HTML canvas attached with the current webGL context
  87292. * @returns a client rectanglee
  87293. */
  87294. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87295. /**
  87296. * Defines the hardware scaling level.
  87297. * By default the hardware scaling level is computed from the window device ratio.
  87298. * 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.
  87299. * @param level defines the level to use
  87300. */
  87301. setHardwareScalingLevel(level: number): void;
  87302. /**
  87303. * Gets the current hardware scaling level.
  87304. * By default the hardware scaling level is computed from the window device ratio.
  87305. * 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.
  87306. * @returns a number indicating the current hardware scaling level
  87307. */
  87308. getHardwareScalingLevel(): number;
  87309. /**
  87310. * Gets the list of loaded textures
  87311. * @returns an array containing all loaded textures
  87312. */
  87313. getLoadedTexturesCache(): InternalTexture[];
  87314. /**
  87315. * Gets the object containing all engine capabilities
  87316. * @returns the EngineCapabilities object
  87317. */
  87318. getCaps(): EngineCapabilities;
  87319. /**
  87320. * Gets the current depth function
  87321. * @returns a number defining the depth function
  87322. */
  87323. getDepthFunction(): Nullable<number>;
  87324. /**
  87325. * Sets the current depth function
  87326. * @param depthFunc defines the function to use
  87327. */
  87328. setDepthFunction(depthFunc: number): void;
  87329. /**
  87330. * Sets the current depth function to GREATER
  87331. */
  87332. setDepthFunctionToGreater(): void;
  87333. /**
  87334. * Sets the current depth function to GEQUAL
  87335. */
  87336. setDepthFunctionToGreaterOrEqual(): void;
  87337. /**
  87338. * Sets the current depth function to LESS
  87339. */
  87340. setDepthFunctionToLess(): void;
  87341. private _cachedStencilBuffer;
  87342. private _cachedStencilFunction;
  87343. private _cachedStencilMask;
  87344. private _cachedStencilOperationPass;
  87345. private _cachedStencilOperationFail;
  87346. private _cachedStencilOperationDepthFail;
  87347. private _cachedStencilReference;
  87348. /**
  87349. * Caches the the state of the stencil buffer
  87350. */
  87351. cacheStencilState(): void;
  87352. /**
  87353. * Restores the state of the stencil buffer
  87354. */
  87355. restoreStencilState(): void;
  87356. /**
  87357. * Sets the current depth function to LEQUAL
  87358. */
  87359. setDepthFunctionToLessOrEqual(): void;
  87360. /**
  87361. * Gets a boolean indicating if stencil buffer is enabled
  87362. * @returns the current stencil buffer state
  87363. */
  87364. getStencilBuffer(): boolean;
  87365. /**
  87366. * Enable or disable the stencil buffer
  87367. * @param enable defines if the stencil buffer must be enabled or disabled
  87368. */
  87369. setStencilBuffer(enable: boolean): void;
  87370. /**
  87371. * Gets the current stencil mask
  87372. * @returns a number defining the new stencil mask to use
  87373. */
  87374. getStencilMask(): number;
  87375. /**
  87376. * Sets the current stencil mask
  87377. * @param mask defines the new stencil mask to use
  87378. */
  87379. setStencilMask(mask: number): void;
  87380. /**
  87381. * Gets the current stencil function
  87382. * @returns a number defining the stencil function to use
  87383. */
  87384. getStencilFunction(): number;
  87385. /**
  87386. * Gets the current stencil reference value
  87387. * @returns a number defining the stencil reference value to use
  87388. */
  87389. getStencilFunctionReference(): number;
  87390. /**
  87391. * Gets the current stencil mask
  87392. * @returns a number defining the stencil mask to use
  87393. */
  87394. getStencilFunctionMask(): number;
  87395. /**
  87396. * Sets the current stencil function
  87397. * @param stencilFunc defines the new stencil function to use
  87398. */
  87399. setStencilFunction(stencilFunc: number): void;
  87400. /**
  87401. * Sets the current stencil reference
  87402. * @param reference defines the new stencil reference to use
  87403. */
  87404. setStencilFunctionReference(reference: number): void;
  87405. /**
  87406. * Sets the current stencil mask
  87407. * @param mask defines the new stencil mask to use
  87408. */
  87409. setStencilFunctionMask(mask: number): void;
  87410. /**
  87411. * Gets the current stencil operation when stencil fails
  87412. * @returns a number defining stencil operation to use when stencil fails
  87413. */
  87414. getStencilOperationFail(): number;
  87415. /**
  87416. * Gets the current stencil operation when depth fails
  87417. * @returns a number defining stencil operation to use when depth fails
  87418. */
  87419. getStencilOperationDepthFail(): number;
  87420. /**
  87421. * Gets the current stencil operation when stencil passes
  87422. * @returns a number defining stencil operation to use when stencil passes
  87423. */
  87424. getStencilOperationPass(): number;
  87425. /**
  87426. * Sets the stencil operation to use when stencil fails
  87427. * @param operation defines the stencil operation to use when stencil fails
  87428. */
  87429. setStencilOperationFail(operation: number): void;
  87430. /**
  87431. * Sets the stencil operation to use when depth fails
  87432. * @param operation defines the stencil operation to use when depth fails
  87433. */
  87434. setStencilOperationDepthFail(operation: number): void;
  87435. /**
  87436. * Sets the stencil operation to use when stencil passes
  87437. * @param operation defines the stencil operation to use when stencil passes
  87438. */
  87439. setStencilOperationPass(operation: number): void;
  87440. /**
  87441. * Sets a boolean indicating if the dithering state is enabled or disabled
  87442. * @param value defines the dithering state
  87443. */
  87444. setDitheringState(value: boolean): void;
  87445. /**
  87446. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87447. * @param value defines the rasterizer state
  87448. */
  87449. setRasterizerState(value: boolean): void;
  87450. /**
  87451. * stop executing a render loop function and remove it from the execution array
  87452. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87453. */
  87454. stopRenderLoop(renderFunction?: () => void): void;
  87455. /** @hidden */
  87456. _renderLoop(): void;
  87457. /**
  87458. * Register and execute a render loop. The engine can have more than one render function
  87459. * @param renderFunction defines the function to continuously execute
  87460. */
  87461. runRenderLoop(renderFunction: () => void): void;
  87462. /**
  87463. * Toggle full screen mode
  87464. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87465. */
  87466. switchFullscreen(requestPointerLock: boolean): void;
  87467. /**
  87468. * Enters full screen mode
  87469. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87470. */
  87471. enterFullscreen(requestPointerLock: boolean): void;
  87472. /**
  87473. * Exits full screen mode
  87474. */
  87475. exitFullscreen(): void;
  87476. /**
  87477. * Clear the current render buffer or the current render target (if any is set up)
  87478. * @param color defines the color to use
  87479. * @param backBuffer defines if the back buffer must be cleared
  87480. * @param depth defines if the depth buffer must be cleared
  87481. * @param stencil defines if the stencil buffer must be cleared
  87482. */
  87483. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87484. /**
  87485. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87486. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87487. * @param y defines the y-coordinate of the corner of the clear rectangle
  87488. * @param width defines the width of the clear rectangle
  87489. * @param height defines the height of the clear rectangle
  87490. * @param clearColor defines the clear color
  87491. */
  87492. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87493. /**
  87494. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87495. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87496. * @param y defines the y-coordinate of the corner of the clear rectangle
  87497. * @param width defines the width of the clear rectangle
  87498. * @param height defines the height of the clear rectangle
  87499. */
  87500. enableScissor(x: number, y: number, width: number, height: number): void;
  87501. /**
  87502. * Disable previously set scissor test rectangle
  87503. */
  87504. disableScissor(): void;
  87505. private _viewportCached;
  87506. /** @hidden */
  87507. _viewport(x: number, y: number, width: number, height: number): void;
  87508. /**
  87509. * Set the WebGL's viewport
  87510. * @param viewport defines the viewport element to be used
  87511. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87512. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87513. */
  87514. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87515. /**
  87516. * Directly set the WebGL Viewport
  87517. * @param x defines the x coordinate of the viewport (in screen space)
  87518. * @param y defines the y coordinate of the viewport (in screen space)
  87519. * @param width defines the width of the viewport (in screen space)
  87520. * @param height defines the height of the viewport (in screen space)
  87521. * @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
  87522. */
  87523. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87524. /**
  87525. * Begin a new frame
  87526. */
  87527. beginFrame(): void;
  87528. /**
  87529. * Enf the current frame
  87530. */
  87531. endFrame(): void;
  87532. /**
  87533. * Resize the view according to the canvas' size
  87534. */
  87535. resize(): void;
  87536. /**
  87537. * Force a specific size of the canvas
  87538. * @param width defines the new canvas' width
  87539. * @param height defines the new canvas' height
  87540. */
  87541. setSize(width: number, height: number): void;
  87542. /**
  87543. * Gets a boolean indicating if a webVR device was detected
  87544. * @returns true if a webVR device was detected
  87545. */
  87546. isVRDevicePresent(): boolean;
  87547. /**
  87548. * Gets the current webVR device
  87549. * @returns the current webVR device (or null)
  87550. */
  87551. getVRDevice(): any;
  87552. /**
  87553. * Initializes a webVR display and starts listening to display change events
  87554. * The onVRDisplayChangedObservable will be notified upon these changes
  87555. * @returns The onVRDisplayChangedObservable
  87556. */
  87557. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87558. /**
  87559. * Initializes a webVR display and starts listening to display change events
  87560. * The onVRDisplayChangedObservable will be notified upon these changes
  87561. * @returns A promise containing a VRDisplay and if vr is supported
  87562. */
  87563. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87564. /**
  87565. * Call this function to switch to webVR mode
  87566. * Will do nothing if webVR is not supported or if there is no webVR device
  87567. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87568. */
  87569. enableVR(): void;
  87570. /**
  87571. * Call this function to leave webVR mode
  87572. * Will do nothing if webVR is not supported or if there is no webVR device
  87573. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87574. */
  87575. disableVR(): void;
  87576. private _onVRFullScreenTriggered;
  87577. private _getVRDisplaysAsync;
  87578. /**
  87579. * Binds the frame buffer to the specified texture.
  87580. * @param texture The texture to render to or null for the default canvas
  87581. * @param faceIndex The face of the texture to render to in case of cube texture
  87582. * @param requiredWidth The width of the target to render to
  87583. * @param requiredHeight The height of the target to render to
  87584. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87585. * @param depthStencilTexture The depth stencil texture to use to render
  87586. * @param lodLevel defines le lod level to bind to the frame buffer
  87587. */
  87588. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87589. /** @hidden */
  87590. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  87591. /**
  87592. * Unbind the current render target texture from the webGL context
  87593. * @param texture defines the render target texture to unbind
  87594. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87595. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87596. */
  87597. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87598. /**
  87599. * Force the mipmap generation for the given render target texture
  87600. * @param texture defines the render target texture to use
  87601. */
  87602. generateMipMapsForCubemap(texture: InternalTexture): void;
  87603. /**
  87604. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  87605. */
  87606. flushFramebuffer(): void;
  87607. /**
  87608. * Unbind the current render target and bind the default framebuffer
  87609. */
  87610. restoreDefaultFramebuffer(): void;
  87611. /**
  87612. * Create an uniform buffer
  87613. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87614. * @param elements defines the content of the uniform buffer
  87615. * @returns the webGL uniform buffer
  87616. */
  87617. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  87618. /**
  87619. * Create a dynamic uniform buffer
  87620. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87621. * @param elements defines the content of the uniform buffer
  87622. * @returns the webGL uniform buffer
  87623. */
  87624. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  87625. /**
  87626. * Update an existing uniform buffer
  87627. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87628. * @param uniformBuffer defines the target uniform buffer
  87629. * @param elements defines the content to update
  87630. * @param offset defines the offset in the uniform buffer where update should start
  87631. * @param count defines the size of the data to update
  87632. */
  87633. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87634. private _resetVertexBufferBinding;
  87635. /**
  87636. * Creates a vertex buffer
  87637. * @param data the data for the vertex buffer
  87638. * @returns the new WebGL static buffer
  87639. */
  87640. createVertexBuffer(data: DataArray): WebGLBuffer;
  87641. /**
  87642. * Creates a dynamic vertex buffer
  87643. * @param data the data for the dynamic vertex buffer
  87644. * @returns the new WebGL dynamic buffer
  87645. */
  87646. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  87647. /**
  87648. * Update a dynamic index buffer
  87649. * @param indexBuffer defines the target index buffer
  87650. * @param indices defines the data to update
  87651. * @param offset defines the offset in the target index buffer where update should start
  87652. */
  87653. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  87654. /**
  87655. * Updates a dynamic vertex buffer.
  87656. * @param vertexBuffer the vertex buffer to update
  87657. * @param data the data used to update the vertex buffer
  87658. * @param byteOffset the byte offset of the data
  87659. * @param byteLength the byte length of the data
  87660. */
  87661. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  87662. private _resetIndexBufferBinding;
  87663. /**
  87664. * Creates a new index buffer
  87665. * @param indices defines the content of the index buffer
  87666. * @param updatable defines if the index buffer must be updatable
  87667. * @returns a new webGL buffer
  87668. */
  87669. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  87670. /**
  87671. * Bind a webGL buffer to the webGL context
  87672. * @param buffer defines the buffer to bind
  87673. */
  87674. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  87675. /**
  87676. * Bind an uniform buffer to the current webGL context
  87677. * @param buffer defines the buffer to bind
  87678. */
  87679. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  87680. /**
  87681. * Bind a buffer to the current webGL context at a given location
  87682. * @param buffer defines the buffer to bind
  87683. * @param location defines the index where to bind the buffer
  87684. */
  87685. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  87686. /**
  87687. * Bind a specific block at a given index in a specific shader program
  87688. * @param shaderProgram defines the shader program
  87689. * @param blockName defines the block name
  87690. * @param index defines the index where to bind the block
  87691. */
  87692. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  87693. private bindIndexBuffer;
  87694. private bindBuffer;
  87695. /**
  87696. * update the bound buffer with the given data
  87697. * @param data defines the data to update
  87698. */
  87699. updateArrayBuffer(data: Float32Array): void;
  87700. private _vertexAttribPointer;
  87701. private _bindIndexBufferWithCache;
  87702. private _bindVertexBuffersAttributes;
  87703. /**
  87704. * Records a vertex array object
  87705. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87706. * @param vertexBuffers defines the list of vertex buffers to store
  87707. * @param indexBuffer defines the index buffer to store
  87708. * @param effect defines the effect to store
  87709. * @returns the new vertex array object
  87710. */
  87711. recordVertexArrayObject(vertexBuffers: {
  87712. [key: string]: VertexBuffer;
  87713. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  87714. /**
  87715. * Bind a specific vertex array object
  87716. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87717. * @param vertexArrayObject defines the vertex array object to bind
  87718. * @param indexBuffer defines the index buffer to bind
  87719. */
  87720. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  87721. /**
  87722. * Bind webGl buffers directly to the webGL context
  87723. * @param vertexBuffer defines the vertex buffer to bind
  87724. * @param indexBuffer defines the index buffer to bind
  87725. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87726. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87727. * @param effect defines the effect associated with the vertex buffer
  87728. */
  87729. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87730. private _unbindVertexArrayObject;
  87731. /**
  87732. * Bind a list of vertex buffers to the webGL context
  87733. * @param vertexBuffers defines the list of vertex buffers to bind
  87734. * @param indexBuffer defines the index buffer to bind
  87735. * @param effect defines the effect associated with the vertex buffers
  87736. */
  87737. bindBuffers(vertexBuffers: {
  87738. [key: string]: Nullable<VertexBuffer>;
  87739. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  87740. /**
  87741. * Unbind all instance attributes
  87742. */
  87743. unbindInstanceAttributes(): void;
  87744. /**
  87745. * Release and free the memory of a vertex array object
  87746. * @param vao defines the vertex array object to delete
  87747. */
  87748. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87749. /** @hidden */
  87750. _releaseBuffer(buffer: WebGLBuffer): boolean;
  87751. /**
  87752. * Creates a webGL buffer to use with instanciation
  87753. * @param capacity defines the size of the buffer
  87754. * @returns the webGL buffer
  87755. */
  87756. createInstancesBuffer(capacity: number): WebGLBuffer;
  87757. /**
  87758. * Delete a webGL buffer used with instanciation
  87759. * @param buffer defines the webGL buffer to delete
  87760. */
  87761. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87762. /**
  87763. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87764. * @param instancesBuffer defines the webGL buffer to update and bind
  87765. * @param data defines the data to store in the buffer
  87766. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87767. */
  87768. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87769. /**
  87770. * Apply all cached states (depth, culling, stencil and alpha)
  87771. */
  87772. applyStates(): void;
  87773. /**
  87774. * Send a draw order
  87775. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87776. * @param indexStart defines the starting index
  87777. * @param indexCount defines the number of index to draw
  87778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87779. */
  87780. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87781. /**
  87782. * Draw a list of points
  87783. * @param verticesStart defines the index of first vertex to draw
  87784. * @param verticesCount defines the count of vertices to draw
  87785. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87786. */
  87787. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87788. /**
  87789. * Draw a list of unindexed primitives
  87790. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87791. * @param verticesStart defines the index of first vertex to draw
  87792. * @param verticesCount defines the count of vertices to draw
  87793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87794. */
  87795. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87796. /**
  87797. * Draw a list of indexed primitives
  87798. * @param fillMode defines the primitive to use
  87799. * @param indexStart defines the starting index
  87800. * @param indexCount defines the number of index to draw
  87801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87802. */
  87803. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87804. /**
  87805. * Draw a list of unindexed primitives
  87806. * @param fillMode defines the primitive to use
  87807. * @param verticesStart defines the index of first vertex to draw
  87808. * @param verticesCount defines the count of vertices to draw
  87809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87810. */
  87811. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87812. private _drawMode;
  87813. /** @hidden */
  87814. _releaseEffect(effect: Effect): void;
  87815. /** @hidden */
  87816. _deleteProgram(program: WebGLProgram): void;
  87817. /**
  87818. * Create a new effect (used to store vertex/fragment shaders)
  87819. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87820. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87821. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87822. * @param samplers defines an array of string used to represent textures
  87823. * @param defines defines the string containing the defines to use to compile the shaders
  87824. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87825. * @param onCompiled defines a function to call when the effect creation is successful
  87826. * @param onError defines a function to call when the effect creation has failed
  87827. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87828. * @returns the new Effect
  87829. */
  87830. 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;
  87831. private _compileShader;
  87832. private _compileRawShader;
  87833. /**
  87834. * Directly creates a webGL program
  87835. * @param vertexCode defines the vertex shader code to use
  87836. * @param fragmentCode defines the fragment shader code to use
  87837. * @param context defines the webGL context to use (if not set, the current one will be used)
  87838. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87839. * @returns the new webGL program
  87840. */
  87841. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87842. /**
  87843. * Creates a webGL program
  87844. * @param vertexCode defines the vertex shader code to use
  87845. * @param fragmentCode defines the fragment shader code to use
  87846. * @param defines defines the string containing the defines to use to compile the shaders
  87847. * @param context defines the webGL context to use (if not set, the current one will be used)
  87848. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87849. * @returns the new webGL program
  87850. */
  87851. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87852. private _createShaderProgram;
  87853. private _finalizeProgram;
  87854. /** @hidden */
  87855. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  87856. /** @hidden */
  87857. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  87858. /**
  87859. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  87860. * @param shaderProgram defines the webGL program to use
  87861. * @param uniformsNames defines the list of uniform names
  87862. * @returns an array of webGL uniform locations
  87863. */
  87864. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  87865. /**
  87866. * Gets the lsit of active attributes for a given webGL program
  87867. * @param shaderProgram defines the webGL program to use
  87868. * @param attributesNames defines the list of attribute names to get
  87869. * @returns an array of indices indicating the offset of each attribute
  87870. */
  87871. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  87872. /**
  87873. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  87874. * @param effect defines the effect to activate
  87875. */
  87876. enableEffect(effect: Nullable<Effect>): void;
  87877. /**
  87878. * Set the value of an uniform to an array of int32
  87879. * @param uniform defines the webGL uniform location where to store the value
  87880. * @param array defines the array of int32 to store
  87881. */
  87882. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87883. /**
  87884. * Set the value of an uniform to an array of int32 (stored as vec2)
  87885. * @param uniform defines the webGL uniform location where to store the value
  87886. * @param array defines the array of int32 to store
  87887. */
  87888. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87889. /**
  87890. * Set the value of an uniform to an array of int32 (stored as vec3)
  87891. * @param uniform defines the webGL uniform location where to store the value
  87892. * @param array defines the array of int32 to store
  87893. */
  87894. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87895. /**
  87896. * Set the value of an uniform to an array of int32 (stored as vec4)
  87897. * @param uniform defines the webGL uniform location where to store the value
  87898. * @param array defines the array of int32 to store
  87899. */
  87900. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87901. /**
  87902. * Set the value of an uniform to an array of float32
  87903. * @param uniform defines the webGL uniform location where to store the value
  87904. * @param array defines the array of float32 to store
  87905. */
  87906. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87907. /**
  87908. * Set the value of an uniform to an array of float32 (stored as vec2)
  87909. * @param uniform defines the webGL uniform location where to store the value
  87910. * @param array defines the array of float32 to store
  87911. */
  87912. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87913. /**
  87914. * Set the value of an uniform to an array of float32 (stored as vec3)
  87915. * @param uniform defines the webGL uniform location where to store the value
  87916. * @param array defines the array of float32 to store
  87917. */
  87918. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87919. /**
  87920. * Set the value of an uniform to an array of float32 (stored as vec4)
  87921. * @param uniform defines the webGL uniform location where to store the value
  87922. * @param array defines the array of float32 to store
  87923. */
  87924. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87925. /**
  87926. * Set the value of an uniform to an array of number
  87927. * @param uniform defines the webGL uniform location where to store the value
  87928. * @param array defines the array of number to store
  87929. */
  87930. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87931. /**
  87932. * Set the value of an uniform to an array of number (stored as vec2)
  87933. * @param uniform defines the webGL uniform location where to store the value
  87934. * @param array defines the array of number to store
  87935. */
  87936. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87937. /**
  87938. * Set the value of an uniform to an array of number (stored as vec3)
  87939. * @param uniform defines the webGL uniform location where to store the value
  87940. * @param array defines the array of number to store
  87941. */
  87942. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87943. /**
  87944. * Set the value of an uniform to an array of number (stored as vec4)
  87945. * @param uniform defines the webGL uniform location where to store the value
  87946. * @param array defines the array of number to store
  87947. */
  87948. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87949. /**
  87950. * Set the value of an uniform to an array of float32 (stored as matrices)
  87951. * @param uniform defines the webGL uniform location where to store the value
  87952. * @param matrices defines the array of float32 to store
  87953. */
  87954. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  87955. /**
  87956. * Set the value of an uniform to a matrix
  87957. * @param uniform defines the webGL uniform location where to store the value
  87958. * @param matrix defines the matrix to store
  87959. */
  87960. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  87961. /**
  87962. * Set the value of an uniform to a matrix (3x3)
  87963. * @param uniform defines the webGL uniform location where to store the value
  87964. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  87965. */
  87966. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87967. /**
  87968. * Set the value of an uniform to a matrix (2x2)
  87969. * @param uniform defines the webGL uniform location where to store the value
  87970. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  87971. */
  87972. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87973. /**
  87974. * Set the value of an uniform to a number (int)
  87975. * @param uniform defines the webGL uniform location where to store the value
  87976. * @param value defines the int number to store
  87977. */
  87978. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87979. /**
  87980. * Set the value of an uniform to a number (float)
  87981. * @param uniform defines the webGL uniform location where to store the value
  87982. * @param value defines the float number to store
  87983. */
  87984. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87985. /**
  87986. * Set the value of an uniform to a vec2
  87987. * @param uniform defines the webGL uniform location where to store the value
  87988. * @param x defines the 1st component of the value
  87989. * @param y defines the 2nd component of the value
  87990. */
  87991. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  87992. /**
  87993. * Set the value of an uniform to a vec3
  87994. * @param uniform defines the webGL uniform location where to store the value
  87995. * @param x defines the 1st component of the value
  87996. * @param y defines the 2nd component of the value
  87997. * @param z defines the 3rd component of the value
  87998. */
  87999. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88000. /**
  88001. * Set the value of an uniform to a boolean
  88002. * @param uniform defines the webGL uniform location where to store the value
  88003. * @param bool defines the boolean to store
  88004. */
  88005. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88006. /**
  88007. * Set the value of an uniform to a vec4
  88008. * @param uniform defines the webGL uniform location where to store the value
  88009. * @param x defines the 1st component of the value
  88010. * @param y defines the 2nd component of the value
  88011. * @param z defines the 3rd component of the value
  88012. * @param w defines the 4th component of the value
  88013. */
  88014. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88015. /**
  88016. * Set the value of an uniform to a Color3
  88017. * @param uniform defines the webGL uniform location where to store the value
  88018. * @param color3 defines the color to store
  88019. */
  88020. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88021. /**
  88022. * Set the value of an uniform to a Color3 and an alpha value
  88023. * @param uniform defines the webGL uniform location where to store the value
  88024. * @param color3 defines the color to store
  88025. * @param alpha defines the alpha component to store
  88026. */
  88027. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88028. /**
  88029. * Sets a Color4 on a uniform variable
  88030. * @param uniform defines the uniform location
  88031. * @param color4 defines the value to be set
  88032. */
  88033. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88034. /**
  88035. * Set various states to the webGL context
  88036. * @param culling defines backface culling state
  88037. * @param zOffset defines the value to apply to zOffset (0 by default)
  88038. * @param force defines if states must be applied even if cache is up to date
  88039. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88040. */
  88041. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88042. /**
  88043. * Set the z offset to apply to current rendering
  88044. * @param value defines the offset to apply
  88045. */
  88046. setZOffset(value: number): void;
  88047. /**
  88048. * Gets the current value of the zOffset
  88049. * @returns the current zOffset state
  88050. */
  88051. getZOffset(): number;
  88052. /**
  88053. * Enable or disable depth buffering
  88054. * @param enable defines the state to set
  88055. */
  88056. setDepthBuffer(enable: boolean): void;
  88057. /**
  88058. * Gets a boolean indicating if depth writing is enabled
  88059. * @returns the current depth writing state
  88060. */
  88061. getDepthWrite(): boolean;
  88062. /**
  88063. * Enable or disable depth writing
  88064. * @param enable defines the state to set
  88065. */
  88066. setDepthWrite(enable: boolean): void;
  88067. /**
  88068. * Enable or disable color writing
  88069. * @param enable defines the state to set
  88070. */
  88071. setColorWrite(enable: boolean): void;
  88072. /**
  88073. * Gets a boolean indicating if color writing is enabled
  88074. * @returns the current color writing state
  88075. */
  88076. getColorWrite(): boolean;
  88077. /**
  88078. * Sets alpha constants used by some alpha blending modes
  88079. * @param r defines the red component
  88080. * @param g defines the green component
  88081. * @param b defines the blue component
  88082. * @param a defines the alpha component
  88083. */
  88084. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88085. /**
  88086. * Sets the current alpha mode
  88087. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88088. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88089. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88090. */
  88091. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88092. /**
  88093. * Gets the current alpha mode
  88094. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88095. * @returns the current alpha mode
  88096. */
  88097. getAlphaMode(): number;
  88098. /**
  88099. * Clears the list of texture accessible through engine.
  88100. * This can help preventing texture load conflict due to name collision.
  88101. */
  88102. clearInternalTexturesCache(): void;
  88103. /**
  88104. * Force the entire cache to be cleared
  88105. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88106. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88107. */
  88108. wipeCaches(bruteForce?: boolean): void;
  88109. /**
  88110. * Set the compressed texture format to use, based on the formats you have, and the formats
  88111. * supported by the hardware / browser.
  88112. *
  88113. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88114. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88115. * to API arguments needed to compressed textures. This puts the burden on the container
  88116. * generator to house the arcane code for determining these for current & future formats.
  88117. *
  88118. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88119. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88120. *
  88121. * Note: The result of this call is not taken into account when a texture is base64.
  88122. *
  88123. * @param formatsAvailable defines the list of those format families you have created
  88124. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88125. *
  88126. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88127. * @returns The extension selected.
  88128. */
  88129. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88130. /** @hidden */
  88131. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88132. min: number;
  88133. mag: number;
  88134. };
  88135. /** @hidden */
  88136. _createTexture(): WebGLTexture;
  88137. /**
  88138. * Usually called from Texture.ts.
  88139. * Passed information to create a WebGLTexture
  88140. * @param urlArg defines a value which contains one of the following:
  88141. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88142. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88143. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88144. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88145. * @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)
  88146. * @param scene needed for loading to the correct scene
  88147. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88148. * @param onLoad optional callback to be called upon successful completion
  88149. * @param onError optional callback to be called upon failure
  88150. * @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
  88151. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88152. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88153. * @param forcedExtension defines the extension to use to pick the right loader
  88154. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88155. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88156. */
  88157. 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;
  88158. private _rescaleTexture;
  88159. private _unpackFlipYCached;
  88160. /**
  88161. * In case you are sharing the context with other applications, it might
  88162. * be interested to not cache the unpack flip y state to ensure a consistent
  88163. * value would be set.
  88164. */
  88165. enableUnpackFlipYCached: boolean;
  88166. /** @hidden */
  88167. _unpackFlipY(value: boolean): void;
  88168. /** @hidden */
  88169. _getUnpackAlignement(): number;
  88170. /**
  88171. * Creates a dynamic texture
  88172. * @param width defines the width of the texture
  88173. * @param height defines the height of the texture
  88174. * @param generateMipMaps defines if the engine should generate the mip levels
  88175. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88176. * @returns the dynamic texture inside an InternalTexture
  88177. */
  88178. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88179. /**
  88180. * Update the sampling mode of a given texture
  88181. * @param samplingMode defines the required sampling mode
  88182. * @param texture defines the texture to update
  88183. */
  88184. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88185. /**
  88186. * Update the content of a dynamic texture
  88187. * @param texture defines the texture to update
  88188. * @param canvas defines the canvas containing the source
  88189. * @param invertY defines if data must be stored with Y axis inverted
  88190. * @param premulAlpha defines if alpha is stored as premultiplied
  88191. * @param format defines the format of the data
  88192. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88193. */
  88194. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88195. /**
  88196. * Update a video texture
  88197. * @param texture defines the texture to update
  88198. * @param video defines the video element to use
  88199. * @param invertY defines if data must be stored with Y axis inverted
  88200. */
  88201. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88202. /**
  88203. * Updates a depth texture Comparison Mode and Function.
  88204. * If the comparison Function is equal to 0, the mode will be set to none.
  88205. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88206. * @param texture The texture to set the comparison function for
  88207. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88208. */
  88209. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88210. /** @hidden */
  88211. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88212. width: number;
  88213. height: number;
  88214. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88215. /**
  88216. * Creates a depth stencil texture.
  88217. * This is only available in WebGL 2 or with the depth texture extension available.
  88218. * @param size The size of face edge in the texture.
  88219. * @param options The options defining the texture.
  88220. * @returns The texture
  88221. */
  88222. createDepthStencilTexture(size: number | {
  88223. width: number;
  88224. height: number;
  88225. }, options: DepthTextureCreationOptions): InternalTexture;
  88226. /**
  88227. * Creates a depth stencil texture.
  88228. * This is only available in WebGL 2 or with the depth texture extension available.
  88229. * @param size The size of face edge in the texture.
  88230. * @param options The options defining the texture.
  88231. * @returns The texture
  88232. */
  88233. private _createDepthStencilTexture;
  88234. /**
  88235. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88236. * @param renderTarget The render target to set the frame buffer for
  88237. */
  88238. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88239. /**
  88240. * Creates a new render target texture
  88241. * @param size defines the size of the texture
  88242. * @param options defines the options used to create the texture
  88243. * @returns a new render target texture stored in an InternalTexture
  88244. */
  88245. createRenderTargetTexture(size: number | {
  88246. width: number;
  88247. height: number;
  88248. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88249. /** @hidden */
  88250. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88251. /**
  88252. * Updates the sample count of a render target texture
  88253. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88254. * @param texture defines the texture to update
  88255. * @param samples defines the sample count to set
  88256. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88257. */
  88258. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88259. /** @hidden */
  88260. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88261. /** @hidden */
  88262. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88263. /** @hidden */
  88264. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88265. /** @hidden */
  88266. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88267. /**
  88268. * @hidden
  88269. */
  88270. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88271. private _prepareWebGLTextureContinuation;
  88272. private _prepareWebGLTexture;
  88273. /** @hidden */
  88274. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88275. /** @hidden */
  88276. _releaseFramebufferObjects(texture: InternalTexture): void;
  88277. /** @hidden */
  88278. _releaseTexture(texture: InternalTexture): void;
  88279. private setProgram;
  88280. private _boundUniforms;
  88281. /**
  88282. * Binds an effect to the webGL context
  88283. * @param effect defines the effect to bind
  88284. */
  88285. bindSamplers(effect: Effect): void;
  88286. private _activateCurrentTexture;
  88287. /** @hidden */
  88288. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88289. /** @hidden */
  88290. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88291. /**
  88292. * Sets a texture to the webGL context from a postprocess
  88293. * @param channel defines the channel to use
  88294. * @param postProcess defines the source postprocess
  88295. */
  88296. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88297. /**
  88298. * Binds the output of the passed in post process to the texture channel specified
  88299. * @param channel The channel the texture should be bound to
  88300. * @param postProcess The post process which's output should be bound
  88301. */
  88302. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88303. /**
  88304. * Unbind all textures from the webGL context
  88305. */
  88306. unbindAllTextures(): void;
  88307. /**
  88308. * Sets a texture to the according uniform.
  88309. * @param channel The texture channel
  88310. * @param uniform The uniform to set
  88311. * @param texture The texture to apply
  88312. */
  88313. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88314. /**
  88315. * Sets a depth stencil texture from a render target to the according uniform.
  88316. * @param channel The texture channel
  88317. * @param uniform The uniform to set
  88318. * @param texture The render target texture containing the depth stencil texture to apply
  88319. */
  88320. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88321. private _bindSamplerUniformToChannel;
  88322. private _getTextureWrapMode;
  88323. private _setTexture;
  88324. /**
  88325. * Sets an array of texture to the webGL context
  88326. * @param channel defines the channel where the texture array must be set
  88327. * @param uniform defines the associated uniform location
  88328. * @param textures defines the array of textures to bind
  88329. */
  88330. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88331. /** @hidden */
  88332. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88333. private _setTextureParameterFloat;
  88334. private _setTextureParameterInteger;
  88335. /**
  88336. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88337. * @param x defines the x coordinate of the rectangle where pixels must be read
  88338. * @param y defines the y coordinate of the rectangle where pixels must be read
  88339. * @param width defines the width of the rectangle where pixels must be read
  88340. * @param height defines the height of the rectangle where pixels must be read
  88341. * @returns a Uint8Array containing RGBA colors
  88342. */
  88343. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88344. /**
  88345. * Add an externaly attached data from its key.
  88346. * This method call will fail and return false, if such key already exists.
  88347. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88348. * @param key the unique key that identifies the data
  88349. * @param data the data object to associate to the key for this Engine instance
  88350. * @return true if no such key were already present and the data was added successfully, false otherwise
  88351. */
  88352. addExternalData<T>(key: string, data: T): boolean;
  88353. /**
  88354. * Get an externaly attached data from its key
  88355. * @param key the unique key that identifies the data
  88356. * @return the associated data, if present (can be null), or undefined if not present
  88357. */
  88358. getExternalData<T>(key: string): T;
  88359. /**
  88360. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88361. * @param key the unique key that identifies the data
  88362. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88363. * @return the associated data, can be null if the factory returned null.
  88364. */
  88365. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88366. /**
  88367. * Remove an externaly attached data from the Engine instance
  88368. * @param key the unique key that identifies the data
  88369. * @return true if the data was successfully removed, false if it doesn't exist
  88370. */
  88371. removeExternalData(key: string): boolean;
  88372. /**
  88373. * Unbind all vertex attributes from the webGL context
  88374. */
  88375. unbindAllAttributes(): void;
  88376. /**
  88377. * 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
  88378. */
  88379. releaseEffects(): void;
  88380. /**
  88381. * Dispose and release all associated resources
  88382. */
  88383. dispose(): void;
  88384. /**
  88385. * Display the loading screen
  88386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88387. */
  88388. displayLoadingUI(): void;
  88389. /**
  88390. * Hide the loading screen
  88391. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88392. */
  88393. hideLoadingUI(): void;
  88394. /**
  88395. * Gets the current loading screen object
  88396. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88397. */
  88398. /**
  88399. * Sets the current loading screen object
  88400. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88401. */
  88402. loadingScreen: ILoadingScreen;
  88403. /**
  88404. * Sets the current loading screen text
  88405. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88406. */
  88407. loadingUIText: string;
  88408. /**
  88409. * Sets the current loading screen background color
  88410. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88411. */
  88412. loadingUIBackgroundColor: string;
  88413. /**
  88414. * Attach a new callback raised when context lost event is fired
  88415. * @param callback defines the callback to call
  88416. */
  88417. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88418. /**
  88419. * Attach a new callback raised when context restored event is fired
  88420. * @param callback defines the callback to call
  88421. */
  88422. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88423. /**
  88424. * Gets the source code of the vertex shader associated with a specific webGL program
  88425. * @param program defines the program to use
  88426. * @returns a string containing the source code of the vertex shader associated with the program
  88427. */
  88428. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88429. /**
  88430. * Gets the source code of the fragment shader associated with a specific webGL program
  88431. * @param program defines the program to use
  88432. * @returns a string containing the source code of the fragment shader associated with the program
  88433. */
  88434. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88435. /**
  88436. * Get the current error code of the webGL context
  88437. * @returns the error code
  88438. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88439. */
  88440. getError(): number;
  88441. /**
  88442. * Gets the current framerate
  88443. * @returns a number representing the framerate
  88444. */
  88445. getFps(): number;
  88446. /**
  88447. * Gets the time spent between current and previous frame
  88448. * @returns a number representing the delta time in ms
  88449. */
  88450. getDeltaTime(): number;
  88451. private _measureFps;
  88452. /** @hidden */
  88453. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88454. private _canRenderToFloatFramebuffer;
  88455. private _canRenderToHalfFloatFramebuffer;
  88456. private _canRenderToFramebuffer;
  88457. /** @hidden */
  88458. _getWebGLTextureType(type: number): number;
  88459. /** @hidden */
  88460. _getInternalFormat(format: number): number;
  88461. /** @hidden */
  88462. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88463. /** @hidden */
  88464. _getRGBAMultiSampleBufferFormat(type: number): number;
  88465. /** @hidden */
  88466. _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;
  88467. /** @hidden */
  88468. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88469. /**
  88470. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88471. * @returns true if the engine can be created
  88472. * @ignorenaming
  88473. */
  88474. static isSupported(): boolean;
  88475. }
  88476. }
  88477. declare module BABYLON {
  88478. /**
  88479. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88480. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88481. */
  88482. export class EffectFallbacks {
  88483. private _defines;
  88484. private _currentRank;
  88485. private _maxRank;
  88486. private _mesh;
  88487. /**
  88488. * Removes the fallback from the bound mesh.
  88489. */
  88490. unBindMesh(): void;
  88491. /**
  88492. * Adds a fallback on the specified property.
  88493. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88494. * @param define The name of the define in the shader
  88495. */
  88496. addFallback(rank: number, define: string): void;
  88497. /**
  88498. * Sets the mesh to use CPU skinning when needing to fallback.
  88499. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88500. * @param mesh The mesh to use the fallbacks.
  88501. */
  88502. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88503. /**
  88504. * Checks to see if more fallbacks are still availible.
  88505. */
  88506. readonly isMoreFallbacks: boolean;
  88507. /**
  88508. * Removes the defines that shoould be removed when falling back.
  88509. * @param currentDefines defines the current define statements for the shader.
  88510. * @param effect defines the current effect we try to compile
  88511. * @returns The resulting defines with defines of the current rank removed.
  88512. */
  88513. reduce(currentDefines: string, effect: Effect): string;
  88514. }
  88515. /**
  88516. * Options to be used when creating an effect.
  88517. */
  88518. export class EffectCreationOptions {
  88519. /**
  88520. * Atrributes that will be used in the shader.
  88521. */
  88522. attributes: string[];
  88523. /**
  88524. * Uniform varible names that will be set in the shader.
  88525. */
  88526. uniformsNames: string[];
  88527. /**
  88528. * Uniform buffer varible names that will be set in the shader.
  88529. */
  88530. uniformBuffersNames: string[];
  88531. /**
  88532. * Sampler texture variable names that will be set in the shader.
  88533. */
  88534. samplers: string[];
  88535. /**
  88536. * Define statements that will be set in the shader.
  88537. */
  88538. defines: any;
  88539. /**
  88540. * Possible fallbacks for this effect to improve performance when needed.
  88541. */
  88542. fallbacks: Nullable<EffectFallbacks>;
  88543. /**
  88544. * Callback that will be called when the shader is compiled.
  88545. */
  88546. onCompiled: Nullable<(effect: Effect) => void>;
  88547. /**
  88548. * Callback that will be called if an error occurs during shader compilation.
  88549. */
  88550. onError: Nullable<(effect: Effect, errors: string) => void>;
  88551. /**
  88552. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88553. */
  88554. indexParameters: any;
  88555. /**
  88556. * Max number of lights that can be used in the shader.
  88557. */
  88558. maxSimultaneousLights: number;
  88559. /**
  88560. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88561. */
  88562. transformFeedbackVaryings: Nullable<string[]>;
  88563. }
  88564. /**
  88565. * Effect containing vertex and fragment shader that can be executed on an object.
  88566. */
  88567. export class Effect implements IDisposable {
  88568. /**
  88569. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88570. */
  88571. static ShadersRepository: string;
  88572. /**
  88573. * Name of the effect.
  88574. */
  88575. name: any;
  88576. /**
  88577. * String container all the define statements that should be set on the shader.
  88578. */
  88579. defines: string;
  88580. /**
  88581. * Callback that will be called when the shader is compiled.
  88582. */
  88583. onCompiled: Nullable<(effect: Effect) => void>;
  88584. /**
  88585. * Callback that will be called if an error occurs during shader compilation.
  88586. */
  88587. onError: Nullable<(effect: Effect, errors: string) => void>;
  88588. /**
  88589. * Callback that will be called when effect is bound.
  88590. */
  88591. onBind: Nullable<(effect: Effect) => void>;
  88592. /**
  88593. * Unique ID of the effect.
  88594. */
  88595. uniqueId: number;
  88596. /**
  88597. * Observable that will be called when the shader is compiled.
  88598. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88599. */
  88600. onCompileObservable: Observable<Effect>;
  88601. /**
  88602. * Observable that will be called if an error occurs during shader compilation.
  88603. */
  88604. onErrorObservable: Observable<Effect>;
  88605. /** @hidden */
  88606. _onBindObservable: Nullable<Observable<Effect>>;
  88607. /**
  88608. * Observable that will be called when effect is bound.
  88609. */
  88610. readonly onBindObservable: Observable<Effect>;
  88611. /** @hidden */
  88612. _bonesComputationForcedToCPU: boolean;
  88613. private static _uniqueIdSeed;
  88614. private _engine;
  88615. private _uniformBuffersNames;
  88616. private _uniformsNames;
  88617. private _samplerList;
  88618. private _samplers;
  88619. private _isReady;
  88620. private _compilationError;
  88621. private _attributesNames;
  88622. private _attributes;
  88623. private _uniforms;
  88624. /**
  88625. * Key for the effect.
  88626. * @hidden
  88627. */
  88628. _key: string;
  88629. private _indexParameters;
  88630. private _fallbacks;
  88631. private _vertexSourceCode;
  88632. private _fragmentSourceCode;
  88633. private _vertexSourceCodeOverride;
  88634. private _fragmentSourceCodeOverride;
  88635. private _transformFeedbackVaryings;
  88636. /**
  88637. * Compiled shader to webGL program.
  88638. * @hidden
  88639. */
  88640. _program: WebGLProgram;
  88641. private _valueCache;
  88642. private static _baseCache;
  88643. /**
  88644. * Instantiates an effect.
  88645. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88646. * @param baseName Name of the effect.
  88647. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88648. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88649. * @param samplers List of sampler variables that will be passed to the shader.
  88650. * @param engine Engine to be used to render the effect
  88651. * @param defines Define statements to be added to the shader.
  88652. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88653. * @param onCompiled Callback that will be called when the shader is compiled.
  88654. * @param onError Callback that will be called if an error occurs during shader compilation.
  88655. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88656. */
  88657. 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);
  88658. /**
  88659. * Unique key for this effect
  88660. */
  88661. readonly key: string;
  88662. /**
  88663. * If the effect has been compiled and prepared.
  88664. * @returns if the effect is compiled and prepared.
  88665. */
  88666. isReady(): boolean;
  88667. /**
  88668. * The engine the effect was initialized with.
  88669. * @returns the engine.
  88670. */
  88671. getEngine(): Engine;
  88672. /**
  88673. * The compiled webGL program for the effect
  88674. * @returns the webGL program.
  88675. */
  88676. getProgram(): WebGLProgram;
  88677. /**
  88678. * The set of names of attribute variables for the shader.
  88679. * @returns An array of attribute names.
  88680. */
  88681. getAttributesNames(): string[];
  88682. /**
  88683. * Returns the attribute at the given index.
  88684. * @param index The index of the attribute.
  88685. * @returns The location of the attribute.
  88686. */
  88687. getAttributeLocation(index: number): number;
  88688. /**
  88689. * Returns the attribute based on the name of the variable.
  88690. * @param name of the attribute to look up.
  88691. * @returns the attribute location.
  88692. */
  88693. getAttributeLocationByName(name: string): number;
  88694. /**
  88695. * The number of attributes.
  88696. * @returns the numnber of attributes.
  88697. */
  88698. getAttributesCount(): number;
  88699. /**
  88700. * Gets the index of a uniform variable.
  88701. * @param uniformName of the uniform to look up.
  88702. * @returns the index.
  88703. */
  88704. getUniformIndex(uniformName: string): number;
  88705. /**
  88706. * Returns the attribute based on the name of the variable.
  88707. * @param uniformName of the uniform to look up.
  88708. * @returns the location of the uniform.
  88709. */
  88710. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88711. /**
  88712. * Returns an array of sampler variable names
  88713. * @returns The array of sampler variable neames.
  88714. */
  88715. getSamplers(): string[];
  88716. /**
  88717. * The error from the last compilation.
  88718. * @returns the error string.
  88719. */
  88720. getCompilationError(): string;
  88721. /**
  88722. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88723. * @param func The callback to be used.
  88724. */
  88725. executeWhenCompiled(func: (effect: Effect) => void): void;
  88726. private _checkIsReady;
  88727. /** @hidden */
  88728. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88729. /** @hidden */
  88730. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88731. /** @hidden */
  88732. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88733. private _processShaderConversion;
  88734. private _processIncludes;
  88735. private _processPrecision;
  88736. /**
  88737. * Recompiles the webGL program
  88738. * @param vertexSourceCode The source code for the vertex shader.
  88739. * @param fragmentSourceCode The source code for the fragment shader.
  88740. * @param onCompiled Callback called when completed.
  88741. * @param onError Callback called on error.
  88742. * @hidden
  88743. */
  88744. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  88745. /**
  88746. * Gets the uniform locations of the the specified variable names
  88747. * @param names THe names of the variables to lookup.
  88748. * @returns Array of locations in the same order as variable names.
  88749. */
  88750. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  88751. /**
  88752. * Prepares the effect
  88753. * @hidden
  88754. */
  88755. _prepareEffect(): void;
  88756. /**
  88757. * Checks if the effect is supported. (Must be called after compilation)
  88758. */
  88759. readonly isSupported: boolean;
  88760. /**
  88761. * Binds a texture to the engine to be used as output of the shader.
  88762. * @param channel Name of the output variable.
  88763. * @param texture Texture to bind.
  88764. * @hidden
  88765. */
  88766. _bindTexture(channel: string, texture: InternalTexture): void;
  88767. /**
  88768. * Sets a texture on the engine to be used in the shader.
  88769. * @param channel Name of the sampler variable.
  88770. * @param texture Texture to set.
  88771. */
  88772. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88773. /**
  88774. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88775. * @param channel Name of the sampler variable.
  88776. * @param texture Texture to set.
  88777. */
  88778. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88779. /**
  88780. * Sets an array of textures on the engine to be used in the shader.
  88781. * @param channel Name of the variable.
  88782. * @param textures Textures to set.
  88783. */
  88784. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88785. /**
  88786. * 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)
  88787. * @param channel Name of the sampler variable.
  88788. * @param postProcess Post process to get the input texture from.
  88789. */
  88790. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88791. /**
  88792. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88793. * 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)
  88794. * @param channel Name of the sampler variable.
  88795. * @param postProcess Post process to get the output texture from.
  88796. */
  88797. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88798. /** @hidden */
  88799. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88800. /** @hidden */
  88801. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88802. /** @hidden */
  88803. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88804. /** @hidden */
  88805. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88806. /**
  88807. * Binds a buffer to a uniform.
  88808. * @param buffer Buffer to bind.
  88809. * @param name Name of the uniform variable to bind to.
  88810. */
  88811. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  88812. /**
  88813. * Binds block to a uniform.
  88814. * @param blockName Name of the block to bind.
  88815. * @param index Index to bind.
  88816. */
  88817. bindUniformBlock(blockName: string, index: number): void;
  88818. /**
  88819. * Sets an interger value on a uniform variable.
  88820. * @param uniformName Name of the variable.
  88821. * @param value Value to be set.
  88822. * @returns this effect.
  88823. */
  88824. setInt(uniformName: string, value: number): Effect;
  88825. /**
  88826. * Sets an int array on a uniform variable.
  88827. * @param uniformName Name of the variable.
  88828. * @param array array to be set.
  88829. * @returns this effect.
  88830. */
  88831. setIntArray(uniformName: string, array: Int32Array): Effect;
  88832. /**
  88833. * 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)
  88834. * @param uniformName Name of the variable.
  88835. * @param array array to be set.
  88836. * @returns this effect.
  88837. */
  88838. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88839. /**
  88840. * 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)
  88841. * @param uniformName Name of the variable.
  88842. * @param array array to be set.
  88843. * @returns this effect.
  88844. */
  88845. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88846. /**
  88847. * 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)
  88848. * @param uniformName Name of the variable.
  88849. * @param array array to be set.
  88850. * @returns this effect.
  88851. */
  88852. setIntArray4(uniformName: string, array: Int32Array): Effect;
  88853. /**
  88854. * Sets an float array on a uniform variable.
  88855. * @param uniformName Name of the variable.
  88856. * @param array array to be set.
  88857. * @returns this effect.
  88858. */
  88859. setFloatArray(uniformName: string, array: Float32Array): Effect;
  88860. /**
  88861. * 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)
  88862. * @param uniformName Name of the variable.
  88863. * @param array array to be set.
  88864. * @returns this effect.
  88865. */
  88866. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  88867. /**
  88868. * 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)
  88869. * @param uniformName Name of the variable.
  88870. * @param array array to be set.
  88871. * @returns this effect.
  88872. */
  88873. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  88874. /**
  88875. * 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)
  88876. * @param uniformName Name of the variable.
  88877. * @param array array to be set.
  88878. * @returns this effect.
  88879. */
  88880. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  88881. /**
  88882. * Sets an array on a uniform variable.
  88883. * @param uniformName Name of the variable.
  88884. * @param array array to be set.
  88885. * @returns this effect.
  88886. */
  88887. setArray(uniformName: string, array: number[]): Effect;
  88888. /**
  88889. * 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)
  88890. * @param uniformName Name of the variable.
  88891. * @param array array to be set.
  88892. * @returns this effect.
  88893. */
  88894. setArray2(uniformName: string, array: number[]): Effect;
  88895. /**
  88896. * 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)
  88897. * @param uniformName Name of the variable.
  88898. * @param array array to be set.
  88899. * @returns this effect.
  88900. */
  88901. setArray3(uniformName: string, array: number[]): Effect;
  88902. /**
  88903. * 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)
  88904. * @param uniformName Name of the variable.
  88905. * @param array array to be set.
  88906. * @returns this effect.
  88907. */
  88908. setArray4(uniformName: string, array: number[]): Effect;
  88909. /**
  88910. * Sets matrices on a uniform variable.
  88911. * @param uniformName Name of the variable.
  88912. * @param matrices matrices to be set.
  88913. * @returns this effect.
  88914. */
  88915. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  88916. /**
  88917. * Sets matrix on a uniform variable.
  88918. * @param uniformName Name of the variable.
  88919. * @param matrix matrix to be set.
  88920. * @returns this effect.
  88921. */
  88922. setMatrix(uniformName: string, matrix: Matrix): Effect;
  88923. /**
  88924. * 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)
  88925. * @param uniformName Name of the variable.
  88926. * @param matrix matrix to be set.
  88927. * @returns this effect.
  88928. */
  88929. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  88930. /**
  88931. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  88932. * @param uniformName Name of the variable.
  88933. * @param matrix matrix to be set.
  88934. * @returns this effect.
  88935. */
  88936. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  88937. /**
  88938. * Sets a float on a uniform variable.
  88939. * @param uniformName Name of the variable.
  88940. * @param value value to be set.
  88941. * @returns this effect.
  88942. */
  88943. setFloat(uniformName: string, value: number): Effect;
  88944. /**
  88945. * Sets a boolean on a uniform variable.
  88946. * @param uniformName Name of the variable.
  88947. * @param bool value to be set.
  88948. * @returns this effect.
  88949. */
  88950. setBool(uniformName: string, bool: boolean): Effect;
  88951. /**
  88952. * Sets a Vector2 on a uniform variable.
  88953. * @param uniformName Name of the variable.
  88954. * @param vector2 vector2 to be set.
  88955. * @returns this effect.
  88956. */
  88957. setVector2(uniformName: string, vector2: Vector2): Effect;
  88958. /**
  88959. * Sets a float2 on a uniform variable.
  88960. * @param uniformName Name of the variable.
  88961. * @param x First float in float2.
  88962. * @param y Second float in float2.
  88963. * @returns this effect.
  88964. */
  88965. setFloat2(uniformName: string, x: number, y: number): Effect;
  88966. /**
  88967. * Sets a Vector3 on a uniform variable.
  88968. * @param uniformName Name of the variable.
  88969. * @param vector3 Value to be set.
  88970. * @returns this effect.
  88971. */
  88972. setVector3(uniformName: string, vector3: Vector3): Effect;
  88973. /**
  88974. * Sets a float3 on a uniform variable.
  88975. * @param uniformName Name of the variable.
  88976. * @param x First float in float3.
  88977. * @param y Second float in float3.
  88978. * @param z Third float in float3.
  88979. * @returns this effect.
  88980. */
  88981. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88982. /**
  88983. * Sets a Vector4 on a uniform variable.
  88984. * @param uniformName Name of the variable.
  88985. * @param vector4 Value to be set.
  88986. * @returns this effect.
  88987. */
  88988. setVector4(uniformName: string, vector4: Vector4): Effect;
  88989. /**
  88990. * Sets a float4 on a uniform variable.
  88991. * @param uniformName Name of the variable.
  88992. * @param x First float in float4.
  88993. * @param y Second float in float4.
  88994. * @param z Third float in float4.
  88995. * @param w Fourth float in float4.
  88996. * @returns this effect.
  88997. */
  88998. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88999. /**
  89000. * Sets a Color3 on a uniform variable.
  89001. * @param uniformName Name of the variable.
  89002. * @param color3 Value to be set.
  89003. * @returns this effect.
  89004. */
  89005. setColor3(uniformName: string, color3: Color3): Effect;
  89006. /**
  89007. * Sets a Color4 on a uniform variable.
  89008. * @param uniformName Name of the variable.
  89009. * @param color3 Value to be set.
  89010. * @param alpha Alpha value to be set.
  89011. * @returns this effect.
  89012. */
  89013. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89014. /**
  89015. * Sets a Color4 on a uniform variable
  89016. * @param uniformName defines the name of the variable
  89017. * @param color4 defines the value to be set
  89018. * @returns this effect.
  89019. */
  89020. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89021. /** Release all associated resources */
  89022. dispose(): void;
  89023. /**
  89024. * This function will add a new shader to the shader store
  89025. * @param name the name of the shader
  89026. * @param pixelShader optional pixel shader content
  89027. * @param vertexShader optional vertex shader content
  89028. */
  89029. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89030. /**
  89031. * Store of each shader (The can be looked up using effect.key)
  89032. */
  89033. static ShadersStore: {
  89034. [key: string]: string;
  89035. };
  89036. /**
  89037. * Store of each included file for a shader (The can be looked up using effect.key)
  89038. */
  89039. static IncludesShadersStore: {
  89040. [key: string]: string;
  89041. };
  89042. /**
  89043. * Resets the cache of effects.
  89044. */
  89045. static ResetCache(): void;
  89046. }
  89047. }
  89048. declare module BABYLON {
  89049. /**
  89050. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89051. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89052. * 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;
  89053. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89054. */
  89055. export class ColorCurves {
  89056. private _dirty;
  89057. private _tempColor;
  89058. private _globalCurve;
  89059. private _highlightsCurve;
  89060. private _midtonesCurve;
  89061. private _shadowsCurve;
  89062. private _positiveCurve;
  89063. private _negativeCurve;
  89064. private _globalHue;
  89065. private _globalDensity;
  89066. private _globalSaturation;
  89067. private _globalExposure;
  89068. /**
  89069. * Gets the global Hue value.
  89070. * 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).
  89071. */
  89072. /**
  89073. * Sets the global Hue value.
  89074. * 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).
  89075. */
  89076. globalHue: number;
  89077. /**
  89078. * Gets the global Density value.
  89079. * 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.
  89080. * Values less than zero provide a filter of opposite hue.
  89081. */
  89082. /**
  89083. * Sets the global Density value.
  89084. * 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.
  89085. * Values less than zero provide a filter of opposite hue.
  89086. */
  89087. globalDensity: number;
  89088. /**
  89089. * Gets the global Saturation value.
  89090. * 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.
  89091. */
  89092. /**
  89093. * Sets the global Saturation value.
  89094. * 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.
  89095. */
  89096. globalSaturation: number;
  89097. /**
  89098. * Gets the global Exposure value.
  89099. * 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.
  89100. */
  89101. /**
  89102. * Sets the global Exposure value.
  89103. * 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.
  89104. */
  89105. globalExposure: number;
  89106. private _highlightsHue;
  89107. private _highlightsDensity;
  89108. private _highlightsSaturation;
  89109. private _highlightsExposure;
  89110. /**
  89111. * Gets the highlights Hue value.
  89112. * 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).
  89113. */
  89114. /**
  89115. * Sets the highlights Hue value.
  89116. * 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).
  89117. */
  89118. highlightsHue: number;
  89119. /**
  89120. * Gets the highlights Density value.
  89121. * 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.
  89122. * Values less than zero provide a filter of opposite hue.
  89123. */
  89124. /**
  89125. * Sets the highlights Density value.
  89126. * 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.
  89127. * Values less than zero provide a filter of opposite hue.
  89128. */
  89129. highlightsDensity: number;
  89130. /**
  89131. * Gets the highlights Saturation value.
  89132. * 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.
  89133. */
  89134. /**
  89135. * Sets the highlights Saturation value.
  89136. * 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.
  89137. */
  89138. highlightsSaturation: number;
  89139. /**
  89140. * Gets the highlights Exposure value.
  89141. * 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.
  89142. */
  89143. /**
  89144. * Sets the highlights Exposure value.
  89145. * 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.
  89146. */
  89147. highlightsExposure: number;
  89148. private _midtonesHue;
  89149. private _midtonesDensity;
  89150. private _midtonesSaturation;
  89151. private _midtonesExposure;
  89152. /**
  89153. * Gets the midtones Hue value.
  89154. * 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).
  89155. */
  89156. /**
  89157. * Sets the midtones Hue value.
  89158. * 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).
  89159. */
  89160. midtonesHue: number;
  89161. /**
  89162. * Gets the midtones Density value.
  89163. * 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.
  89164. * Values less than zero provide a filter of opposite hue.
  89165. */
  89166. /**
  89167. * Sets the midtones Density value.
  89168. * 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.
  89169. * Values less than zero provide a filter of opposite hue.
  89170. */
  89171. midtonesDensity: number;
  89172. /**
  89173. * Gets the midtones Saturation value.
  89174. * 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.
  89175. */
  89176. /**
  89177. * Sets the midtones Saturation value.
  89178. * 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.
  89179. */
  89180. midtonesSaturation: number;
  89181. /**
  89182. * Gets the midtones Exposure value.
  89183. * 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.
  89184. */
  89185. /**
  89186. * Sets the midtones Exposure value.
  89187. * 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.
  89188. */
  89189. midtonesExposure: number;
  89190. private _shadowsHue;
  89191. private _shadowsDensity;
  89192. private _shadowsSaturation;
  89193. private _shadowsExposure;
  89194. /**
  89195. * Gets the shadows Hue value.
  89196. * 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).
  89197. */
  89198. /**
  89199. * Sets the shadows Hue value.
  89200. * 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).
  89201. */
  89202. shadowsHue: number;
  89203. /**
  89204. * Gets the shadows Density value.
  89205. * 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.
  89206. * Values less than zero provide a filter of opposite hue.
  89207. */
  89208. /**
  89209. * Sets the shadows Density value.
  89210. * 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.
  89211. * Values less than zero provide a filter of opposite hue.
  89212. */
  89213. shadowsDensity: number;
  89214. /**
  89215. * Gets the shadows Saturation value.
  89216. * 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.
  89217. */
  89218. /**
  89219. * Sets the shadows Saturation value.
  89220. * 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.
  89221. */
  89222. shadowsSaturation: number;
  89223. /**
  89224. * Gets the shadows Exposure value.
  89225. * 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.
  89226. */
  89227. /**
  89228. * Sets the shadows Exposure value.
  89229. * 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.
  89230. */
  89231. shadowsExposure: number;
  89232. /**
  89233. * Returns the class name
  89234. * @returns The class name
  89235. */
  89236. getClassName(): string;
  89237. /**
  89238. * Binds the color curves to the shader.
  89239. * @param colorCurves The color curve to bind
  89240. * @param effect The effect to bind to
  89241. * @param positiveUniform The positive uniform shader parameter
  89242. * @param neutralUniform The neutral uniform shader parameter
  89243. * @param negativeUniform The negative uniform shader parameter
  89244. */
  89245. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89246. /**
  89247. * Prepare the list of uniforms associated with the ColorCurves effects.
  89248. * @param uniformsList The list of uniforms used in the effect
  89249. */
  89250. static PrepareUniforms(uniformsList: string[]): void;
  89251. /**
  89252. * Returns color grading data based on a hue, density, saturation and exposure value.
  89253. * @param filterHue The hue of the color filter.
  89254. * @param filterDensity The density of the color filter.
  89255. * @param saturation The saturation.
  89256. * @param exposure The exposure.
  89257. * @param result The result data container.
  89258. */
  89259. private getColorGradingDataToRef;
  89260. /**
  89261. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89262. * @param value The input slider value in range [-100,100].
  89263. * @returns Adjusted value.
  89264. */
  89265. private static applyColorGradingSliderNonlinear;
  89266. /**
  89267. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89268. * @param hue The hue (H) input.
  89269. * @param saturation The saturation (S) input.
  89270. * @param brightness The brightness (B) input.
  89271. * @result An RGBA color represented as Vector4.
  89272. */
  89273. private static fromHSBToRef;
  89274. /**
  89275. * Returns a value clamped between min and max
  89276. * @param value The value to clamp
  89277. * @param min The minimum of value
  89278. * @param max The maximum of value
  89279. * @returns The clamped value.
  89280. */
  89281. private static clamp;
  89282. /**
  89283. * Clones the current color curve instance.
  89284. * @return The cloned curves
  89285. */
  89286. clone(): ColorCurves;
  89287. /**
  89288. * Serializes the current color curve instance to a json representation.
  89289. * @return a JSON representation
  89290. */
  89291. serialize(): any;
  89292. /**
  89293. * Parses the color curve from a json representation.
  89294. * @param source the JSON source to parse
  89295. * @return The parsed curves
  89296. */
  89297. static Parse(source: any): ColorCurves;
  89298. }
  89299. }
  89300. declare module BABYLON {
  89301. /**
  89302. * Interface to follow in your material defines to integrate easily the
  89303. * Image proccessing functions.
  89304. * @hidden
  89305. */
  89306. export interface IImageProcessingConfigurationDefines {
  89307. IMAGEPROCESSING: boolean;
  89308. VIGNETTE: boolean;
  89309. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89310. VIGNETTEBLENDMODEOPAQUE: boolean;
  89311. TONEMAPPING: boolean;
  89312. TONEMAPPING_ACES: boolean;
  89313. CONTRAST: boolean;
  89314. EXPOSURE: boolean;
  89315. COLORCURVES: boolean;
  89316. COLORGRADING: boolean;
  89317. COLORGRADING3D: boolean;
  89318. SAMPLER3DGREENDEPTH: boolean;
  89319. SAMPLER3DBGRMAP: boolean;
  89320. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89321. }
  89322. /**
  89323. * @hidden
  89324. */
  89325. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89326. IMAGEPROCESSING: boolean;
  89327. VIGNETTE: boolean;
  89328. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89329. VIGNETTEBLENDMODEOPAQUE: boolean;
  89330. TONEMAPPING: boolean;
  89331. TONEMAPPING_ACES: boolean;
  89332. CONTRAST: boolean;
  89333. COLORCURVES: boolean;
  89334. COLORGRADING: boolean;
  89335. COLORGRADING3D: boolean;
  89336. SAMPLER3DGREENDEPTH: boolean;
  89337. SAMPLER3DBGRMAP: boolean;
  89338. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89339. EXPOSURE: boolean;
  89340. constructor();
  89341. }
  89342. /**
  89343. * This groups together the common properties used for image processing either in direct forward pass
  89344. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89345. * or not.
  89346. */
  89347. export class ImageProcessingConfiguration {
  89348. /**
  89349. * Default tone mapping applied in BabylonJS.
  89350. */
  89351. static readonly TONEMAPPING_STANDARD: number;
  89352. /**
  89353. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89354. * to other engines rendering to increase portability.
  89355. */
  89356. static readonly TONEMAPPING_ACES: number;
  89357. /**
  89358. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89359. */
  89360. colorCurves: Nullable<ColorCurves>;
  89361. private _colorCurvesEnabled;
  89362. /**
  89363. * Gets wether the color curves effect is enabled.
  89364. */
  89365. /**
  89366. * Sets wether the color curves effect is enabled.
  89367. */
  89368. colorCurvesEnabled: boolean;
  89369. private _colorGradingTexture;
  89370. /**
  89371. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89372. */
  89373. /**
  89374. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89375. */
  89376. colorGradingTexture: Nullable<BaseTexture>;
  89377. private _colorGradingEnabled;
  89378. /**
  89379. * Gets wether the color grading effect is enabled.
  89380. */
  89381. /**
  89382. * Sets wether the color grading effect is enabled.
  89383. */
  89384. colorGradingEnabled: boolean;
  89385. private _colorGradingWithGreenDepth;
  89386. /**
  89387. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89388. */
  89389. /**
  89390. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89391. */
  89392. colorGradingWithGreenDepth: boolean;
  89393. private _colorGradingBGR;
  89394. /**
  89395. * Gets wether the color grading texture contains BGR values.
  89396. */
  89397. /**
  89398. * Sets wether the color grading texture contains BGR values.
  89399. */
  89400. colorGradingBGR: boolean;
  89401. /** @hidden */
  89402. _exposure: number;
  89403. /**
  89404. * Gets the Exposure used in the effect.
  89405. */
  89406. /**
  89407. * Sets the Exposure used in the effect.
  89408. */
  89409. exposure: number;
  89410. private _toneMappingEnabled;
  89411. /**
  89412. * Gets wether the tone mapping effect is enabled.
  89413. */
  89414. /**
  89415. * Sets wether the tone mapping effect is enabled.
  89416. */
  89417. toneMappingEnabled: boolean;
  89418. private _toneMappingType;
  89419. /**
  89420. * Gets the type of tone mapping effect.
  89421. */
  89422. /**
  89423. * Sets the type of tone mapping effect used in BabylonJS.
  89424. */
  89425. toneMappingType: number;
  89426. protected _contrast: number;
  89427. /**
  89428. * Gets the contrast used in the effect.
  89429. */
  89430. /**
  89431. * Sets the contrast used in the effect.
  89432. */
  89433. contrast: number;
  89434. /**
  89435. * Vignette stretch size.
  89436. */
  89437. vignetteStretch: number;
  89438. /**
  89439. * Vignette centre X Offset.
  89440. */
  89441. vignetteCentreX: number;
  89442. /**
  89443. * Vignette centre Y Offset.
  89444. */
  89445. vignetteCentreY: number;
  89446. /**
  89447. * Vignette weight or intensity of the vignette effect.
  89448. */
  89449. vignetteWeight: number;
  89450. /**
  89451. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89452. * if vignetteEnabled is set to true.
  89453. */
  89454. vignetteColor: Color4;
  89455. /**
  89456. * Camera field of view used by the Vignette effect.
  89457. */
  89458. vignetteCameraFov: number;
  89459. private _vignetteBlendMode;
  89460. /**
  89461. * Gets the vignette blend mode allowing different kind of effect.
  89462. */
  89463. /**
  89464. * Sets the vignette blend mode allowing different kind of effect.
  89465. */
  89466. vignetteBlendMode: number;
  89467. private _vignetteEnabled;
  89468. /**
  89469. * Gets wether the vignette effect is enabled.
  89470. */
  89471. /**
  89472. * Sets wether the vignette effect is enabled.
  89473. */
  89474. vignetteEnabled: boolean;
  89475. private _applyByPostProcess;
  89476. /**
  89477. * Gets wether the image processing is applied through a post process or not.
  89478. */
  89479. /**
  89480. * Sets wether the image processing is applied through a post process or not.
  89481. */
  89482. applyByPostProcess: boolean;
  89483. private _isEnabled;
  89484. /**
  89485. * Gets wether the image processing is enabled or not.
  89486. */
  89487. /**
  89488. * Sets wether the image processing is enabled or not.
  89489. */
  89490. isEnabled: boolean;
  89491. /**
  89492. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89493. */
  89494. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89495. /**
  89496. * Method called each time the image processing information changes requires to recompile the effect.
  89497. */
  89498. protected _updateParameters(): void;
  89499. /**
  89500. * Gets the current class name.
  89501. * @return "ImageProcessingConfiguration"
  89502. */
  89503. getClassName(): string;
  89504. /**
  89505. * Prepare the list of uniforms associated with the Image Processing effects.
  89506. * @param uniforms The list of uniforms used in the effect
  89507. * @param defines the list of defines currently in use
  89508. */
  89509. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89510. /**
  89511. * Prepare the list of samplers associated with the Image Processing effects.
  89512. * @param samplersList The list of uniforms used in the effect
  89513. * @param defines the list of defines currently in use
  89514. */
  89515. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89516. /**
  89517. * Prepare the list of defines associated to the shader.
  89518. * @param defines the list of defines to complete
  89519. * @param forPostProcess Define if we are currently in post process mode or not
  89520. */
  89521. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89522. /**
  89523. * Returns true if all the image processing information are ready.
  89524. * @returns True if ready, otherwise, false
  89525. */
  89526. isReady(): boolean;
  89527. /**
  89528. * Binds the image processing to the shader.
  89529. * @param effect The effect to bind to
  89530. * @param aspectRatio Define the current aspect ratio of the effect
  89531. */
  89532. bind(effect: Effect, aspectRatio?: number): void;
  89533. /**
  89534. * Clones the current image processing instance.
  89535. * @return The cloned image processing
  89536. */
  89537. clone(): ImageProcessingConfiguration;
  89538. /**
  89539. * Serializes the current image processing instance to a json representation.
  89540. * @return a JSON representation
  89541. */
  89542. serialize(): any;
  89543. /**
  89544. * Parses the image processing from a json representation.
  89545. * @param source the JSON source to parse
  89546. * @return The parsed image processing
  89547. */
  89548. static Parse(source: any): ImageProcessingConfiguration;
  89549. private static _VIGNETTEMODE_MULTIPLY;
  89550. private static _VIGNETTEMODE_OPAQUE;
  89551. /**
  89552. * Used to apply the vignette as a mix with the pixel color.
  89553. */
  89554. static readonly VIGNETTEMODE_MULTIPLY: number;
  89555. /**
  89556. * Used to apply the vignette as a replacement of the pixel color.
  89557. */
  89558. static readonly VIGNETTEMODE_OPAQUE: number;
  89559. }
  89560. }
  89561. declare module BABYLON {
  89562. /**
  89563. * This represents all the required information to add a fresnel effect on a material:
  89564. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89565. */
  89566. export class FresnelParameters {
  89567. private _isEnabled;
  89568. /**
  89569. * Define if the fresnel effect is enable or not.
  89570. */
  89571. isEnabled: boolean;
  89572. /**
  89573. * Define the color used on edges (grazing angle)
  89574. */
  89575. leftColor: Color3;
  89576. /**
  89577. * Define the color used on center
  89578. */
  89579. rightColor: Color3;
  89580. /**
  89581. * Define bias applied to computed fresnel term
  89582. */
  89583. bias: number;
  89584. /**
  89585. * Defined the power exponent applied to fresnel term
  89586. */
  89587. power: number;
  89588. /**
  89589. * Clones the current fresnel and its valuues
  89590. * @returns a clone fresnel configuration
  89591. */
  89592. clone(): FresnelParameters;
  89593. /**
  89594. * Serializes the current fresnel parameters to a JSON representation.
  89595. * @return the JSON serialization
  89596. */
  89597. serialize(): any;
  89598. /**
  89599. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89600. * @param parsedFresnelParameters Define the JSON representation
  89601. * @returns the parsed parameters
  89602. */
  89603. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89604. }
  89605. }
  89606. declare module BABYLON {
  89607. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89608. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89609. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89610. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89611. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89612. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89613. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89614. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89615. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89616. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89617. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89618. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89619. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89620. /**
  89621. * Decorator used to define property that can be serialized as reference to a camera
  89622. * @param sourceName defines the name of the property to decorate
  89623. */
  89624. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89625. /**
  89626. * Class used to help serialization objects
  89627. */
  89628. export class SerializationHelper {
  89629. /** hidden */
  89630. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89631. /** hidden */
  89632. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89633. /** hidden */
  89634. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89635. /** hidden */
  89636. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89637. /**
  89638. * Appends the serialized animations from the source animations
  89639. * @param source Source containing the animations
  89640. * @param destination Target to store the animations
  89641. */
  89642. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89643. /**
  89644. * Static function used to serialized a specific entity
  89645. * @param entity defines the entity to serialize
  89646. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89647. * @returns a JSON compatible object representing the serialization of the entity
  89648. */
  89649. static Serialize<T>(entity: T, serializationObject?: any): any;
  89650. /**
  89651. * Creates a new entity from a serialization data object
  89652. * @param creationFunction defines a function used to instanciated the new entity
  89653. * @param source defines the source serialization data
  89654. * @param scene defines the hosting scene
  89655. * @param rootUrl defines the root url for resources
  89656. * @returns a new entity
  89657. */
  89658. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89659. /**
  89660. * Clones an object
  89661. * @param creationFunction defines the function used to instanciate the new object
  89662. * @param source defines the source object
  89663. * @returns the cloned object
  89664. */
  89665. static Clone<T>(creationFunction: () => T, source: T): T;
  89666. /**
  89667. * Instanciates a new object based on a source one (some data will be shared between both object)
  89668. * @param creationFunction defines the function used to instanciate the new object
  89669. * @param source defines the source object
  89670. * @returns the new object
  89671. */
  89672. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89673. }
  89674. }
  89675. declare module BABYLON {
  89676. /**
  89677. * This is the base class of all the camera used in the application.
  89678. * @see http://doc.babylonjs.com/features/cameras
  89679. */
  89680. export class Camera extends Node {
  89681. /** @hidden */
  89682. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89683. /**
  89684. * This is the default projection mode used by the cameras.
  89685. * It helps recreating a feeling of perspective and better appreciate depth.
  89686. * This is the best way to simulate real life cameras.
  89687. */
  89688. static readonly PERSPECTIVE_CAMERA: number;
  89689. /**
  89690. * This helps creating camera with an orthographic mode.
  89691. * 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.
  89692. */
  89693. static readonly ORTHOGRAPHIC_CAMERA: number;
  89694. /**
  89695. * This is the default FOV mode for perspective cameras.
  89696. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89697. */
  89698. static readonly FOVMODE_VERTICAL_FIXED: number;
  89699. /**
  89700. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89701. */
  89702. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89703. /**
  89704. * This specifies ther is no need for a camera rig.
  89705. * Basically only one eye is rendered corresponding to the camera.
  89706. */
  89707. static readonly RIG_MODE_NONE: number;
  89708. /**
  89709. * Simulates a camera Rig with one blue eye and one red eye.
  89710. * This can be use with 3d blue and red glasses.
  89711. */
  89712. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89713. /**
  89714. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89715. */
  89716. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89717. /**
  89718. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89719. */
  89720. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89721. /**
  89722. * Defines that both eyes of the camera will be rendered over under each other.
  89723. */
  89724. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89725. /**
  89726. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89727. */
  89728. static readonly RIG_MODE_VR: number;
  89729. /**
  89730. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89731. */
  89732. static readonly RIG_MODE_WEBVR: number;
  89733. /**
  89734. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89735. */
  89736. static readonly RIG_MODE_CUSTOM: number;
  89737. /**
  89738. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89739. */
  89740. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89741. /**
  89742. * Define the input manager associated with the camera.
  89743. */
  89744. inputs: CameraInputsManager<Camera>;
  89745. /** @hidden */
  89746. _position: Vector3;
  89747. /**
  89748. * Define the current local position of the camera in the scene
  89749. */
  89750. position: Vector3;
  89751. /**
  89752. * The vector the camera should consider as up.
  89753. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89754. */
  89755. upVector: Vector3;
  89756. /**
  89757. * Define the current limit on the left side for an orthographic camera
  89758. * In scene unit
  89759. */
  89760. orthoLeft: Nullable<number>;
  89761. /**
  89762. * Define the current limit on the right side for an orthographic camera
  89763. * In scene unit
  89764. */
  89765. orthoRight: Nullable<number>;
  89766. /**
  89767. * Define the current limit on the bottom side for an orthographic camera
  89768. * In scene unit
  89769. */
  89770. orthoBottom: Nullable<number>;
  89771. /**
  89772. * Define the current limit on the top side for an orthographic camera
  89773. * In scene unit
  89774. */
  89775. orthoTop: Nullable<number>;
  89776. /**
  89777. * Field Of View is set in Radians. (default is 0.8)
  89778. */
  89779. fov: number;
  89780. /**
  89781. * Define the minimum distance the camera can see from.
  89782. * This is important to note that the depth buffer are not infinite and the closer it starts
  89783. * the more your scene might encounter depth fighting issue.
  89784. */
  89785. minZ: number;
  89786. /**
  89787. * Define the maximum distance the camera can see to.
  89788. * This is important to note that the depth buffer are not infinite and the further it end
  89789. * the more your scene might encounter depth fighting issue.
  89790. */
  89791. maxZ: number;
  89792. /**
  89793. * Define the default inertia of the camera.
  89794. * This helps giving a smooth feeling to the camera movement.
  89795. */
  89796. inertia: number;
  89797. /**
  89798. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89799. */
  89800. mode: number;
  89801. /**
  89802. * Define wether the camera is intermediate.
  89803. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89804. */
  89805. isIntermediate: boolean;
  89806. /**
  89807. * Define the viewport of the camera.
  89808. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89809. */
  89810. viewport: Viewport;
  89811. /**
  89812. * Restricts the camera to viewing objects with the same layerMask.
  89813. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89814. */
  89815. layerMask: number;
  89816. /**
  89817. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89818. */
  89819. fovMode: number;
  89820. /**
  89821. * Rig mode of the camera.
  89822. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89823. * This is normally controlled byt the camera themselves as internal use.
  89824. */
  89825. cameraRigMode: number;
  89826. /**
  89827. * Defines the distance between both "eyes" in case of a RIG
  89828. */
  89829. interaxialDistance: number;
  89830. /**
  89831. * Defines if stereoscopic rendering is done side by side or over under.
  89832. */
  89833. isStereoscopicSideBySide: boolean;
  89834. /**
  89835. * 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
  89836. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89837. * else in the scene.
  89838. */
  89839. customRenderTargets: RenderTargetTexture[];
  89840. /**
  89841. * When set, the camera will render to this render target instead of the default canvas
  89842. */
  89843. outputRenderTarget: Nullable<RenderTargetTexture>;
  89844. /**
  89845. * Observable triggered when the camera view matrix has changed.
  89846. */
  89847. onViewMatrixChangedObservable: Observable<Camera>;
  89848. /**
  89849. * Observable triggered when the camera Projection matrix has changed.
  89850. */
  89851. onProjectionMatrixChangedObservable: Observable<Camera>;
  89852. /**
  89853. * Observable triggered when the inputs have been processed.
  89854. */
  89855. onAfterCheckInputsObservable: Observable<Camera>;
  89856. /**
  89857. * Observable triggered when reset has been called and applied to the camera.
  89858. */
  89859. onRestoreStateObservable: Observable<Camera>;
  89860. /** @hidden */
  89861. _cameraRigParams: any;
  89862. /** @hidden */
  89863. _rigCameras: Camera[];
  89864. /** @hidden */
  89865. _rigPostProcess: Nullable<PostProcess>;
  89866. protected _webvrViewMatrix: Matrix;
  89867. /** @hidden */
  89868. _skipRendering: boolean;
  89869. /** @hidden */
  89870. _projectionMatrix: Matrix;
  89871. /** @hidden */
  89872. _postProcesses: Nullable<PostProcess>[];
  89873. /** @hidden */
  89874. _activeMeshes: SmartArray<AbstractMesh>;
  89875. protected _globalPosition: Vector3;
  89876. /** hidden */
  89877. _computedViewMatrix: Matrix;
  89878. private _doNotComputeProjectionMatrix;
  89879. private _transformMatrix;
  89880. private _frustumPlanes;
  89881. private _refreshFrustumPlanes;
  89882. private _storedFov;
  89883. private _stateStored;
  89884. /**
  89885. * Instantiates a new camera object.
  89886. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89887. * @see http://doc.babylonjs.com/features/cameras
  89888. * @param name Defines the name of the camera in the scene
  89889. * @param position Defines the position of the camera
  89890. * @param scene Defines the scene the camera belongs too
  89891. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89892. */
  89893. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89894. /**
  89895. * Store current camera state (fov, position, etc..)
  89896. * @returns the camera
  89897. */
  89898. storeState(): Camera;
  89899. /**
  89900. * Restores the camera state values if it has been stored. You must call storeState() first
  89901. */
  89902. protected _restoreStateValues(): boolean;
  89903. /**
  89904. * Restored camera state. You must call storeState() first.
  89905. * @returns true if restored and false otherwise
  89906. */
  89907. restoreState(): boolean;
  89908. /**
  89909. * Gets the class name of the camera.
  89910. * @returns the class name
  89911. */
  89912. getClassName(): string;
  89913. /** @hidden */
  89914. readonly _isCamera: boolean;
  89915. /**
  89916. * Gets a string representation of the camera useful for debug purpose.
  89917. * @param fullDetails Defines that a more verboe level of logging is required
  89918. * @returns the string representation
  89919. */
  89920. toString(fullDetails?: boolean): string;
  89921. /**
  89922. * Gets the current world space position of the camera.
  89923. */
  89924. readonly globalPosition: Vector3;
  89925. /**
  89926. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89927. * @returns the active meshe list
  89928. */
  89929. getActiveMeshes(): SmartArray<AbstractMesh>;
  89930. /**
  89931. * Check wether a mesh is part of the current active mesh list of the camera
  89932. * @param mesh Defines the mesh to check
  89933. * @returns true if active, false otherwise
  89934. */
  89935. isActiveMesh(mesh: Mesh): boolean;
  89936. /**
  89937. * Is this camera ready to be used/rendered
  89938. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89939. * @return true if the camera is ready
  89940. */
  89941. isReady(completeCheck?: boolean): boolean;
  89942. /** @hidden */
  89943. _initCache(): void;
  89944. /** @hidden */
  89945. _updateCache(ignoreParentClass?: boolean): void;
  89946. /** @hidden */
  89947. _isSynchronized(): boolean;
  89948. /** @hidden */
  89949. _isSynchronizedViewMatrix(): boolean;
  89950. /** @hidden */
  89951. _isSynchronizedProjectionMatrix(): boolean;
  89952. /**
  89953. * Attach the input controls to a specific dom element to get the input from.
  89954. * @param element Defines the element the controls should be listened from
  89955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89956. */
  89957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89958. /**
  89959. * Detach the current controls from the specified dom element.
  89960. * @param element Defines the element to stop listening the inputs from
  89961. */
  89962. detachControl(element: HTMLElement): void;
  89963. /**
  89964. * Update the camera state according to the different inputs gathered during the frame.
  89965. */
  89966. update(): void;
  89967. /** @hidden */
  89968. _checkInputs(): void;
  89969. /** @hidden */
  89970. readonly rigCameras: Camera[];
  89971. /**
  89972. * Gets the post process used by the rig cameras
  89973. */
  89974. readonly rigPostProcess: Nullable<PostProcess>;
  89975. /**
  89976. * Internal, gets the first post proces.
  89977. * @returns the first post process to be run on this camera.
  89978. */
  89979. _getFirstPostProcess(): Nullable<PostProcess>;
  89980. private _cascadePostProcessesToRigCams;
  89981. /**
  89982. * Attach a post process to the camera.
  89983. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89984. * @param postProcess The post process to attach to the camera
  89985. * @param insertAt The position of the post process in case several of them are in use in the scene
  89986. * @returns the position the post process has been inserted at
  89987. */
  89988. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89989. /**
  89990. * Detach a post process to the camera.
  89991. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89992. * @param postProcess The post process to detach from the camera
  89993. */
  89994. detachPostProcess(postProcess: PostProcess): void;
  89995. /**
  89996. * Gets the current world matrix of the camera
  89997. */
  89998. getWorldMatrix(): Matrix;
  89999. /** @hidden */
  90000. _getViewMatrix(): Matrix;
  90001. /**
  90002. * Gets the current view matrix of the camera.
  90003. * @param force forces the camera to recompute the matrix without looking at the cached state
  90004. * @returns the view matrix
  90005. */
  90006. getViewMatrix(force?: boolean): Matrix;
  90007. /**
  90008. * Freeze the projection matrix.
  90009. * It will prevent the cache check of the camera projection compute and can speed up perf
  90010. * if no parameter of the camera are meant to change
  90011. * @param projection Defines manually a projection if necessary
  90012. */
  90013. freezeProjectionMatrix(projection?: Matrix): void;
  90014. /**
  90015. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90016. */
  90017. unfreezeProjectionMatrix(): void;
  90018. /**
  90019. * Gets the current projection matrix of the camera.
  90020. * @param force forces the camera to recompute the matrix without looking at the cached state
  90021. * @returns the projection matrix
  90022. */
  90023. getProjectionMatrix(force?: boolean): Matrix;
  90024. /**
  90025. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90026. * @returns a Matrix
  90027. */
  90028. getTransformationMatrix(): Matrix;
  90029. private _updateFrustumPlanes;
  90030. /**
  90031. * Checks if a cullable object (mesh...) is in the camera frustum
  90032. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90033. * @param target The object to check
  90034. * @returns true if the object is in frustum otherwise false
  90035. */
  90036. isInFrustum(target: ICullable): boolean;
  90037. /**
  90038. * Checks if a cullable object (mesh...) is in the camera frustum
  90039. * Unlike isInFrustum this cheks the full bounding box
  90040. * @param target The object to check
  90041. * @returns true if the object is in frustum otherwise false
  90042. */
  90043. isCompletelyInFrustum(target: ICullable): boolean;
  90044. /**
  90045. * Gets a ray in the forward direction from the camera.
  90046. * @param length Defines the length of the ray to create
  90047. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90048. * @param origin Defines the start point of the ray which defaults to the camera position
  90049. * @returns the forward ray
  90050. */
  90051. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90052. /**
  90053. * Releases resources associated with this node.
  90054. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90055. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90056. */
  90057. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90058. /** @hidden */
  90059. _isLeftCamera: boolean;
  90060. /**
  90061. * Gets the left camera of a rig setup in case of Rigged Camera
  90062. */
  90063. readonly isLeftCamera: boolean;
  90064. /** @hidden */
  90065. _isRightCamera: boolean;
  90066. /**
  90067. * Gets the right camera of a rig setup in case of Rigged Camera
  90068. */
  90069. readonly isRightCamera: boolean;
  90070. /**
  90071. * Gets the left camera of a rig setup in case of Rigged Camera
  90072. */
  90073. readonly leftCamera: Nullable<FreeCamera>;
  90074. /**
  90075. * Gets the right camera of a rig setup in case of Rigged Camera
  90076. */
  90077. readonly rightCamera: Nullable<FreeCamera>;
  90078. /**
  90079. * Gets the left camera target of a rig setup in case of Rigged Camera
  90080. * @returns the target position
  90081. */
  90082. getLeftTarget(): Nullable<Vector3>;
  90083. /**
  90084. * Gets the right camera target of a rig setup in case of Rigged Camera
  90085. * @returns the target position
  90086. */
  90087. getRightTarget(): Nullable<Vector3>;
  90088. /**
  90089. * @hidden
  90090. */
  90091. setCameraRigMode(mode: number, rigParams: any): void;
  90092. /** @hidden */
  90093. static _setStereoscopicRigMode(camera: Camera): void;
  90094. /** @hidden */
  90095. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90096. /** @hidden */
  90097. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90098. /** @hidden */
  90099. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90100. /** @hidden */
  90101. _getVRProjectionMatrix(): Matrix;
  90102. protected _updateCameraRotationMatrix(): void;
  90103. protected _updateWebVRCameraRotationMatrix(): void;
  90104. /**
  90105. * This function MUST be overwritten by the different WebVR cameras available.
  90106. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90107. * @hidden
  90108. */
  90109. _getWebVRProjectionMatrix(): Matrix;
  90110. /**
  90111. * This function MUST be overwritten by the different WebVR cameras available.
  90112. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90113. * @hidden
  90114. */
  90115. _getWebVRViewMatrix(): Matrix;
  90116. /** @hidden */
  90117. setCameraRigParameter(name: string, value: any): void;
  90118. /**
  90119. * needs to be overridden by children so sub has required properties to be copied
  90120. * @hidden
  90121. */
  90122. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90123. /**
  90124. * May need to be overridden by children
  90125. * @hidden
  90126. */
  90127. _updateRigCameras(): void;
  90128. /** @hidden */
  90129. _setupInputs(): void;
  90130. /**
  90131. * Serialiaze the camera setup to a json represention
  90132. * @returns the JSON representation
  90133. */
  90134. serialize(): any;
  90135. /**
  90136. * Clones the current camera.
  90137. * @param name The cloned camera name
  90138. * @returns the cloned camera
  90139. */
  90140. clone(name: string): Camera;
  90141. /**
  90142. * Gets the direction of the camera relative to a given local axis.
  90143. * @param localAxis Defines the reference axis to provide a relative direction.
  90144. * @return the direction
  90145. */
  90146. getDirection(localAxis: Vector3): Vector3;
  90147. /**
  90148. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90149. * @param localAxis Defines the reference axis to provide a relative direction.
  90150. * @param result Defines the vector to store the result in
  90151. */
  90152. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90153. /**
  90154. * Gets a camera constructor for a given camera type
  90155. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90156. * @param name The name of the camera the result will be able to instantiate
  90157. * @param scene The scene the result will construct the camera in
  90158. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90159. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90160. * @returns a factory method to construc the camera
  90161. */
  90162. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90163. /**
  90164. * Compute the world matrix of the camera.
  90165. * @returns the camera workd matrix
  90166. */
  90167. computeWorldMatrix(): Matrix;
  90168. /**
  90169. * Parse a JSON and creates the camera from the parsed information
  90170. * @param parsedCamera The JSON to parse
  90171. * @param scene The scene to instantiate the camera in
  90172. * @returns the newly constructed camera
  90173. */
  90174. static Parse(parsedCamera: any, scene: Scene): Camera;
  90175. }
  90176. }
  90177. declare module BABYLON {
  90178. /**
  90179. * Interface for any object that can request an animation frame
  90180. */
  90181. export interface ICustomAnimationFrameRequester {
  90182. /**
  90183. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90184. */
  90185. renderFunction?: Function;
  90186. /**
  90187. * Called to request the next frame to render to
  90188. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90189. */
  90190. requestAnimationFrame: Function;
  90191. /**
  90192. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90193. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90194. */
  90195. requestID?: number;
  90196. }
  90197. /**
  90198. * Interface containing an array of animations
  90199. */
  90200. export interface IAnimatable {
  90201. /**
  90202. * Array of animations
  90203. */
  90204. animations: Nullable<Array<Animation>>;
  90205. }
  90206. /** Interface used by value gradients (color, factor, ...) */
  90207. export interface IValueGradient {
  90208. /**
  90209. * Gets or sets the gradient value (between 0 and 1)
  90210. */
  90211. gradient: number;
  90212. }
  90213. /** Class used to store color4 gradient */
  90214. export class ColorGradient implements IValueGradient {
  90215. /**
  90216. * Gets or sets the gradient value (between 0 and 1)
  90217. */
  90218. gradient: number;
  90219. /**
  90220. * Gets or sets first associated color
  90221. */
  90222. color1: Color4;
  90223. /**
  90224. * Gets or sets second associated color
  90225. */
  90226. color2?: Color4;
  90227. /**
  90228. * Will get a color picked randomly between color1 and color2.
  90229. * If color2 is undefined then color1 will be used
  90230. * @param result defines the target Color4 to store the result in
  90231. */
  90232. getColorToRef(result: Color4): void;
  90233. }
  90234. /** Class used to store color 3 gradient */
  90235. export class Color3Gradient implements IValueGradient {
  90236. /**
  90237. * Gets or sets the gradient value (between 0 and 1)
  90238. */
  90239. gradient: number;
  90240. /**
  90241. * Gets or sets the associated color
  90242. */
  90243. color: Color3;
  90244. }
  90245. /** Class used to store factor gradient */
  90246. export class FactorGradient implements IValueGradient {
  90247. /**
  90248. * Gets or sets the gradient value (between 0 and 1)
  90249. */
  90250. gradient: number;
  90251. /**
  90252. * Gets or sets first associated factor
  90253. */
  90254. factor1: number;
  90255. /**
  90256. * Gets or sets second associated factor
  90257. */
  90258. factor2?: number;
  90259. /**
  90260. * Will get a number picked randomly between factor1 and factor2.
  90261. * If factor2 is undefined then factor1 will be used
  90262. * @returns the picked number
  90263. */
  90264. getFactor(): number;
  90265. }
  90266. /**
  90267. * @ignore
  90268. * Application error to support additional information when loading a file
  90269. */
  90270. export class LoadFileError extends Error {
  90271. /** defines the optional web request */
  90272. request?: WebRequest | undefined;
  90273. private static _setPrototypeOf;
  90274. /**
  90275. * Creates a new LoadFileError
  90276. * @param message defines the message of the error
  90277. * @param request defines the optional web request
  90278. */
  90279. constructor(message: string,
  90280. /** defines the optional web request */
  90281. request?: WebRequest | undefined);
  90282. }
  90283. /**
  90284. * Class used to define a retry strategy when error happens while loading assets
  90285. */
  90286. export class RetryStrategy {
  90287. /**
  90288. * Function used to defines an exponential back off strategy
  90289. * @param maxRetries defines the maximum number of retries (3 by default)
  90290. * @param baseInterval defines the interval between retries
  90291. * @returns the strategy function to use
  90292. */
  90293. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90294. }
  90295. /**
  90296. * File request interface
  90297. */
  90298. export interface IFileRequest {
  90299. /**
  90300. * Raised when the request is complete (success or error).
  90301. */
  90302. onCompleteObservable: Observable<IFileRequest>;
  90303. /**
  90304. * Aborts the request for a file.
  90305. */
  90306. abort: () => void;
  90307. }
  90308. /**
  90309. * Class containing a set of static utilities functions
  90310. */
  90311. export class Tools {
  90312. /**
  90313. * Gets or sets the base URL to use to load assets
  90314. */
  90315. static BaseUrl: string;
  90316. /**
  90317. * Enable/Disable Custom HTTP Request Headers globally.
  90318. * default = false
  90319. * @see CustomRequestHeaders
  90320. */
  90321. static UseCustomRequestHeaders: boolean;
  90322. /**
  90323. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90324. * i.e. when loading files, where the server/service expects an Authorization header
  90325. */
  90326. static CustomRequestHeaders: {
  90327. [key: string]: string;
  90328. };
  90329. /**
  90330. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90331. */
  90332. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90333. /**
  90334. * Default behaviour for cors in the application.
  90335. * It can be a string if the expected behavior is identical in the entire app.
  90336. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90337. */
  90338. static CorsBehavior: string | ((url: string | string[]) => string);
  90339. /**
  90340. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90341. * @ignorenaming
  90342. */
  90343. static UseFallbackTexture: boolean;
  90344. /**
  90345. * Use this object to register external classes like custom textures or material
  90346. * to allow the laoders to instantiate them
  90347. */
  90348. static RegisteredExternalClasses: {
  90349. [key: string]: Object;
  90350. };
  90351. /**
  90352. * Texture content used if a texture cannot loaded
  90353. * @ignorenaming
  90354. */
  90355. static fallbackTexture: string;
  90356. /**
  90357. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90358. * @param u defines the coordinate on X axis
  90359. * @param v defines the coordinate on Y axis
  90360. * @param width defines the width of the source data
  90361. * @param height defines the height of the source data
  90362. * @param pixels defines the source byte array
  90363. * @param color defines the output color
  90364. */
  90365. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90366. /**
  90367. * Interpolates between a and b via alpha
  90368. * @param a The lower value (returned when alpha = 0)
  90369. * @param b The upper value (returned when alpha = 1)
  90370. * @param alpha The interpolation-factor
  90371. * @return The mixed value
  90372. */
  90373. static Mix(a: number, b: number, alpha: number): number;
  90374. /**
  90375. * Tries to instantiate a new object from a given class name
  90376. * @param className defines the class name to instantiate
  90377. * @returns the new object or null if the system was not able to do the instantiation
  90378. */
  90379. static Instantiate(className: string): any;
  90380. /**
  90381. * Provides a slice function that will work even on IE
  90382. * @param data defines the array to slice
  90383. * @param start defines the start of the data (optional)
  90384. * @param end defines the end of the data (optional)
  90385. * @returns the new sliced array
  90386. */
  90387. static Slice<T>(data: T, start?: number, end?: number): T;
  90388. /**
  90389. * Polyfill for setImmediate
  90390. * @param action defines the action to execute after the current execution block
  90391. */
  90392. static SetImmediate(action: () => void): void;
  90393. /**
  90394. * Function indicating if a number is an exponent of 2
  90395. * @param value defines the value to test
  90396. * @returns true if the value is an exponent of 2
  90397. */
  90398. static IsExponentOfTwo(value: number): boolean;
  90399. private static _tmpFloatArray;
  90400. /**
  90401. * Returns the nearest 32-bit single precision float representation of a Number
  90402. * @param value A Number. If the parameter is of a different type, it will get converted
  90403. * to a number or to NaN if it cannot be converted
  90404. * @returns number
  90405. */
  90406. static FloatRound(value: number): number;
  90407. /**
  90408. * Find the next highest power of two.
  90409. * @param x Number to start search from.
  90410. * @return Next highest power of two.
  90411. */
  90412. static CeilingPOT(x: number): number;
  90413. /**
  90414. * Find the next lowest power of two.
  90415. * @param x Number to start search from.
  90416. * @return Next lowest power of two.
  90417. */
  90418. static FloorPOT(x: number): number;
  90419. /**
  90420. * Find the nearest power of two.
  90421. * @param x Number to start search from.
  90422. * @return Next nearest power of two.
  90423. */
  90424. static NearestPOT(x: number): number;
  90425. /**
  90426. * Get the closest exponent of two
  90427. * @param value defines the value to approximate
  90428. * @param max defines the maximum value to return
  90429. * @param mode defines how to define the closest value
  90430. * @returns closest exponent of two of the given value
  90431. */
  90432. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90433. /**
  90434. * Extracts the filename from a path
  90435. * @param path defines the path to use
  90436. * @returns the filename
  90437. */
  90438. static GetFilename(path: string): string;
  90439. /**
  90440. * Extracts the "folder" part of a path (everything before the filename).
  90441. * @param uri The URI to extract the info from
  90442. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90443. * @returns The "folder" part of the path
  90444. */
  90445. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90446. /**
  90447. * Extracts text content from a DOM element hierarchy
  90448. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90449. */
  90450. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90451. /**
  90452. * Convert an angle in radians to degrees
  90453. * @param angle defines the angle to convert
  90454. * @returns the angle in degrees
  90455. */
  90456. static ToDegrees(angle: number): number;
  90457. /**
  90458. * Convert an angle in degrees to radians
  90459. * @param angle defines the angle to convert
  90460. * @returns the angle in radians
  90461. */
  90462. static ToRadians(angle: number): number;
  90463. /**
  90464. * Encode a buffer to a base64 string
  90465. * @param buffer defines the buffer to encode
  90466. * @returns the encoded string
  90467. */
  90468. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90469. /**
  90470. * Extracts minimum and maximum values from a list of indexed positions
  90471. * @param positions defines the positions to use
  90472. * @param indices defines the indices to the positions
  90473. * @param indexStart defines the start index
  90474. * @param indexCount defines the end index
  90475. * @param bias defines bias value to add to the result
  90476. * @return minimum and maximum values
  90477. */
  90478. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90479. minimum: Vector3;
  90480. maximum: Vector3;
  90481. };
  90482. /**
  90483. * Extracts minimum and maximum values from a list of positions
  90484. * @param positions defines the positions to use
  90485. * @param start defines the start index in the positions array
  90486. * @param count defines the number of positions to handle
  90487. * @param bias defines bias value to add to the result
  90488. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90489. * @return minimum and maximum values
  90490. */
  90491. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90492. minimum: Vector3;
  90493. maximum: Vector3;
  90494. };
  90495. /**
  90496. * Returns an array if obj is not an array
  90497. * @param obj defines the object to evaluate as an array
  90498. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90499. * @returns either obj directly if obj is an array or a new array containing obj
  90500. */
  90501. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90502. /**
  90503. * Gets the pointer prefix to use
  90504. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90505. */
  90506. static GetPointerPrefix(): string;
  90507. /**
  90508. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90509. * @param func - the function to be called
  90510. * @param requester - the object that will request the next frame. Falls back to window.
  90511. * @returns frame number
  90512. */
  90513. static QueueNewFrame(func: () => void, requester?: any): number;
  90514. /**
  90515. * Ask the browser to promote the current element to fullscreen rendering mode
  90516. * @param element defines the DOM element to promote
  90517. */
  90518. static RequestFullscreen(element: HTMLElement): void;
  90519. /**
  90520. * Asks the browser to exit fullscreen mode
  90521. */
  90522. static ExitFullscreen(): void;
  90523. /**
  90524. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90525. * @param url define the url we are trying
  90526. * @param element define the dom element where to configure the cors policy
  90527. */
  90528. static SetCorsBehavior(url: string | string[], element: {
  90529. crossOrigin: string | null;
  90530. }): void;
  90531. /**
  90532. * Removes unwanted characters from an url
  90533. * @param url defines the url to clean
  90534. * @returns the cleaned url
  90535. */
  90536. static CleanUrl(url: string): string;
  90537. /**
  90538. * Gets or sets a function used to pre-process url before using them to load assets
  90539. */
  90540. static PreprocessUrl: (url: string) => string;
  90541. /**
  90542. * Loads an image as an HTMLImageElement.
  90543. * @param input url string, ArrayBuffer, or Blob to load
  90544. * @param onLoad callback called when the image successfully loads
  90545. * @param onError callback called when the image fails to load
  90546. * @param offlineProvider offline provider for caching
  90547. * @returns the HTMLImageElement of the loaded image
  90548. */
  90549. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90550. /**
  90551. * Loads a file
  90552. * @param url url string, ArrayBuffer, or Blob to load
  90553. * @param onSuccess callback called when the file successfully loads
  90554. * @param onProgress callback called while file is loading (if the server supports this mode)
  90555. * @param offlineProvider defines the offline provider for caching
  90556. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90557. * @param onError callback called when the file fails to load
  90558. * @returns a file request object
  90559. */
  90560. 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;
  90561. /**
  90562. * Load a script (identified by an url). When the url returns, the
  90563. * content of this file is added into a new script element, attached to the DOM (body element)
  90564. * @param scriptUrl defines the url of the script to laod
  90565. * @param onSuccess defines the callback called when the script is loaded
  90566. * @param onError defines the callback to call if an error occurs
  90567. * @param scriptId defines the id of the script element
  90568. */
  90569. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90570. /**
  90571. * Load an asynchronous script (identified by an url). When the url returns, the
  90572. * content of this file is added into a new script element, attached to the DOM (body element)
  90573. * @param scriptUrl defines the url of the script to laod
  90574. * @param scriptId defines the id of the script element
  90575. * @returns a promise request object
  90576. */
  90577. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90578. /**
  90579. * Loads a file from a blob
  90580. * @param fileToLoad defines the blob to use
  90581. * @param callback defines the callback to call when data is loaded
  90582. * @param progressCallback defines the callback to call during loading process
  90583. * @returns a file request object
  90584. */
  90585. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90586. /**
  90587. * Loads a file
  90588. * @param fileToLoad defines the file to load
  90589. * @param callback defines the callback to call when data is loaded
  90590. * @param progressCallBack defines the callback to call during loading process
  90591. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90592. * @returns a file request object
  90593. */
  90594. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90595. /**
  90596. * Creates a data url from a given string content
  90597. * @param content defines the content to convert
  90598. * @returns the new data url link
  90599. */
  90600. static FileAsURL(content: string): string;
  90601. /**
  90602. * Format the given number to a specific decimal format
  90603. * @param value defines the number to format
  90604. * @param decimals defines the number of decimals to use
  90605. * @returns the formatted string
  90606. */
  90607. static Format(value: number, decimals?: number): string;
  90608. /**
  90609. * Checks if a given vector is inside a specific range
  90610. * @param v defines the vector to test
  90611. * @param min defines the minimum range
  90612. * @param max defines the maximum range
  90613. */
  90614. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90615. /**
  90616. * Tries to copy an object by duplicating every property
  90617. * @param source defines the source object
  90618. * @param destination defines the target object
  90619. * @param doNotCopyList defines a list of properties to avoid
  90620. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90621. */
  90622. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90623. /**
  90624. * Gets a boolean indicating if the given object has no own property
  90625. * @param obj defines the object to test
  90626. * @returns true if object has no own property
  90627. */
  90628. static IsEmpty(obj: any): boolean;
  90629. /**
  90630. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90631. * @param str Source string
  90632. * @param suffix Suffix to search for in the source string
  90633. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90634. */
  90635. static EndsWith(str: string, suffix: string): boolean;
  90636. /**
  90637. * Function used to register events at window level
  90638. * @param events defines the events to register
  90639. */
  90640. static RegisterTopRootEvents(events: {
  90641. name: string;
  90642. handler: Nullable<(e: FocusEvent) => any>;
  90643. }[]): void;
  90644. /**
  90645. * Function used to unregister events from window level
  90646. * @param events defines the events to unregister
  90647. */
  90648. static UnregisterTopRootEvents(events: {
  90649. name: string;
  90650. handler: Nullable<(e: FocusEvent) => any>;
  90651. }[]): void;
  90652. /**
  90653. * @ignore
  90654. */
  90655. static _ScreenshotCanvas: HTMLCanvasElement;
  90656. /**
  90657. * Dumps the current bound framebuffer
  90658. * @param width defines the rendering width
  90659. * @param height defines the rendering height
  90660. * @param engine defines the hosting engine
  90661. * @param successCallback defines the callback triggered once the data are available
  90662. * @param mimeType defines the mime type of the result
  90663. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90664. */
  90665. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90666. /**
  90667. * Converts the canvas data to blob.
  90668. * This acts as a polyfill for browsers not supporting the to blob function.
  90669. * @param canvas Defines the canvas to extract the data from
  90670. * @param successCallback Defines the callback triggered once the data are available
  90671. * @param mimeType Defines the mime type of the result
  90672. */
  90673. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90674. /**
  90675. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90676. * @param successCallback defines the callback triggered once the data are available
  90677. * @param mimeType defines the mime type of the result
  90678. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90679. */
  90680. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90681. /**
  90682. * Downloads a blob in the browser
  90683. * @param blob defines the blob to download
  90684. * @param fileName defines the name of the downloaded file
  90685. */
  90686. static Download(blob: Blob, fileName: string): void;
  90687. /**
  90688. * Captures a screenshot of the current rendering
  90689. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90690. * @param engine defines the rendering engine
  90691. * @param camera defines the source camera
  90692. * @param size This parameter can be set to a single number or to an object with the
  90693. * following (optional) properties: precision, width, height. If a single number is passed,
  90694. * it will be used for both width and height. If an object is passed, the screenshot size
  90695. * will be derived from the parameters. The precision property is a multiplier allowing
  90696. * rendering at a higher or lower resolution
  90697. * @param successCallback defines the callback receives a single parameter which contains the
  90698. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90699. * src parameter of an <img> to display it
  90700. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90701. * Check your browser for supported MIME types
  90702. */
  90703. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90704. /**
  90705. * Generates an image screenshot from the specified camera.
  90706. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90707. * @param engine The engine to use for rendering
  90708. * @param camera The camera to use for rendering
  90709. * @param size This parameter can be set to a single number or to an object with the
  90710. * following (optional) properties: precision, width, height. If a single number is passed,
  90711. * it will be used for both width and height. If an object is passed, the screenshot size
  90712. * will be derived from the parameters. The precision property is a multiplier allowing
  90713. * rendering at a higher or lower resolution
  90714. * @param successCallback The callback receives a single parameter which contains the
  90715. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90716. * src parameter of an <img> to display it
  90717. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90718. * Check your browser for supported MIME types
  90719. * @param samples Texture samples (default: 1)
  90720. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90721. * @param fileName A name for for the downloaded file.
  90722. */
  90723. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90724. /**
  90725. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90726. * Be aware Math.random() could cause collisions, but:
  90727. * "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"
  90728. * @returns a pseudo random id
  90729. */
  90730. static RandomId(): string;
  90731. /**
  90732. * Test if the given uri is a base64 string
  90733. * @param uri The uri to test
  90734. * @return True if the uri is a base64 string or false otherwise
  90735. */
  90736. static IsBase64(uri: string): boolean;
  90737. /**
  90738. * Decode the given base64 uri.
  90739. * @param uri The uri to decode
  90740. * @return The decoded base64 data.
  90741. */
  90742. static DecodeBase64(uri: string): ArrayBuffer;
  90743. /**
  90744. * Gets the absolute url.
  90745. * @param url the input url
  90746. * @return the absolute url
  90747. */
  90748. static GetAbsoluteUrl(url: string): string;
  90749. /**
  90750. * No log
  90751. */
  90752. static readonly NoneLogLevel: number;
  90753. /**
  90754. * Only message logs
  90755. */
  90756. static readonly MessageLogLevel: number;
  90757. /**
  90758. * Only warning logs
  90759. */
  90760. static readonly WarningLogLevel: number;
  90761. /**
  90762. * Only error logs
  90763. */
  90764. static readonly ErrorLogLevel: number;
  90765. /**
  90766. * All logs
  90767. */
  90768. static readonly AllLogLevel: number;
  90769. /**
  90770. * Gets a value indicating the number of loading errors
  90771. * @ignorenaming
  90772. */
  90773. static readonly errorsCount: number;
  90774. /**
  90775. * Callback called when a new log is added
  90776. */
  90777. static OnNewCacheEntry: (entry: string) => void;
  90778. /**
  90779. * Log a message to the console
  90780. * @param message defines the message to log
  90781. */
  90782. static Log(message: string): void;
  90783. /**
  90784. * Write a warning message to the console
  90785. * @param message defines the message to log
  90786. */
  90787. static Warn(message: string): void;
  90788. /**
  90789. * Write an error message to the console
  90790. * @param message defines the message to log
  90791. */
  90792. static Error(message: string): void;
  90793. /**
  90794. * Gets current log cache (list of logs)
  90795. */
  90796. static readonly LogCache: string;
  90797. /**
  90798. * Clears the log cache
  90799. */
  90800. static ClearLogCache(): void;
  90801. /**
  90802. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90803. */
  90804. static LogLevels: number;
  90805. /**
  90806. * Checks if the loaded document was accessed via `file:`-Protocol.
  90807. * @returns boolean
  90808. */
  90809. static IsFileURL(): boolean;
  90810. /**
  90811. * Checks if the window object exists
  90812. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90813. */
  90814. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90815. /**
  90816. * No performance log
  90817. */
  90818. static readonly PerformanceNoneLogLevel: number;
  90819. /**
  90820. * Use user marks to log performance
  90821. */
  90822. static readonly PerformanceUserMarkLogLevel: number;
  90823. /**
  90824. * Log performance to the console
  90825. */
  90826. static readonly PerformanceConsoleLogLevel: number;
  90827. private static _performance;
  90828. /**
  90829. * Sets the current performance log level
  90830. */
  90831. static PerformanceLogLevel: number;
  90832. private static _StartPerformanceCounterDisabled;
  90833. private static _EndPerformanceCounterDisabled;
  90834. private static _StartUserMark;
  90835. private static _EndUserMark;
  90836. private static _StartPerformanceConsole;
  90837. private static _EndPerformanceConsole;
  90838. /**
  90839. * Starts a performance counter
  90840. */
  90841. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90842. /**
  90843. * Ends a specific performance coutner
  90844. */
  90845. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90846. /**
  90847. * Gets either window.performance.now() if supported or Date.now() else
  90848. */
  90849. static readonly Now: number;
  90850. /**
  90851. * This method will return the name of the class used to create the instance of the given object.
  90852. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  90853. * @param object the object to get the class name from
  90854. * @param isType defines if the object is actually a type
  90855. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  90856. */
  90857. static GetClassName(object: any, isType?: boolean): string;
  90858. /**
  90859. * Gets the first element of an array satisfying a given predicate
  90860. * @param array defines the array to browse
  90861. * @param predicate defines the predicate to use
  90862. * @returns null if not found or the element
  90863. */
  90864. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  90865. /**
  90866. * This method will return the name of the full name of the class, including its owning module (if any).
  90867. * 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).
  90868. * @param object the object to get the class name from
  90869. * @param isType defines if the object is actually a type
  90870. * @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.
  90871. * @ignorenaming
  90872. */
  90873. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  90874. /**
  90875. * Returns a promise that resolves after the given amount of time.
  90876. * @param delay Number of milliseconds to delay
  90877. * @returns Promise that resolves after the given amount of time
  90878. */
  90879. static DelayAsync(delay: number): Promise<void>;
  90880. /**
  90881. * Gets the current gradient from an array of IValueGradient
  90882. * @param ratio defines the current ratio to get
  90883. * @param gradients defines the array of IValueGradient
  90884. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90885. */
  90886. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90887. }
  90888. /**
  90889. * This class is used to track a performance counter which is number based.
  90890. * The user has access to many properties which give statistics of different nature.
  90891. *
  90892. * The implementer can track two kinds of Performance Counter: time and count.
  90893. * 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.
  90894. * 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.
  90895. */
  90896. export class PerfCounter {
  90897. /**
  90898. * Gets or sets a global boolean to turn on and off all the counters
  90899. */
  90900. static Enabled: boolean;
  90901. /**
  90902. * Returns the smallest value ever
  90903. */
  90904. readonly min: number;
  90905. /**
  90906. * Returns the biggest value ever
  90907. */
  90908. readonly max: number;
  90909. /**
  90910. * Returns the average value since the performance counter is running
  90911. */
  90912. readonly average: number;
  90913. /**
  90914. * Returns the average value of the last second the counter was monitored
  90915. */
  90916. readonly lastSecAverage: number;
  90917. /**
  90918. * Returns the current value
  90919. */
  90920. readonly current: number;
  90921. /**
  90922. * Gets the accumulated total
  90923. */
  90924. readonly total: number;
  90925. /**
  90926. * Gets the total value count
  90927. */
  90928. readonly count: number;
  90929. /**
  90930. * Creates a new counter
  90931. */
  90932. constructor();
  90933. /**
  90934. * Call this method to start monitoring a new frame.
  90935. * 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.
  90936. */
  90937. fetchNewFrame(): void;
  90938. /**
  90939. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  90940. * @param newCount the count value to add to the monitored count
  90941. * @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.
  90942. */
  90943. addCount(newCount: number, fetchResult: boolean): void;
  90944. /**
  90945. * Start monitoring this performance counter
  90946. */
  90947. beginMonitoring(): void;
  90948. /**
  90949. * Compute the time lapsed since the previous beginMonitoring() call.
  90950. * @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
  90951. */
  90952. endMonitoring(newFrame?: boolean): void;
  90953. private _fetchResult;
  90954. private _startMonitoringTime;
  90955. private _min;
  90956. private _max;
  90957. private _average;
  90958. private _current;
  90959. private _totalValueCount;
  90960. private _totalAccumulated;
  90961. private _lastSecAverage;
  90962. private _lastSecAccumulated;
  90963. private _lastSecTime;
  90964. private _lastSecValueCount;
  90965. }
  90966. /**
  90967. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  90968. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  90969. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  90970. * @param name The name of the class, case should be preserved
  90971. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90972. */
  90973. export function className(name: string, module?: string): (target: Object) => void;
  90974. /**
  90975. * An implementation of a loop for asynchronous functions.
  90976. */
  90977. export class AsyncLoop {
  90978. /**
  90979. * Defines the number of iterations for the loop
  90980. */
  90981. iterations: number;
  90982. /**
  90983. * Defines the current index of the loop.
  90984. */
  90985. index: number;
  90986. private _done;
  90987. private _fn;
  90988. private _successCallback;
  90989. /**
  90990. * Constructor.
  90991. * @param iterations the number of iterations.
  90992. * @param func the function to run each iteration
  90993. * @param successCallback the callback that will be called upon succesful execution
  90994. * @param offset starting offset.
  90995. */
  90996. constructor(
  90997. /**
  90998. * Defines the number of iterations for the loop
  90999. */
  91000. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91001. /**
  91002. * Execute the next iteration. Must be called after the last iteration was finished.
  91003. */
  91004. executeNext(): void;
  91005. /**
  91006. * Break the loop and run the success callback.
  91007. */
  91008. breakLoop(): void;
  91009. /**
  91010. * Create and run an async loop.
  91011. * @param iterations the number of iterations.
  91012. * @param fn the function to run each iteration
  91013. * @param successCallback the callback that will be called upon succesful execution
  91014. * @param offset starting offset.
  91015. * @returns the created async loop object
  91016. */
  91017. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91018. /**
  91019. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91020. * @param iterations total number of iterations
  91021. * @param syncedIterations number of synchronous iterations in each async iteration.
  91022. * @param fn the function to call each iteration.
  91023. * @param callback a success call back that will be called when iterating stops.
  91024. * @param breakFunction a break condition (optional)
  91025. * @param timeout timeout settings for the setTimeout function. default - 0.
  91026. * @returns the created async loop object
  91027. */
  91028. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91029. }
  91030. }
  91031. declare module BABYLON {
  91032. /** @hidden */
  91033. export interface ICollisionCoordinator {
  91034. createCollider(): Collider;
  91035. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91036. init(scene: Scene): void;
  91037. }
  91038. /** @hidden */
  91039. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91040. private _scene;
  91041. private _scaledPosition;
  91042. private _scaledVelocity;
  91043. private _finalPosition;
  91044. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91045. createCollider(): Collider;
  91046. init(scene: Scene): void;
  91047. private _collideWithWorld;
  91048. }
  91049. }
  91050. declare module BABYLON {
  91051. /**
  91052. * This class defines the direct association between an animation and a target
  91053. */
  91054. export class TargetedAnimation {
  91055. /**
  91056. * Animation to perform
  91057. */
  91058. animation: Animation;
  91059. /**
  91060. * Target to animate
  91061. */
  91062. target: any;
  91063. }
  91064. /**
  91065. * Use this class to create coordinated animations on multiple targets
  91066. */
  91067. export class AnimationGroup implements IDisposable {
  91068. /** The name of the animation group */
  91069. name: string;
  91070. private _scene;
  91071. private _targetedAnimations;
  91072. private _animatables;
  91073. private _from;
  91074. private _to;
  91075. private _isStarted;
  91076. private _isPaused;
  91077. private _speedRatio;
  91078. /**
  91079. * Gets or sets the unique id of the node
  91080. */
  91081. uniqueId: number;
  91082. /**
  91083. * This observable will notify when one animation have ended
  91084. */
  91085. onAnimationEndObservable: Observable<TargetedAnimation>;
  91086. /**
  91087. * Observer raised when one animation loops
  91088. */
  91089. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91090. /**
  91091. * This observable will notify when all animations have ended.
  91092. */
  91093. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91094. /**
  91095. * This observable will notify when all animations have paused.
  91096. */
  91097. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91098. /**
  91099. * This observable will notify when all animations are playing.
  91100. */
  91101. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91102. /**
  91103. * Gets the first frame
  91104. */
  91105. readonly from: number;
  91106. /**
  91107. * Gets the last frame
  91108. */
  91109. readonly to: number;
  91110. /**
  91111. * Define if the animations are started
  91112. */
  91113. readonly isStarted: boolean;
  91114. /**
  91115. * Gets a value indicating that the current group is playing
  91116. */
  91117. readonly isPlaying: boolean;
  91118. /**
  91119. * Gets or sets the speed ratio to use for all animations
  91120. */
  91121. /**
  91122. * Gets or sets the speed ratio to use for all animations
  91123. */
  91124. speedRatio: number;
  91125. /**
  91126. * Gets the targeted animations for this animation group
  91127. */
  91128. readonly targetedAnimations: Array<TargetedAnimation>;
  91129. /**
  91130. * returning the list of animatables controlled by this animation group.
  91131. */
  91132. readonly animatables: Array<Animatable>;
  91133. /**
  91134. * Instantiates a new Animation Group.
  91135. * This helps managing several animations at once.
  91136. * @see http://doc.babylonjs.com/how_to/group
  91137. * @param name Defines the name of the group
  91138. * @param scene Defines the scene the group belongs to
  91139. */
  91140. constructor(
  91141. /** The name of the animation group */
  91142. name: string, scene?: Nullable<Scene>);
  91143. /**
  91144. * Add an animation (with its target) in the group
  91145. * @param animation defines the animation we want to add
  91146. * @param target defines the target of the animation
  91147. * @returns the TargetedAnimation object
  91148. */
  91149. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91150. /**
  91151. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91152. * It can add constant keys at begin or end
  91153. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91154. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91155. * @returns the animation group
  91156. */
  91157. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91158. /**
  91159. * Start all animations on given targets
  91160. * @param loop defines if animations must loop
  91161. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91162. * @param from defines the from key (optional)
  91163. * @param to defines the to key (optional)
  91164. * @returns the current animation group
  91165. */
  91166. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91167. /**
  91168. * Pause all animations
  91169. * @returns the animation group
  91170. */
  91171. pause(): AnimationGroup;
  91172. /**
  91173. * Play all animations to initial state
  91174. * This function will start() the animations if they were not started or will restart() them if they were paused
  91175. * @param loop defines if animations must loop
  91176. * @returns the animation group
  91177. */
  91178. play(loop?: boolean): AnimationGroup;
  91179. /**
  91180. * Reset all animations to initial state
  91181. * @returns the animation group
  91182. */
  91183. reset(): AnimationGroup;
  91184. /**
  91185. * Restart animations from key 0
  91186. * @returns the animation group
  91187. */
  91188. restart(): AnimationGroup;
  91189. /**
  91190. * Stop all animations
  91191. * @returns the animation group
  91192. */
  91193. stop(): AnimationGroup;
  91194. /**
  91195. * Set animation weight for all animatables
  91196. * @param weight defines the weight to use
  91197. * @return the animationGroup
  91198. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91199. */
  91200. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91201. /**
  91202. * Synchronize and normalize all animatables with a source animatable
  91203. * @param root defines the root animatable to synchronize with
  91204. * @return the animationGroup
  91205. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91206. */
  91207. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91208. /**
  91209. * Goes to a specific frame in this animation group
  91210. * @param frame the frame number to go to
  91211. * @return the animationGroup
  91212. */
  91213. goToFrame(frame: number): AnimationGroup;
  91214. /**
  91215. * Dispose all associated resources
  91216. */
  91217. dispose(): void;
  91218. private _checkAnimationGroupEnded;
  91219. /**
  91220. * Clone the current animation group and returns a copy
  91221. * @param newName defines the name of the new group
  91222. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91223. * @returns the new aniamtion group
  91224. */
  91225. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91226. /**
  91227. * Returns a new AnimationGroup object parsed from the source provided.
  91228. * @param parsedAnimationGroup defines the source
  91229. * @param scene defines the scene that will receive the animationGroup
  91230. * @returns a new AnimationGroup
  91231. */
  91232. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91233. /**
  91234. * Returns the string "AnimationGroup"
  91235. * @returns "AnimationGroup"
  91236. */
  91237. getClassName(): string;
  91238. /**
  91239. * Creates a detailled string about the object
  91240. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91241. * @returns a string representing the object
  91242. */
  91243. toString(fullDetails?: boolean): string;
  91244. }
  91245. }
  91246. declare module BABYLON {
  91247. /**
  91248. * Define an interface for all classes that will hold resources
  91249. */
  91250. export interface IDisposable {
  91251. /**
  91252. * Releases all held resources
  91253. */
  91254. dispose(): void;
  91255. }
  91256. /** Interface defining initialization parameters for Scene class */
  91257. export interface SceneOptions {
  91258. /**
  91259. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91260. * It will improve performance when the number of geometries becomes important.
  91261. */
  91262. useGeometryUniqueIdsMap?: boolean;
  91263. /**
  91264. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91265. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91266. */
  91267. useMaterialMeshMap?: boolean;
  91268. /**
  91269. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91270. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91271. */
  91272. useClonedMeshhMap?: boolean;
  91273. }
  91274. /**
  91275. * Represents a scene to be rendered by the engine.
  91276. * @see http://doc.babylonjs.com/features/scene
  91277. */
  91278. export class Scene extends AbstractScene implements IAnimatable {
  91279. private static _uniqueIdCounter;
  91280. /** The fog is deactivated */
  91281. static readonly FOGMODE_NONE: number;
  91282. /** The fog density is following an exponential function */
  91283. static readonly FOGMODE_EXP: number;
  91284. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91285. static readonly FOGMODE_EXP2: number;
  91286. /** The fog density is following a linear function. */
  91287. static readonly FOGMODE_LINEAR: number;
  91288. /**
  91289. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91290. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91291. */
  91292. static MinDeltaTime: number;
  91293. /**
  91294. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91295. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91296. */
  91297. static MaxDeltaTime: number;
  91298. /**
  91299. * Factory used to create the default material.
  91300. * @param name The name of the material to create
  91301. * @param scene The scene to create the material for
  91302. * @returns The default material
  91303. */
  91304. static DefaultMaterialFactory(scene: Scene): Material;
  91305. /**
  91306. * Factory used to create the a collision coordinator.
  91307. * @returns The collision coordinator
  91308. */
  91309. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91310. /** @hidden */
  91311. readonly _isScene: boolean;
  91312. /**
  91313. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91314. */
  91315. autoClear: boolean;
  91316. /**
  91317. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91318. */
  91319. autoClearDepthAndStencil: boolean;
  91320. /**
  91321. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91322. */
  91323. clearColor: Color4;
  91324. /**
  91325. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91326. */
  91327. ambientColor: Color3;
  91328. /**
  91329. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91330. * It should only be one of the following (if not the default embedded one):
  91331. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91332. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91333. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91334. * The material properties need to be setup according to the type of texture in use.
  91335. */
  91336. environmentBRDFTexture: BaseTexture;
  91337. /** @hidden */
  91338. protected _environmentTexture: Nullable<BaseTexture>;
  91339. /**
  91340. * Texture used in all pbr material as the reflection texture.
  91341. * As in the majority of the scene they are the same (exception for multi room and so on),
  91342. * this is easier to reference from here than from all the materials.
  91343. */
  91344. /**
  91345. * Texture used in all pbr material as the reflection texture.
  91346. * As in the majority of the scene they are the same (exception for multi room and so on),
  91347. * this is easier to set here than in all the materials.
  91348. */
  91349. environmentTexture: Nullable<BaseTexture>;
  91350. /** @hidden */
  91351. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91352. /**
  91353. * Default image processing configuration used either in the rendering
  91354. * Forward main pass or through the imageProcessingPostProcess if present.
  91355. * As in the majority of the scene they are the same (exception for multi camera),
  91356. * this is easier to reference from here than from all the materials and post process.
  91357. *
  91358. * No setter as we it is a shared configuration, you can set the values instead.
  91359. */
  91360. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91361. private _forceWireframe;
  91362. /**
  91363. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91364. */
  91365. forceWireframe: boolean;
  91366. private _forcePointsCloud;
  91367. /**
  91368. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91369. */
  91370. forcePointsCloud: boolean;
  91371. /**
  91372. * Gets or sets the active clipplane 1
  91373. */
  91374. clipPlane: Nullable<Plane>;
  91375. /**
  91376. * Gets or sets the active clipplane 2
  91377. */
  91378. clipPlane2: Nullable<Plane>;
  91379. /**
  91380. * Gets or sets the active clipplane 3
  91381. */
  91382. clipPlane3: Nullable<Plane>;
  91383. /**
  91384. * Gets or sets the active clipplane 4
  91385. */
  91386. clipPlane4: Nullable<Plane>;
  91387. /**
  91388. * Gets or sets a boolean indicating if animations are enabled
  91389. */
  91390. animationsEnabled: boolean;
  91391. private _animationPropertiesOverride;
  91392. /**
  91393. * Gets or sets the animation properties override
  91394. */
  91395. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91396. /**
  91397. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91398. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91399. */
  91400. useConstantAnimationDeltaTime: boolean;
  91401. /**
  91402. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91403. * Please note that it requires to run a ray cast through the scene on every frame
  91404. */
  91405. constantlyUpdateMeshUnderPointer: boolean;
  91406. /**
  91407. * Defines the HTML cursor to use when hovering over interactive elements
  91408. */
  91409. hoverCursor: string;
  91410. /**
  91411. * Defines the HTML default cursor to use (empty by default)
  91412. */
  91413. defaultCursor: string;
  91414. /**
  91415. * This is used to call preventDefault() on pointer down
  91416. * in order to block unwanted artifacts like system double clicks
  91417. */
  91418. preventDefaultOnPointerDown: boolean;
  91419. /**
  91420. * This is used to call preventDefault() on pointer up
  91421. * in order to block unwanted artifacts like system double clicks
  91422. */
  91423. preventDefaultOnPointerUp: boolean;
  91424. /**
  91425. * Gets or sets user defined metadata
  91426. */
  91427. metadata: any;
  91428. /**
  91429. * For internal use only. Please do not use.
  91430. */
  91431. reservedDataStore: any;
  91432. /**
  91433. * Gets the name of the plugin used to load this scene (null by default)
  91434. */
  91435. loadingPluginName: string;
  91436. /**
  91437. * Use this array to add regular expressions used to disable offline support for specific urls
  91438. */
  91439. disableOfflineSupportExceptionRules: RegExp[];
  91440. /**
  91441. * An event triggered when the scene is disposed.
  91442. */
  91443. onDisposeObservable: Observable<Scene>;
  91444. private _onDisposeObserver;
  91445. /** Sets a function to be executed when this scene is disposed. */
  91446. onDispose: () => void;
  91447. /**
  91448. * An event triggered before rendering the scene (right after animations and physics)
  91449. */
  91450. onBeforeRenderObservable: Observable<Scene>;
  91451. private _onBeforeRenderObserver;
  91452. /** Sets a function to be executed before rendering this scene */
  91453. beforeRender: Nullable<() => void>;
  91454. /**
  91455. * An event triggered after rendering the scene
  91456. */
  91457. onAfterRenderObservable: Observable<Scene>;
  91458. private _onAfterRenderObserver;
  91459. /** Sets a function to be executed after rendering this scene */
  91460. afterRender: Nullable<() => void>;
  91461. /**
  91462. * An event triggered before animating the scene
  91463. */
  91464. onBeforeAnimationsObservable: Observable<Scene>;
  91465. /**
  91466. * An event triggered after animations processing
  91467. */
  91468. onAfterAnimationsObservable: Observable<Scene>;
  91469. /**
  91470. * An event triggered before draw calls are ready to be sent
  91471. */
  91472. onBeforeDrawPhaseObservable: Observable<Scene>;
  91473. /**
  91474. * An event triggered after draw calls have been sent
  91475. */
  91476. onAfterDrawPhaseObservable: Observable<Scene>;
  91477. /**
  91478. * An event triggered when the scene is ready
  91479. */
  91480. onReadyObservable: Observable<Scene>;
  91481. /**
  91482. * An event triggered before rendering a camera
  91483. */
  91484. onBeforeCameraRenderObservable: Observable<Camera>;
  91485. private _onBeforeCameraRenderObserver;
  91486. /** Sets a function to be executed before rendering a camera*/
  91487. beforeCameraRender: () => void;
  91488. /**
  91489. * An event triggered after rendering a camera
  91490. */
  91491. onAfterCameraRenderObservable: Observable<Camera>;
  91492. private _onAfterCameraRenderObserver;
  91493. /** Sets a function to be executed after rendering a camera*/
  91494. afterCameraRender: () => void;
  91495. /**
  91496. * An event triggered when active meshes evaluation is about to start
  91497. */
  91498. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  91499. /**
  91500. * An event triggered when active meshes evaluation is done
  91501. */
  91502. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  91503. /**
  91504. * An event triggered when particles rendering is about to start
  91505. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91506. */
  91507. onBeforeParticlesRenderingObservable: Observable<Scene>;
  91508. /**
  91509. * An event triggered when particles rendering is done
  91510. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91511. */
  91512. onAfterParticlesRenderingObservable: Observable<Scene>;
  91513. /**
  91514. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  91515. */
  91516. onDataLoadedObservable: Observable<Scene>;
  91517. /**
  91518. * An event triggered when a camera is created
  91519. */
  91520. onNewCameraAddedObservable: Observable<Camera>;
  91521. /**
  91522. * An event triggered when a camera is removed
  91523. */
  91524. onCameraRemovedObservable: Observable<Camera>;
  91525. /**
  91526. * An event triggered when a light is created
  91527. */
  91528. onNewLightAddedObservable: Observable<Light>;
  91529. /**
  91530. * An event triggered when a light is removed
  91531. */
  91532. onLightRemovedObservable: Observable<Light>;
  91533. /**
  91534. * An event triggered when a geometry is created
  91535. */
  91536. onNewGeometryAddedObservable: Observable<Geometry>;
  91537. /**
  91538. * An event triggered when a geometry is removed
  91539. */
  91540. onGeometryRemovedObservable: Observable<Geometry>;
  91541. /**
  91542. * An event triggered when a transform node is created
  91543. */
  91544. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  91545. /**
  91546. * An event triggered when a transform node is removed
  91547. */
  91548. onTransformNodeRemovedObservable: Observable<TransformNode>;
  91549. /**
  91550. * An event triggered when a mesh is created
  91551. */
  91552. onNewMeshAddedObservable: Observable<AbstractMesh>;
  91553. /**
  91554. * An event triggered when a mesh is removed
  91555. */
  91556. onMeshRemovedObservable: Observable<AbstractMesh>;
  91557. /**
  91558. * An event triggered when a skeleton is created
  91559. */
  91560. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91561. /**
  91562. * An event triggered when a skeleton is removed
  91563. */
  91564. onSkeletonRemovedObservable: Observable<Skeleton>;
  91565. /**
  91566. * An event triggered when a material is created
  91567. */
  91568. onNewMaterialAddedObservable: Observable<Material>;
  91569. /**
  91570. * An event triggered when a material is removed
  91571. */
  91572. onMaterialRemovedObservable: Observable<Material>;
  91573. /**
  91574. * An event triggered when a texture is created
  91575. */
  91576. onNewTextureAddedObservable: Observable<BaseTexture>;
  91577. /**
  91578. * An event triggered when a texture is removed
  91579. */
  91580. onTextureRemovedObservable: Observable<BaseTexture>;
  91581. /**
  91582. * An event triggered when render targets are about to be rendered
  91583. * Can happen multiple times per frame.
  91584. */
  91585. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91586. /**
  91587. * An event triggered when render targets were rendered.
  91588. * Can happen multiple times per frame.
  91589. */
  91590. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91591. /**
  91592. * An event triggered before calculating deterministic simulation step
  91593. */
  91594. onBeforeStepObservable: Observable<Scene>;
  91595. /**
  91596. * An event triggered after calculating deterministic simulation step
  91597. */
  91598. onAfterStepObservable: Observable<Scene>;
  91599. /**
  91600. * An event triggered when the activeCamera property is updated
  91601. */
  91602. onActiveCameraChanged: Observable<Scene>;
  91603. /**
  91604. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91605. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91606. * 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)
  91607. */
  91608. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91609. /**
  91610. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91611. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91612. * 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)
  91613. */
  91614. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91615. /**
  91616. * This Observable will when a mesh has been imported into the scene.
  91617. */
  91618. onMeshImportedObservable: Observable<AbstractMesh>;
  91619. /**
  91620. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91621. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91622. */
  91623. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91624. /** @hidden */
  91625. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91626. /**
  91627. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91628. */
  91629. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91630. /**
  91631. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91632. */
  91633. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91634. /**
  91635. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91636. */
  91637. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91638. private _onPointerMove;
  91639. private _onPointerDown;
  91640. private _onPointerUp;
  91641. /** Callback called when a pointer move is detected */
  91642. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91643. /** Callback called when a pointer down is detected */
  91644. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91645. /** Callback called when a pointer up is detected */
  91646. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91647. /** Callback called when a pointer pick is detected */
  91648. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91649. /**
  91650. * 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).
  91651. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91652. */
  91653. onPrePointerObservable: Observable<PointerInfoPre>;
  91654. /**
  91655. * Observable event triggered each time an input event is received from the rendering canvas
  91656. */
  91657. onPointerObservable: Observable<PointerInfo>;
  91658. /**
  91659. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91660. */
  91661. readonly unTranslatedPointer: Vector2;
  91662. /** The distance in pixel that you have to move to prevent some events */
  91663. static DragMovementThreshold: number;
  91664. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91665. static LongPressDelay: number;
  91666. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91667. static DoubleClickDelay: number;
  91668. /** If you need to check double click without raising a single click at first click, enable this flag */
  91669. static ExclusiveDoubleClickMode: boolean;
  91670. private _initClickEvent;
  91671. private _initActionManager;
  91672. private _delayedSimpleClick;
  91673. private _delayedSimpleClickTimeout;
  91674. private _previousDelayedSimpleClickTimeout;
  91675. private _meshPickProceed;
  91676. private _previousButtonPressed;
  91677. private _currentPickResult;
  91678. private _previousPickResult;
  91679. private _totalPointersPressed;
  91680. private _doubleClickOccured;
  91681. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91682. cameraToUseForPointers: Nullable<Camera>;
  91683. private _pointerX;
  91684. private _pointerY;
  91685. private _unTranslatedPointerX;
  91686. private _unTranslatedPointerY;
  91687. private _startingPointerPosition;
  91688. private _previousStartingPointerPosition;
  91689. private _startingPointerTime;
  91690. private _previousStartingPointerTime;
  91691. private _pointerCaptures;
  91692. private _timeAccumulator;
  91693. private _currentStepId;
  91694. private _currentInternalStep;
  91695. /** @hidden */
  91696. _mirroredCameraPosition: Nullable<Vector3>;
  91697. /**
  91698. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91699. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91700. */
  91701. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91702. /**
  91703. * Observable event triggered each time an keyboard event is received from the hosting window
  91704. */
  91705. onKeyboardObservable: Observable<KeyboardInfo>;
  91706. private _onKeyDown;
  91707. private _onKeyUp;
  91708. private _onCanvasFocusObserver;
  91709. private _onCanvasBlurObserver;
  91710. private _useRightHandedSystem;
  91711. /**
  91712. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91713. */
  91714. useRightHandedSystem: boolean;
  91715. /**
  91716. * Sets the step Id used by deterministic lock step
  91717. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91718. * @param newStepId defines the step Id
  91719. */
  91720. setStepId(newStepId: number): void;
  91721. /**
  91722. * Gets the step Id used by deterministic lock step
  91723. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91724. * @returns the step Id
  91725. */
  91726. getStepId(): number;
  91727. /**
  91728. * Gets the internal step used by deterministic lock step
  91729. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91730. * @returns the internal step
  91731. */
  91732. getInternalStep(): number;
  91733. private _fogEnabled;
  91734. /**
  91735. * Gets or sets a boolean indicating if fog is enabled on this scene
  91736. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91737. * (Default is true)
  91738. */
  91739. fogEnabled: boolean;
  91740. private _fogMode;
  91741. /**
  91742. * Gets or sets the fog mode to use
  91743. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91744. * | mode | value |
  91745. * | --- | --- |
  91746. * | FOGMODE_NONE | 0 |
  91747. * | FOGMODE_EXP | 1 |
  91748. * | FOGMODE_EXP2 | 2 |
  91749. * | FOGMODE_LINEAR | 3 |
  91750. */
  91751. fogMode: number;
  91752. /**
  91753. * Gets or sets the fog color to use
  91754. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91755. * (Default is Color3(0.2, 0.2, 0.3))
  91756. */
  91757. fogColor: Color3;
  91758. /**
  91759. * Gets or sets the fog density to use
  91760. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91761. * (Default is 0.1)
  91762. */
  91763. fogDensity: number;
  91764. /**
  91765. * Gets or sets the fog start distance to use
  91766. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91767. * (Default is 0)
  91768. */
  91769. fogStart: number;
  91770. /**
  91771. * Gets or sets the fog end distance to use
  91772. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91773. * (Default is 1000)
  91774. */
  91775. fogEnd: number;
  91776. private _shadowsEnabled;
  91777. /**
  91778. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91779. */
  91780. shadowsEnabled: boolean;
  91781. private _lightsEnabled;
  91782. /**
  91783. * Gets or sets a boolean indicating if lights are enabled on this scene
  91784. */
  91785. lightsEnabled: boolean;
  91786. /** All of the active cameras added to this scene. */
  91787. activeCameras: Camera[];
  91788. /** @hidden */
  91789. _activeCamera: Nullable<Camera>;
  91790. /** Gets or sets the current active camera */
  91791. activeCamera: Nullable<Camera>;
  91792. private _defaultMaterial;
  91793. /** The default material used on meshes when no material is affected */
  91794. /** The default material used on meshes when no material is affected */
  91795. defaultMaterial: Material;
  91796. private _texturesEnabled;
  91797. /**
  91798. * Gets or sets a boolean indicating if textures are enabled on this scene
  91799. */
  91800. texturesEnabled: boolean;
  91801. /**
  91802. * Gets or sets a boolean indicating if particles are enabled on this scene
  91803. */
  91804. particlesEnabled: boolean;
  91805. /**
  91806. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91807. */
  91808. spritesEnabled: boolean;
  91809. private _skeletonsEnabled;
  91810. /**
  91811. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91812. */
  91813. skeletonsEnabled: boolean;
  91814. /**
  91815. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91816. */
  91817. lensFlaresEnabled: boolean;
  91818. /**
  91819. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91820. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91821. */
  91822. collisionsEnabled: boolean;
  91823. private _collisionCoordinator;
  91824. /** @hidden */
  91825. readonly collisionCoordinator: ICollisionCoordinator;
  91826. /**
  91827. * Defines the gravity applied to this scene (used only for collisions)
  91828. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91829. */
  91830. gravity: Vector3;
  91831. /**
  91832. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91833. */
  91834. postProcessesEnabled: boolean;
  91835. /**
  91836. * The list of postprocesses added to the scene
  91837. */
  91838. postProcesses: PostProcess[];
  91839. /**
  91840. * Gets the current postprocess manager
  91841. */
  91842. postProcessManager: PostProcessManager;
  91843. /**
  91844. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91845. */
  91846. renderTargetsEnabled: boolean;
  91847. /**
  91848. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  91849. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  91850. */
  91851. dumpNextRenderTargets: boolean;
  91852. /**
  91853. * The list of user defined render targets added to the scene
  91854. */
  91855. customRenderTargets: RenderTargetTexture[];
  91856. /**
  91857. * Defines if texture loading must be delayed
  91858. * If true, textures will only be loaded when they need to be rendered
  91859. */
  91860. useDelayedTextureLoading: boolean;
  91861. /**
  91862. * Gets the list of meshes imported to the scene through SceneLoader
  91863. */
  91864. importedMeshesFiles: String[];
  91865. /**
  91866. * Gets or sets a boolean indicating if probes are enabled on this scene
  91867. */
  91868. probesEnabled: boolean;
  91869. /**
  91870. * Gets or sets the current offline provider to use to store scene data
  91871. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  91872. */
  91873. offlineProvider: IOfflineProvider;
  91874. /**
  91875. * Gets or sets the action manager associated with the scene
  91876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91877. */
  91878. actionManager: AbstractActionManager;
  91879. private _meshesForIntersections;
  91880. /**
  91881. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  91882. */
  91883. proceduralTexturesEnabled: boolean;
  91884. private _engine;
  91885. private _totalVertices;
  91886. /** @hidden */
  91887. _activeIndices: PerfCounter;
  91888. /** @hidden */
  91889. _activeParticles: PerfCounter;
  91890. /** @hidden */
  91891. _activeBones: PerfCounter;
  91892. private _animationRatio;
  91893. /** @hidden */
  91894. _animationTimeLast: number;
  91895. /** @hidden */
  91896. _animationTime: number;
  91897. /**
  91898. * Gets or sets a general scale for animation speed
  91899. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  91900. */
  91901. animationTimeScale: number;
  91902. /** @hidden */
  91903. _cachedMaterial: Nullable<Material>;
  91904. /** @hidden */
  91905. _cachedEffect: Nullable<Effect>;
  91906. /** @hidden */
  91907. _cachedVisibility: Nullable<number>;
  91908. private _renderId;
  91909. private _frameId;
  91910. private _executeWhenReadyTimeoutId;
  91911. private _intermediateRendering;
  91912. private _viewUpdateFlag;
  91913. private _projectionUpdateFlag;
  91914. /** @hidden */
  91915. _toBeDisposed: Nullable<IDisposable>[];
  91916. private _activeRequests;
  91917. /** @hidden */
  91918. _pendingData: any[];
  91919. private _isDisposed;
  91920. /**
  91921. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  91922. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  91923. */
  91924. dispatchAllSubMeshesOfActiveMeshes: boolean;
  91925. private _activeMeshes;
  91926. private _processedMaterials;
  91927. private _renderTargets;
  91928. /** @hidden */
  91929. _activeParticleSystems: SmartArray<IParticleSystem>;
  91930. private _activeSkeletons;
  91931. private _softwareSkinnedMeshes;
  91932. private _renderingManager;
  91933. /** @hidden */
  91934. _activeAnimatables: Animatable[];
  91935. private _transformMatrix;
  91936. private _sceneUbo;
  91937. /** @hidden */
  91938. _viewMatrix: Matrix;
  91939. private _projectionMatrix;
  91940. private _wheelEventName;
  91941. /** @hidden */
  91942. _forcedViewPosition: Nullable<Vector3>;
  91943. /** @hidden */
  91944. _frustumPlanes: Plane[];
  91945. /**
  91946. * Gets the list of frustum planes (built from the active camera)
  91947. */
  91948. readonly frustumPlanes: Plane[];
  91949. /**
  91950. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  91951. * This is useful if there are more lights that the maximum simulteanous authorized
  91952. */
  91953. requireLightSorting: boolean;
  91954. /** @hidden */
  91955. readonly useMaterialMeshMap: boolean;
  91956. /** @hidden */
  91957. readonly useClonedMeshhMap: boolean;
  91958. private _pointerOverMesh;
  91959. private _pickedDownMesh;
  91960. private _pickedUpMesh;
  91961. private _externalData;
  91962. private _uid;
  91963. /**
  91964. * @hidden
  91965. * Backing store of defined scene components.
  91966. */
  91967. _components: ISceneComponent[];
  91968. /**
  91969. * @hidden
  91970. * Backing store of defined scene components.
  91971. */
  91972. _serializableComponents: ISceneSerializableComponent[];
  91973. /**
  91974. * List of components to register on the next registration step.
  91975. */
  91976. private _transientComponents;
  91977. /**
  91978. * Registers the transient components if needed.
  91979. */
  91980. private _registerTransientComponents;
  91981. /**
  91982. * @hidden
  91983. * Add a component to the scene.
  91984. * Note that the ccomponent could be registered on th next frame if this is called after
  91985. * the register component stage.
  91986. * @param component Defines the component to add to the scene
  91987. */
  91988. _addComponent(component: ISceneComponent): void;
  91989. /**
  91990. * @hidden
  91991. * Gets a component from the scene.
  91992. * @param name defines the name of the component to retrieve
  91993. * @returns the component or null if not present
  91994. */
  91995. _getComponent(name: string): Nullable<ISceneComponent>;
  91996. /**
  91997. * @hidden
  91998. * Defines the actions happening before camera updates.
  91999. */
  92000. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92001. /**
  92002. * @hidden
  92003. * Defines the actions happening before clear the canvas.
  92004. */
  92005. _beforeClearStage: Stage<SimpleStageAction>;
  92006. /**
  92007. * @hidden
  92008. * Defines the actions when collecting render targets for the frame.
  92009. */
  92010. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92011. /**
  92012. * @hidden
  92013. * Defines the actions happening for one camera in the frame.
  92014. */
  92015. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92016. /**
  92017. * @hidden
  92018. * Defines the actions happening during the per mesh ready checks.
  92019. */
  92020. _isReadyForMeshStage: Stage<MeshStageAction>;
  92021. /**
  92022. * @hidden
  92023. * Defines the actions happening before evaluate active mesh checks.
  92024. */
  92025. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92026. /**
  92027. * @hidden
  92028. * Defines the actions happening during the evaluate sub mesh checks.
  92029. */
  92030. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92031. /**
  92032. * @hidden
  92033. * Defines the actions happening during the active mesh stage.
  92034. */
  92035. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92036. /**
  92037. * @hidden
  92038. * Defines the actions happening during the per camera render target step.
  92039. */
  92040. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92041. /**
  92042. * @hidden
  92043. * Defines the actions happening just before the active camera is drawing.
  92044. */
  92045. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92046. /**
  92047. * @hidden
  92048. * Defines the actions happening just before a render target is drawing.
  92049. */
  92050. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92051. /**
  92052. * @hidden
  92053. * Defines the actions happening just before a rendering group is drawing.
  92054. */
  92055. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92056. /**
  92057. * @hidden
  92058. * Defines the actions happening just before a mesh is drawing.
  92059. */
  92060. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92061. /**
  92062. * @hidden
  92063. * Defines the actions happening just after a mesh has been drawn.
  92064. */
  92065. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92066. /**
  92067. * @hidden
  92068. * Defines the actions happening just after a rendering group has been drawn.
  92069. */
  92070. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92071. /**
  92072. * @hidden
  92073. * Defines the actions happening just after the active camera has been drawn.
  92074. */
  92075. _afterCameraDrawStage: Stage<CameraStageAction>;
  92076. /**
  92077. * @hidden
  92078. * Defines the actions happening just after a render target has been drawn.
  92079. */
  92080. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92081. /**
  92082. * @hidden
  92083. * Defines the actions happening just after rendering all cameras and computing intersections.
  92084. */
  92085. _afterRenderStage: Stage<SimpleStageAction>;
  92086. /**
  92087. * @hidden
  92088. * Defines the actions happening when a pointer move event happens.
  92089. */
  92090. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92091. /**
  92092. * @hidden
  92093. * Defines the actions happening when a pointer down event happens.
  92094. */
  92095. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92096. /**
  92097. * @hidden
  92098. * Defines the actions happening when a pointer up event happens.
  92099. */
  92100. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92101. /**
  92102. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92103. */
  92104. private geometriesByUniqueId;
  92105. /**
  92106. * Creates a new Scene
  92107. * @param engine defines the engine to use to render this scene
  92108. * @param options defines the scene options
  92109. */
  92110. constructor(engine: Engine, options?: SceneOptions);
  92111. /**
  92112. * Gets a string idenfifying the name of the class
  92113. * @returns "Scene" string
  92114. */
  92115. getClassName(): string;
  92116. private _defaultMeshCandidates;
  92117. /**
  92118. * @hidden
  92119. */
  92120. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92121. private _defaultSubMeshCandidates;
  92122. /**
  92123. * @hidden
  92124. */
  92125. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92126. /**
  92127. * Sets the default candidate providers for the scene.
  92128. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92129. * and getCollidingSubMeshCandidates to their default function
  92130. */
  92131. setDefaultCandidateProviders(): void;
  92132. /**
  92133. * Gets the mesh that is currently under the pointer
  92134. */
  92135. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92136. /**
  92137. * Gets or sets the current on-screen X position of the pointer
  92138. */
  92139. pointerX: number;
  92140. /**
  92141. * Gets or sets the current on-screen Y position of the pointer
  92142. */
  92143. pointerY: number;
  92144. /**
  92145. * Gets the cached material (ie. the latest rendered one)
  92146. * @returns the cached material
  92147. */
  92148. getCachedMaterial(): Nullable<Material>;
  92149. /**
  92150. * Gets the cached effect (ie. the latest rendered one)
  92151. * @returns the cached effect
  92152. */
  92153. getCachedEffect(): Nullable<Effect>;
  92154. /**
  92155. * Gets the cached visibility state (ie. the latest rendered one)
  92156. * @returns the cached visibility state
  92157. */
  92158. getCachedVisibility(): Nullable<number>;
  92159. /**
  92160. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92161. * @param material defines the current material
  92162. * @param effect defines the current effect
  92163. * @param visibility defines the current visibility state
  92164. * @returns true if one parameter is not cached
  92165. */
  92166. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92167. /**
  92168. * Gets the engine associated with the scene
  92169. * @returns an Engine
  92170. */
  92171. getEngine(): Engine;
  92172. /**
  92173. * Gets the total number of vertices rendered per frame
  92174. * @returns the total number of vertices rendered per frame
  92175. */
  92176. getTotalVertices(): number;
  92177. /**
  92178. * Gets the performance counter for total vertices
  92179. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92180. */
  92181. readonly totalVerticesPerfCounter: PerfCounter;
  92182. /**
  92183. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92184. * @returns the total number of active indices rendered per frame
  92185. */
  92186. getActiveIndices(): number;
  92187. /**
  92188. * Gets the performance counter for active indices
  92189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92190. */
  92191. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92192. /**
  92193. * Gets the total number of active particles rendered per frame
  92194. * @returns the total number of active particles rendered per frame
  92195. */
  92196. getActiveParticles(): number;
  92197. /**
  92198. * Gets the performance counter for active particles
  92199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92200. */
  92201. readonly activeParticlesPerfCounter: PerfCounter;
  92202. /**
  92203. * Gets the total number of active bones rendered per frame
  92204. * @returns the total number of active bones rendered per frame
  92205. */
  92206. getActiveBones(): number;
  92207. /**
  92208. * Gets the performance counter for active bones
  92209. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92210. */
  92211. readonly activeBonesPerfCounter: PerfCounter;
  92212. /**
  92213. * Gets the array of active meshes
  92214. * @returns an array of AbstractMesh
  92215. */
  92216. getActiveMeshes(): SmartArray<AbstractMesh>;
  92217. /**
  92218. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92219. * @returns a number
  92220. */
  92221. getAnimationRatio(): number;
  92222. /**
  92223. * Gets an unique Id for the current render phase
  92224. * @returns a number
  92225. */
  92226. getRenderId(): number;
  92227. /**
  92228. * Gets an unique Id for the current frame
  92229. * @returns a number
  92230. */
  92231. getFrameId(): number;
  92232. /** Call this function if you want to manually increment the render Id*/
  92233. incrementRenderId(): void;
  92234. private _updatePointerPosition;
  92235. private _createUbo;
  92236. private _setRayOnPointerInfo;
  92237. /**
  92238. * Use this method to simulate a pointer move on a mesh
  92239. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92240. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92241. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92242. * @returns the current scene
  92243. */
  92244. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92245. private _processPointerMove;
  92246. private _checkPrePointerObservable;
  92247. /**
  92248. * Use this method to simulate a pointer down on a mesh
  92249. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92250. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92251. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92252. * @returns the current scene
  92253. */
  92254. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92255. private _processPointerDown;
  92256. /**
  92257. * Use this method to simulate a pointer up on a mesh
  92258. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92259. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92260. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92261. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92262. * @returns the current scene
  92263. */
  92264. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92265. private _processPointerUp;
  92266. /**
  92267. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92268. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92269. * @returns true if the pointer was captured
  92270. */
  92271. isPointerCaptured(pointerId?: number): boolean;
  92272. /** @hidden */
  92273. _isPointerSwiping(): boolean;
  92274. /**
  92275. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92276. * @param attachUp defines if you want to attach events to pointerup
  92277. * @param attachDown defines if you want to attach events to pointerdown
  92278. * @param attachMove defines if you want to attach events to pointermove
  92279. */
  92280. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92281. /** Detaches all event handlers*/
  92282. detachControl(): void;
  92283. /**
  92284. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92285. * Delay loaded resources are not taking in account
  92286. * @return true if all required resources are ready
  92287. */
  92288. isReady(): boolean;
  92289. /** Resets all cached information relative to material (including effect and visibility) */
  92290. resetCachedMaterial(): void;
  92291. /**
  92292. * Registers a function to be called before every frame render
  92293. * @param func defines the function to register
  92294. */
  92295. registerBeforeRender(func: () => void): void;
  92296. /**
  92297. * Unregisters a function called before every frame render
  92298. * @param func defines the function to unregister
  92299. */
  92300. unregisterBeforeRender(func: () => void): void;
  92301. /**
  92302. * Registers a function to be called after every frame render
  92303. * @param func defines the function to register
  92304. */
  92305. registerAfterRender(func: () => void): void;
  92306. /**
  92307. * Unregisters a function called after every frame render
  92308. * @param func defines the function to unregister
  92309. */
  92310. unregisterAfterRender(func: () => void): void;
  92311. private _executeOnceBeforeRender;
  92312. /**
  92313. * The provided function will run before render once and will be disposed afterwards.
  92314. * A timeout delay can be provided so that the function will be executed in N ms.
  92315. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92316. * @param func The function to be executed.
  92317. * @param timeout optional delay in ms
  92318. */
  92319. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92320. /** @hidden */
  92321. _addPendingData(data: any): void;
  92322. /** @hidden */
  92323. _removePendingData(data: any): void;
  92324. /**
  92325. * Returns the number of items waiting to be loaded
  92326. * @returns the number of items waiting to be loaded
  92327. */
  92328. getWaitingItemsCount(): number;
  92329. /**
  92330. * Returns a boolean indicating if the scene is still loading data
  92331. */
  92332. readonly isLoading: boolean;
  92333. /**
  92334. * Registers a function to be executed when the scene is ready
  92335. * @param {Function} func - the function to be executed
  92336. */
  92337. executeWhenReady(func: () => void): void;
  92338. /**
  92339. * Returns a promise that resolves when the scene is ready
  92340. * @returns A promise that resolves when the scene is ready
  92341. */
  92342. whenReadyAsync(): Promise<void>;
  92343. /** @hidden */
  92344. _checkIsReady(): void;
  92345. /**
  92346. * Gets all animatable attached to the scene
  92347. */
  92348. readonly animatables: Animatable[];
  92349. /**
  92350. * Resets the last animation time frame.
  92351. * Useful to override when animations start running when loading a scene for the first time.
  92352. */
  92353. resetLastAnimationTimeFrame(): void;
  92354. /**
  92355. * Gets the current view matrix
  92356. * @returns a Matrix
  92357. */
  92358. getViewMatrix(): Matrix;
  92359. /**
  92360. * Gets the current projection matrix
  92361. * @returns a Matrix
  92362. */
  92363. getProjectionMatrix(): Matrix;
  92364. /**
  92365. * Gets the current transform matrix
  92366. * @returns a Matrix made of View * Projection
  92367. */
  92368. getTransformMatrix(): Matrix;
  92369. /**
  92370. * Sets the current transform matrix
  92371. * @param viewL defines the View matrix to use
  92372. * @param projectionL defines the Projection matrix to use
  92373. * @param viewR defines the right View matrix to use (if provided)
  92374. * @param projectionR defines the right Projection matrix to use (if provided)
  92375. */
  92376. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92377. /**
  92378. * Gets the uniform buffer used to store scene data
  92379. * @returns a UniformBuffer
  92380. */
  92381. getSceneUniformBuffer(): UniformBuffer;
  92382. /**
  92383. * Gets an unique (relatively to the current scene) Id
  92384. * @returns an unique number for the scene
  92385. */
  92386. getUniqueId(): number;
  92387. /**
  92388. * Add a mesh to the list of scene's meshes
  92389. * @param newMesh defines the mesh to add
  92390. * @param recursive if all child meshes should also be added to the scene
  92391. */
  92392. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92393. /**
  92394. * Remove a mesh for the list of scene's meshes
  92395. * @param toRemove defines the mesh to remove
  92396. * @param recursive if all child meshes should also be removed from the scene
  92397. * @returns the index where the mesh was in the mesh list
  92398. */
  92399. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92400. /**
  92401. * Add a transform node to the list of scene's transform nodes
  92402. * @param newTransformNode defines the transform node to add
  92403. */
  92404. addTransformNode(newTransformNode: TransformNode): void;
  92405. /**
  92406. * Remove a transform node for the list of scene's transform nodes
  92407. * @param toRemove defines the transform node to remove
  92408. * @returns the index where the transform node was in the transform node list
  92409. */
  92410. removeTransformNode(toRemove: TransformNode): number;
  92411. /**
  92412. * Remove a skeleton for the list of scene's skeletons
  92413. * @param toRemove defines the skeleton to remove
  92414. * @returns the index where the skeleton was in the skeleton list
  92415. */
  92416. removeSkeleton(toRemove: Skeleton): number;
  92417. /**
  92418. * Remove a morph target for the list of scene's morph targets
  92419. * @param toRemove defines the morph target to remove
  92420. * @returns the index where the morph target was in the morph target list
  92421. */
  92422. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92423. /**
  92424. * Remove a light for the list of scene's lights
  92425. * @param toRemove defines the light to remove
  92426. * @returns the index where the light was in the light list
  92427. */
  92428. removeLight(toRemove: Light): number;
  92429. /**
  92430. * Remove a camera for the list of scene's cameras
  92431. * @param toRemove defines the camera to remove
  92432. * @returns the index where the camera was in the camera list
  92433. */
  92434. removeCamera(toRemove: Camera): number;
  92435. /**
  92436. * Remove a particle system for the list of scene's particle systems
  92437. * @param toRemove defines the particle system to remove
  92438. * @returns the index where the particle system was in the particle system list
  92439. */
  92440. removeParticleSystem(toRemove: IParticleSystem): number;
  92441. /**
  92442. * Remove a animation for the list of scene's animations
  92443. * @param toRemove defines the animation to remove
  92444. * @returns the index where the animation was in the animation list
  92445. */
  92446. removeAnimation(toRemove: Animation): number;
  92447. /**
  92448. * Removes the given animation group from this scene.
  92449. * @param toRemove The animation group to remove
  92450. * @returns The index of the removed animation group
  92451. */
  92452. removeAnimationGroup(toRemove: AnimationGroup): number;
  92453. /**
  92454. * Removes the given multi-material from this scene.
  92455. * @param toRemove The multi-material to remove
  92456. * @returns The index of the removed multi-material
  92457. */
  92458. removeMultiMaterial(toRemove: MultiMaterial): number;
  92459. /**
  92460. * Removes the given material from this scene.
  92461. * @param toRemove The material to remove
  92462. * @returns The index of the removed material
  92463. */
  92464. removeMaterial(toRemove: Material): number;
  92465. /**
  92466. * Removes the given action manager from this scene.
  92467. * @param toRemove The action manager to remove
  92468. * @returns The index of the removed action manager
  92469. */
  92470. removeActionManager(toRemove: AbstractActionManager): number;
  92471. /**
  92472. * Removes the given texture from this scene.
  92473. * @param toRemove The texture to remove
  92474. * @returns The index of the removed texture
  92475. */
  92476. removeTexture(toRemove: BaseTexture): number;
  92477. /**
  92478. * Adds the given light to this scene
  92479. * @param newLight The light to add
  92480. */
  92481. addLight(newLight: Light): void;
  92482. /**
  92483. * Sorts the list list based on light priorities
  92484. */
  92485. sortLightsByPriority(): void;
  92486. /**
  92487. * Adds the given camera to this scene
  92488. * @param newCamera The camera to add
  92489. */
  92490. addCamera(newCamera: Camera): void;
  92491. /**
  92492. * Adds the given skeleton to this scene
  92493. * @param newSkeleton The skeleton to add
  92494. */
  92495. addSkeleton(newSkeleton: Skeleton): void;
  92496. /**
  92497. * Adds the given particle system to this scene
  92498. * @param newParticleSystem The particle system to add
  92499. */
  92500. addParticleSystem(newParticleSystem: IParticleSystem): void;
  92501. /**
  92502. * Adds the given animation to this scene
  92503. * @param newAnimation The animation to add
  92504. */
  92505. addAnimation(newAnimation: Animation): void;
  92506. /**
  92507. * Adds the given animation group to this scene.
  92508. * @param newAnimationGroup The animation group to add
  92509. */
  92510. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  92511. /**
  92512. * Adds the given multi-material to this scene
  92513. * @param newMultiMaterial The multi-material to add
  92514. */
  92515. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  92516. /**
  92517. * Adds the given material to this scene
  92518. * @param newMaterial The material to add
  92519. */
  92520. addMaterial(newMaterial: Material): void;
  92521. /**
  92522. * Adds the given morph target to this scene
  92523. * @param newMorphTargetManager The morph target to add
  92524. */
  92525. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  92526. /**
  92527. * Adds the given geometry to this scene
  92528. * @param newGeometry The geometry to add
  92529. */
  92530. addGeometry(newGeometry: Geometry): void;
  92531. /**
  92532. * Adds the given action manager to this scene
  92533. * @param newActionManager The action manager to add
  92534. */
  92535. addActionManager(newActionManager: AbstractActionManager): void;
  92536. /**
  92537. * Adds the given texture to this scene.
  92538. * @param newTexture The texture to add
  92539. */
  92540. addTexture(newTexture: BaseTexture): void;
  92541. /**
  92542. * Switch active camera
  92543. * @param newCamera defines the new active camera
  92544. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  92545. */
  92546. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92547. /**
  92548. * sets the active camera of the scene using its ID
  92549. * @param id defines the camera's ID
  92550. * @return the new active camera or null if none found.
  92551. */
  92552. setActiveCameraByID(id: string): Nullable<Camera>;
  92553. /**
  92554. * sets the active camera of the scene using its name
  92555. * @param name defines the camera's name
  92556. * @returns the new active camera or null if none found.
  92557. */
  92558. setActiveCameraByName(name: string): Nullable<Camera>;
  92559. /**
  92560. * get an animation group using its name
  92561. * @param name defines the material's name
  92562. * @return the animation group or null if none found.
  92563. */
  92564. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92565. /**
  92566. * Get a material using its unique id
  92567. * @param uniqueId defines the material's unique id
  92568. * @return the material or null if none found.
  92569. */
  92570. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92571. /**
  92572. * get a material using its id
  92573. * @param id defines the material's ID
  92574. * @return the material or null if none found.
  92575. */
  92576. getMaterialByID(id: string): Nullable<Material>;
  92577. /**
  92578. * Gets a material using its name
  92579. * @param name defines the material's name
  92580. * @return the material or null if none found.
  92581. */
  92582. getMaterialByName(name: string): Nullable<Material>;
  92583. /**
  92584. * Gets a camera using its id
  92585. * @param id defines the id to look for
  92586. * @returns the camera or null if not found
  92587. */
  92588. getCameraByID(id: string): Nullable<Camera>;
  92589. /**
  92590. * Gets a camera using its unique id
  92591. * @param uniqueId defines the unique id to look for
  92592. * @returns the camera or null if not found
  92593. */
  92594. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92595. /**
  92596. * Gets a camera using its name
  92597. * @param name defines the camera's name
  92598. * @return the camera or null if none found.
  92599. */
  92600. getCameraByName(name: string): Nullable<Camera>;
  92601. /**
  92602. * Gets a bone using its id
  92603. * @param id defines the bone's id
  92604. * @return the bone or null if not found
  92605. */
  92606. getBoneByID(id: string): Nullable<Bone>;
  92607. /**
  92608. * Gets a bone using its id
  92609. * @param name defines the bone's name
  92610. * @return the bone or null if not found
  92611. */
  92612. getBoneByName(name: string): Nullable<Bone>;
  92613. /**
  92614. * Gets a light node using its name
  92615. * @param name defines the the light's name
  92616. * @return the light or null if none found.
  92617. */
  92618. getLightByName(name: string): Nullable<Light>;
  92619. /**
  92620. * Gets a light node using its id
  92621. * @param id defines the light's id
  92622. * @return the light or null if none found.
  92623. */
  92624. getLightByID(id: string): Nullable<Light>;
  92625. /**
  92626. * Gets a light node using its scene-generated unique ID
  92627. * @param uniqueId defines the light's unique id
  92628. * @return the light or null if none found.
  92629. */
  92630. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92631. /**
  92632. * Gets a particle system by id
  92633. * @param id defines the particle system id
  92634. * @return the corresponding system or null if none found
  92635. */
  92636. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92637. /**
  92638. * Gets a geometry using its ID
  92639. * @param id defines the geometry's id
  92640. * @return the geometry or null if none found.
  92641. */
  92642. getGeometryByID(id: string): Nullable<Geometry>;
  92643. private _getGeometryByUniqueID;
  92644. /**
  92645. * Add a new geometry to this scene
  92646. * @param geometry defines the geometry to be added to the scene.
  92647. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92648. * @return a boolean defining if the geometry was added or not
  92649. */
  92650. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92651. /**
  92652. * Removes an existing geometry
  92653. * @param geometry defines the geometry to be removed from the scene
  92654. * @return a boolean defining if the geometry was removed or not
  92655. */
  92656. removeGeometry(geometry: Geometry): boolean;
  92657. /**
  92658. * Gets the list of geometries attached to the scene
  92659. * @returns an array of Geometry
  92660. */
  92661. getGeometries(): Geometry[];
  92662. /**
  92663. * Gets the first added mesh found of a given ID
  92664. * @param id defines the id to search for
  92665. * @return the mesh found or null if not found at all
  92666. */
  92667. getMeshByID(id: string): Nullable<AbstractMesh>;
  92668. /**
  92669. * Gets a list of meshes using their id
  92670. * @param id defines the id to search for
  92671. * @returns a list of meshes
  92672. */
  92673. getMeshesByID(id: string): Array<AbstractMesh>;
  92674. /**
  92675. * Gets the first added transform node found of a given ID
  92676. * @param id defines the id to search for
  92677. * @return the found transform node or null if not found at all.
  92678. */
  92679. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92680. /**
  92681. * Gets a transform node with its auto-generated unique id
  92682. * @param uniqueId efines the unique id to search for
  92683. * @return the found transform node or null if not found at all.
  92684. */
  92685. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92686. /**
  92687. * Gets a list of transform nodes using their id
  92688. * @param id defines the id to search for
  92689. * @returns a list of transform nodes
  92690. */
  92691. getTransformNodesByID(id: string): Array<TransformNode>;
  92692. /**
  92693. * Gets a mesh with its auto-generated unique id
  92694. * @param uniqueId defines the unique id to search for
  92695. * @return the found mesh or null if not found at all.
  92696. */
  92697. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92698. /**
  92699. * Gets a the last added mesh using a given id
  92700. * @param id defines the id to search for
  92701. * @return the found mesh or null if not found at all.
  92702. */
  92703. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92704. /**
  92705. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92706. * @param id defines the id to search for
  92707. * @return the found node or null if not found at all
  92708. */
  92709. getLastEntryByID(id: string): Nullable<Node>;
  92710. /**
  92711. * Gets a node (Mesh, Camera, Light) using a given id
  92712. * @param id defines the id to search for
  92713. * @return the found node or null if not found at all
  92714. */
  92715. getNodeByID(id: string): Nullable<Node>;
  92716. /**
  92717. * Gets a node (Mesh, Camera, Light) using a given name
  92718. * @param name defines the name to search for
  92719. * @return the found node or null if not found at all.
  92720. */
  92721. getNodeByName(name: string): Nullable<Node>;
  92722. /**
  92723. * Gets a mesh using a given name
  92724. * @param name defines the name to search for
  92725. * @return the found mesh or null if not found at all.
  92726. */
  92727. getMeshByName(name: string): Nullable<AbstractMesh>;
  92728. /**
  92729. * Gets a transform node using a given name
  92730. * @param name defines the name to search for
  92731. * @return the found transform node or null if not found at all.
  92732. */
  92733. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92734. /**
  92735. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92736. * @param id defines the id to search for
  92737. * @return the found skeleton or null if not found at all.
  92738. */
  92739. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92740. /**
  92741. * Gets a skeleton using a given auto generated unique id
  92742. * @param uniqueId defines the unique id to search for
  92743. * @return the found skeleton or null if not found at all.
  92744. */
  92745. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92746. /**
  92747. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92748. * @param id defines the id to search for
  92749. * @return the found skeleton or null if not found at all.
  92750. */
  92751. getSkeletonById(id: string): Nullable<Skeleton>;
  92752. /**
  92753. * Gets a skeleton using a given name
  92754. * @param name defines the name to search for
  92755. * @return the found skeleton or null if not found at all.
  92756. */
  92757. getSkeletonByName(name: string): Nullable<Skeleton>;
  92758. /**
  92759. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92760. * @param id defines the id to search for
  92761. * @return the found morph target manager or null if not found at all.
  92762. */
  92763. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92764. /**
  92765. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92766. * @param id defines the id to search for
  92767. * @return the found morph target or null if not found at all.
  92768. */
  92769. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92770. /**
  92771. * Gets a boolean indicating if the given mesh is active
  92772. * @param mesh defines the mesh to look for
  92773. * @returns true if the mesh is in the active list
  92774. */
  92775. isActiveMesh(mesh: AbstractMesh): boolean;
  92776. /**
  92777. * Return a unique id as a string which can serve as an identifier for the scene
  92778. */
  92779. readonly uid: string;
  92780. /**
  92781. * Add an externaly attached data from its key.
  92782. * This method call will fail and return false, if such key already exists.
  92783. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92784. * @param key the unique key that identifies the data
  92785. * @param data the data object to associate to the key for this Engine instance
  92786. * @return true if no such key were already present and the data was added successfully, false otherwise
  92787. */
  92788. addExternalData<T>(key: string, data: T): boolean;
  92789. /**
  92790. * Get an externaly attached data from its key
  92791. * @param key the unique key that identifies the data
  92792. * @return the associated data, if present (can be null), or undefined if not present
  92793. */
  92794. getExternalData<T>(key: string): Nullable<T>;
  92795. /**
  92796. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92797. * @param key the unique key that identifies the data
  92798. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92799. * @return the associated data, can be null if the factory returned null.
  92800. */
  92801. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92802. /**
  92803. * Remove an externaly attached data from the Engine instance
  92804. * @param key the unique key that identifies the data
  92805. * @return true if the data was successfully removed, false if it doesn't exist
  92806. */
  92807. removeExternalData(key: string): boolean;
  92808. private _evaluateSubMesh;
  92809. /**
  92810. * Clear the processed materials smart array preventing retention point in material dispose.
  92811. */
  92812. freeProcessedMaterials(): void;
  92813. private _preventFreeActiveMeshesAndRenderingGroups;
  92814. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92815. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92816. * when disposing several meshes in a row or a hierarchy of meshes.
  92817. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92818. */
  92819. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92820. /**
  92821. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92822. */
  92823. freeActiveMeshes(): void;
  92824. /**
  92825. * Clear the info related to rendering groups preventing retention points during dispose.
  92826. */
  92827. freeRenderingGroups(): void;
  92828. /** @hidden */
  92829. _isInIntermediateRendering(): boolean;
  92830. /**
  92831. * Lambda returning the list of potentially active meshes.
  92832. */
  92833. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92834. /**
  92835. * Lambda returning the list of potentially active sub meshes.
  92836. */
  92837. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92838. /**
  92839. * Lambda returning the list of potentially intersecting sub meshes.
  92840. */
  92841. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92842. /**
  92843. * Lambda returning the list of potentially colliding sub meshes.
  92844. */
  92845. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92846. private _activeMeshesFrozen;
  92847. /**
  92848. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  92849. * @returns the current scene
  92850. */
  92851. freezeActiveMeshes(): Scene;
  92852. /**
  92853. * Use this function to restart evaluating active meshes on every frame
  92854. * @returns the current scene
  92855. */
  92856. unfreezeActiveMeshes(): Scene;
  92857. private _evaluateActiveMeshes;
  92858. private _activeMesh;
  92859. /**
  92860. * Update the transform matrix to update from the current active camera
  92861. * @param force defines a boolean used to force the update even if cache is up to date
  92862. */
  92863. updateTransformMatrix(force?: boolean): void;
  92864. private _bindFrameBuffer;
  92865. /** @hidden */
  92866. _allowPostProcessClearColor: boolean;
  92867. /** @hidden */
  92868. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  92869. private _processSubCameras;
  92870. private _checkIntersections;
  92871. /** @hidden */
  92872. _advancePhysicsEngineStep(step: number): void;
  92873. /**
  92874. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  92875. */
  92876. getDeterministicFrameTime: () => number;
  92877. /** @hidden */
  92878. _animate(): void;
  92879. /** Execute all animations (for a frame) */
  92880. animate(): void;
  92881. /**
  92882. * Render the scene
  92883. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  92884. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  92885. */
  92886. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  92887. /**
  92888. * Freeze all materials
  92889. * A frozen material will not be updatable but should be faster to render
  92890. */
  92891. freezeMaterials(): void;
  92892. /**
  92893. * Unfreeze all materials
  92894. * A frozen material will not be updatable but should be faster to render
  92895. */
  92896. unfreezeMaterials(): void;
  92897. /**
  92898. * Releases all held ressources
  92899. */
  92900. dispose(): void;
  92901. /**
  92902. * Gets if the scene is already disposed
  92903. */
  92904. readonly isDisposed: boolean;
  92905. /**
  92906. * Call this function to reduce memory footprint of the scene.
  92907. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  92908. */
  92909. clearCachedVertexData(): void;
  92910. /**
  92911. * This function will remove the local cached buffer data from texture.
  92912. * It will save memory but will prevent the texture from being rebuilt
  92913. */
  92914. cleanCachedTextureBuffer(): void;
  92915. /**
  92916. * Get the world extend vectors with an optional filter
  92917. *
  92918. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  92919. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  92920. */
  92921. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  92922. min: Vector3;
  92923. max: Vector3;
  92924. };
  92925. /**
  92926. * Creates a ray that can be used to pick in the scene
  92927. * @param x defines the x coordinate of the origin (on-screen)
  92928. * @param y defines the y coordinate of the origin (on-screen)
  92929. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92930. * @param camera defines the camera to use for the picking
  92931. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92932. * @returns a Ray
  92933. */
  92934. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  92935. /**
  92936. * Creates a ray that can be used to pick in the scene
  92937. * @param x defines the x coordinate of the origin (on-screen)
  92938. * @param y defines the y coordinate of the origin (on-screen)
  92939. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92940. * @param result defines the ray where to store the picking ray
  92941. * @param camera defines the camera to use for the picking
  92942. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92943. * @returns the current scene
  92944. */
  92945. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  92946. /**
  92947. * Creates a ray that can be used to pick in the scene
  92948. * @param x defines the x coordinate of the origin (on-screen)
  92949. * @param y defines the y coordinate of the origin (on-screen)
  92950. * @param camera defines the camera to use for the picking
  92951. * @returns a Ray
  92952. */
  92953. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  92954. /**
  92955. * Creates a ray that can be used to pick in the scene
  92956. * @param x defines the x coordinate of the origin (on-screen)
  92957. * @param y defines the y coordinate of the origin (on-screen)
  92958. * @param result defines the ray where to store the picking ray
  92959. * @param camera defines the camera to use for the picking
  92960. * @returns the current scene
  92961. */
  92962. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  92963. /** Launch a ray to try to pick a mesh in the scene
  92964. * @param x position on screen
  92965. * @param y position on screen
  92966. * @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
  92967. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  92968. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92969. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92970. * @returns a PickingInfo
  92971. */
  92972. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  92973. /** Use the given ray to pick a mesh in the scene
  92974. * @param ray The ray to use to pick meshes
  92975. * @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
  92976. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  92977. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92978. * @returns a PickingInfo
  92979. */
  92980. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92981. /**
  92982. * Launch a ray to try to pick a mesh in the scene
  92983. * @param x X position on screen
  92984. * @param y Y position on screen
  92985. * @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
  92986. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92987. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92988. * @returns an array of PickingInfo
  92989. */
  92990. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92991. /**
  92992. * Launch a ray to try to pick a mesh in the scene
  92993. * @param ray Ray to use
  92994. * @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
  92995. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92996. * @returns an array of PickingInfo
  92997. */
  92998. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92999. /**
  93000. * Force the value of meshUnderPointer
  93001. * @param mesh defines the mesh to use
  93002. */
  93003. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93004. /**
  93005. * Gets the mesh under the pointer
  93006. * @returns a Mesh or null if no mesh is under the pointer
  93007. */
  93008. getPointerOverMesh(): Nullable<AbstractMesh>;
  93009. /** @hidden */
  93010. _rebuildGeometries(): void;
  93011. /** @hidden */
  93012. _rebuildTextures(): void;
  93013. private _getByTags;
  93014. /**
  93015. * Get a list of meshes by tags
  93016. * @param tagsQuery defines the tags query to use
  93017. * @param forEach defines a predicate used to filter results
  93018. * @returns an array of Mesh
  93019. */
  93020. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93021. /**
  93022. * Get a list of cameras 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 Camera
  93026. */
  93027. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93028. /**
  93029. * Get a list of lights 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 Light
  93033. */
  93034. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93035. /**
  93036. * Get a list of materials 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 Material
  93040. */
  93041. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93042. /**
  93043. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93044. * This allowed control for front to back rendering or reversly depending of the special needs.
  93045. *
  93046. * @param renderingGroupId The rendering group id corresponding to its index
  93047. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93048. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93049. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93050. */
  93051. 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;
  93052. /**
  93053. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93054. *
  93055. * @param renderingGroupId The rendering group id corresponding to its index
  93056. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93057. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93058. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93059. */
  93060. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93061. /**
  93062. * Gets the current auto clear configuration for one rendering group of the rendering
  93063. * manager.
  93064. * @param index the rendering group index to get the information for
  93065. * @returns The auto clear setup for the requested rendering group
  93066. */
  93067. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93068. private _blockMaterialDirtyMechanism;
  93069. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93070. blockMaterialDirtyMechanism: boolean;
  93071. /**
  93072. * Will flag all materials as dirty to trigger new shader compilation
  93073. * @param flag defines the flag used to specify which material part must be marked as dirty
  93074. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93075. */
  93076. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93077. /** @hidden */
  93078. _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;
  93079. /** @hidden */
  93080. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93081. }
  93082. }
  93083. declare module BABYLON {
  93084. /**
  93085. * Set of assets to keep when moving a scene into an asset container.
  93086. */
  93087. export class KeepAssets extends AbstractScene {
  93088. }
  93089. /**
  93090. * Container with a set of assets that can be added or removed from a scene.
  93091. */
  93092. export class AssetContainer extends AbstractScene {
  93093. /**
  93094. * The scene the AssetContainer belongs to.
  93095. */
  93096. scene: Scene;
  93097. /**
  93098. * Instantiates an AssetContainer.
  93099. * @param scene The scene the AssetContainer belongs to.
  93100. */
  93101. constructor(scene: Scene);
  93102. /**
  93103. * Adds all the assets from the container to the scene.
  93104. */
  93105. addAllToScene(): void;
  93106. /**
  93107. * Removes all the assets in the container from the scene
  93108. */
  93109. removeAllFromScene(): void;
  93110. /**
  93111. * Disposes all the assets in the container
  93112. */
  93113. dispose(): void;
  93114. private _moveAssets;
  93115. /**
  93116. * Removes all the assets contained in the scene and adds them to the container.
  93117. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93118. */
  93119. moveAllFromScene(keepAssets?: KeepAssets): void;
  93120. /**
  93121. * 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.
  93122. * @returns the root mesh
  93123. */
  93124. createRootMesh(): Mesh;
  93125. }
  93126. }
  93127. declare module BABYLON {
  93128. /**
  93129. * Defines how the parser contract is defined.
  93130. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93131. */
  93132. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93133. /**
  93134. * Defines how the individual parser contract is defined.
  93135. * These parser can parse an individual asset
  93136. */
  93137. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93138. /**
  93139. * Base class of the scene acting as a container for the different elements composing a scene.
  93140. * This class is dynamically extended by the different components of the scene increasing
  93141. * flexibility and reducing coupling
  93142. */
  93143. export abstract class AbstractScene {
  93144. /**
  93145. * Stores the list of available parsers in the application.
  93146. */
  93147. private static _BabylonFileParsers;
  93148. /**
  93149. * Stores the list of available individual parsers in the application.
  93150. */
  93151. private static _IndividualBabylonFileParsers;
  93152. /**
  93153. * Adds a parser in the list of available ones
  93154. * @param name Defines the name of the parser
  93155. * @param parser Defines the parser to add
  93156. */
  93157. static AddParser(name: string, parser: BabylonFileParser): void;
  93158. /**
  93159. * Gets a general parser from the list of avaialble ones
  93160. * @param name Defines the name of the parser
  93161. * @returns the requested parser or null
  93162. */
  93163. static GetParser(name: string): Nullable<BabylonFileParser>;
  93164. /**
  93165. * Adds n individual parser in the list of available ones
  93166. * @param name Defines the name of the parser
  93167. * @param parser Defines the parser to add
  93168. */
  93169. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93170. /**
  93171. * Gets an individual parser from the list of avaialble ones
  93172. * @param name Defines the name of the parser
  93173. * @returns the requested parser or null
  93174. */
  93175. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93176. /**
  93177. * Parser json data and populate both a scene and its associated container object
  93178. * @param jsonData Defines the data to parse
  93179. * @param scene Defines the scene to parse the data for
  93180. * @param container Defines the container attached to the parsing sequence
  93181. * @param rootUrl Defines the root url of the data
  93182. */
  93183. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93184. /**
  93185. * Gets the list of root nodes (ie. nodes with no parent)
  93186. */
  93187. rootNodes: Node[];
  93188. /** All of the cameras added to this scene
  93189. * @see http://doc.babylonjs.com/babylon101/cameras
  93190. */
  93191. cameras: Camera[];
  93192. /**
  93193. * All of the lights added to this scene
  93194. * @see http://doc.babylonjs.com/babylon101/lights
  93195. */
  93196. lights: Light[];
  93197. /**
  93198. * All of the (abstract) meshes added to this scene
  93199. */
  93200. meshes: AbstractMesh[];
  93201. /**
  93202. * The list of skeletons added to the scene
  93203. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93204. */
  93205. skeletons: Skeleton[];
  93206. /**
  93207. * All of the particle systems added to this scene
  93208. * @see http://doc.babylonjs.com/babylon101/particles
  93209. */
  93210. particleSystems: IParticleSystem[];
  93211. /**
  93212. * Gets a list of Animations associated with the scene
  93213. */
  93214. animations: Animation[];
  93215. /**
  93216. * All of the animation groups added to this scene
  93217. * @see http://doc.babylonjs.com/how_to/group
  93218. */
  93219. animationGroups: AnimationGroup[];
  93220. /**
  93221. * All of the multi-materials added to this scene
  93222. * @see http://doc.babylonjs.com/how_to/multi_materials
  93223. */
  93224. multiMaterials: MultiMaterial[];
  93225. /**
  93226. * All of the materials added to this scene
  93227. * In the context of a Scene, it is not supposed to be modified manually.
  93228. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93229. * Note also that the order of the Material wihin the array is not significant and might change.
  93230. * @see http://doc.babylonjs.com/babylon101/materials
  93231. */
  93232. materials: Material[];
  93233. /**
  93234. * The list of morph target managers added to the scene
  93235. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93236. */
  93237. morphTargetManagers: MorphTargetManager[];
  93238. /**
  93239. * The list of geometries used in the scene.
  93240. */
  93241. geometries: Geometry[];
  93242. /**
  93243. * All of the tranform nodes added to this scene
  93244. * In the context of a Scene, it is not supposed to be modified manually.
  93245. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93246. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93247. * @see http://doc.babylonjs.com/how_to/transformnode
  93248. */
  93249. transformNodes: TransformNode[];
  93250. /**
  93251. * ActionManagers available on the scene.
  93252. */
  93253. actionManagers: AbstractActionManager[];
  93254. /**
  93255. * Textures to keep.
  93256. */
  93257. textures: BaseTexture[];
  93258. /**
  93259. * Environment texture for the scene
  93260. */
  93261. environmentTexture: Nullable<BaseTexture>;
  93262. }
  93263. }
  93264. declare module BABYLON {
  93265. /**
  93266. * Defines a sound that can be played in the application.
  93267. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93269. */
  93270. export class Sound {
  93271. /**
  93272. * The name of the sound in the scene.
  93273. */
  93274. name: string;
  93275. /**
  93276. * Does the sound autoplay once loaded.
  93277. */
  93278. autoplay: boolean;
  93279. /**
  93280. * Does the sound loop after it finishes playing once.
  93281. */
  93282. loop: boolean;
  93283. /**
  93284. * Does the sound use a custom attenuation curve to simulate the falloff
  93285. * happening when the source gets further away from the camera.
  93286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93287. */
  93288. useCustomAttenuation: boolean;
  93289. /**
  93290. * The sound track id this sound belongs to.
  93291. */
  93292. soundTrackId: number;
  93293. /**
  93294. * Is this sound currently played.
  93295. */
  93296. isPlaying: boolean;
  93297. /**
  93298. * Is this sound currently paused.
  93299. */
  93300. isPaused: boolean;
  93301. /**
  93302. * Does this sound enables spatial sound.
  93303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93304. */
  93305. spatialSound: boolean;
  93306. /**
  93307. * Define the reference distance the sound should be heard perfectly.
  93308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93309. */
  93310. refDistance: number;
  93311. /**
  93312. * Define the roll off factor of spatial sounds.
  93313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93314. */
  93315. rolloffFactor: number;
  93316. /**
  93317. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93319. */
  93320. maxDistance: number;
  93321. /**
  93322. * Define the distance attenuation model the sound will follow.
  93323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93324. */
  93325. distanceModel: string;
  93326. /**
  93327. * @hidden
  93328. * Back Compat
  93329. **/
  93330. onended: () => any;
  93331. /**
  93332. * Observable event when the current playing sound finishes.
  93333. */
  93334. onEndedObservable: Observable<Sound>;
  93335. private _panningModel;
  93336. private _playbackRate;
  93337. private _streaming;
  93338. private _startTime;
  93339. private _startOffset;
  93340. private _position;
  93341. /** @hidden */
  93342. _positionInEmitterSpace: boolean;
  93343. private _localDirection;
  93344. private _volume;
  93345. private _isReadyToPlay;
  93346. private _isDirectional;
  93347. private _readyToPlayCallback;
  93348. private _audioBuffer;
  93349. private _soundSource;
  93350. private _streamingSource;
  93351. private _soundPanner;
  93352. private _soundGain;
  93353. private _inputAudioNode;
  93354. private _outputAudioNode;
  93355. private _coneInnerAngle;
  93356. private _coneOuterAngle;
  93357. private _coneOuterGain;
  93358. private _scene;
  93359. private _connectedTransformNode;
  93360. private _customAttenuationFunction;
  93361. private _registerFunc;
  93362. private _isOutputConnected;
  93363. private _htmlAudioElement;
  93364. private _urlType;
  93365. /** @hidden */
  93366. static _SceneComponentInitialization: (scene: Scene) => void;
  93367. /**
  93368. * Create a sound and attach it to a scene
  93369. * @param name Name of your sound
  93370. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93371. * @param scene defines the scene the sound belongs to
  93372. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93373. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93374. */
  93375. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93376. /**
  93377. * Release the sound and its associated resources
  93378. */
  93379. dispose(): void;
  93380. /**
  93381. * Gets if the sounds is ready to be played or not.
  93382. * @returns true if ready, otherwise false
  93383. */
  93384. isReady(): boolean;
  93385. private _soundLoaded;
  93386. /**
  93387. * Sets the data of the sound from an audiobuffer
  93388. * @param audioBuffer The audioBuffer containing the data
  93389. */
  93390. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93391. /**
  93392. * Updates the current sounds options such as maxdistance, loop...
  93393. * @param options A JSON object containing values named as the object properties
  93394. */
  93395. updateOptions(options: any): void;
  93396. private _createSpatialParameters;
  93397. private _updateSpatialParameters;
  93398. /**
  93399. * Switch the panning model to HRTF:
  93400. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93402. */
  93403. switchPanningModelToHRTF(): void;
  93404. /**
  93405. * Switch the panning model to Equal Power:
  93406. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93408. */
  93409. switchPanningModelToEqualPower(): void;
  93410. private _switchPanningModel;
  93411. /**
  93412. * Connect this sound to a sound track audio node like gain...
  93413. * @param soundTrackAudioNode the sound track audio node to connect to
  93414. */
  93415. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93416. /**
  93417. * Transform this sound into a directional source
  93418. * @param coneInnerAngle Size of the inner cone in degree
  93419. * @param coneOuterAngle Size of the outer cone in degree
  93420. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93421. */
  93422. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93423. /**
  93424. * Gets or sets the inner angle for the directional cone.
  93425. */
  93426. /**
  93427. * Gets or sets the inner angle for the directional cone.
  93428. */
  93429. directionalConeInnerAngle: number;
  93430. /**
  93431. * Gets or sets the outer angle for the directional cone.
  93432. */
  93433. /**
  93434. * Gets or sets the outer angle for the directional cone.
  93435. */
  93436. directionalConeOuterAngle: number;
  93437. /**
  93438. * Sets the position of the emitter if spatial sound is enabled
  93439. * @param newPosition Defines the new posisiton
  93440. */
  93441. setPosition(newPosition: Vector3): void;
  93442. /**
  93443. * Sets the local direction of the emitter if spatial sound is enabled
  93444. * @param newLocalDirection Defines the new local direction
  93445. */
  93446. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93447. private _updateDirection;
  93448. /** @hidden */
  93449. updateDistanceFromListener(): void;
  93450. /**
  93451. * Sets a new custom attenuation function for the sound.
  93452. * @param callback Defines the function used for the attenuation
  93453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93454. */
  93455. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93456. /**
  93457. * Play the sound
  93458. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93459. * @param offset (optional) Start the sound setting it at a specific time
  93460. */
  93461. play(time?: number, offset?: number): void;
  93462. private _onended;
  93463. /**
  93464. * Stop the sound
  93465. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93466. */
  93467. stop(time?: number): void;
  93468. /**
  93469. * Put the sound in pause
  93470. */
  93471. pause(): void;
  93472. /**
  93473. * Sets a dedicated volume for this sounds
  93474. * @param newVolume Define the new volume of the sound
  93475. * @param time Define in how long the sound should be at this value
  93476. */
  93477. setVolume(newVolume: number, time?: number): void;
  93478. /**
  93479. * Set the sound play back rate
  93480. * @param newPlaybackRate Define the playback rate the sound should be played at
  93481. */
  93482. setPlaybackRate(newPlaybackRate: number): void;
  93483. /**
  93484. * Gets the volume of the sound.
  93485. * @returns the volume of the sound
  93486. */
  93487. getVolume(): number;
  93488. /**
  93489. * Attach the sound to a dedicated mesh
  93490. * @param transformNode The transform node to connect the sound with
  93491. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93492. */
  93493. attachToMesh(transformNode: TransformNode): void;
  93494. /**
  93495. * Detach the sound from the previously attached mesh
  93496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93497. */
  93498. detachFromMesh(): void;
  93499. private _onRegisterAfterWorldMatrixUpdate;
  93500. /**
  93501. * Clone the current sound in the scene.
  93502. * @returns the new sound clone
  93503. */
  93504. clone(): Nullable<Sound>;
  93505. /**
  93506. * Gets the current underlying audio buffer containing the data
  93507. * @returns the audio buffer
  93508. */
  93509. getAudioBuffer(): Nullable<AudioBuffer>;
  93510. /**
  93511. * Serializes the Sound in a JSON representation
  93512. * @returns the JSON representation of the sound
  93513. */
  93514. serialize(): any;
  93515. /**
  93516. * Parse a JSON representation of a sound to innstantiate in a given scene
  93517. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  93518. * @param scene Define the scene the new parsed sound should be created in
  93519. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  93520. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  93521. * @returns the newly parsed sound
  93522. */
  93523. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  93524. }
  93525. }
  93526. declare module BABYLON {
  93527. /**
  93528. * This defines an action helpful to play a defined sound on a triggered action.
  93529. */
  93530. export class PlaySoundAction extends Action {
  93531. private _sound;
  93532. /**
  93533. * Instantiate the action
  93534. * @param triggerOptions defines the trigger options
  93535. * @param sound defines the sound to play
  93536. * @param condition defines the trigger related conditions
  93537. */
  93538. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93539. /** @hidden */
  93540. _prepare(): void;
  93541. /**
  93542. * Execute the action and play the sound.
  93543. */
  93544. execute(): void;
  93545. /**
  93546. * Serializes the actions and its related information.
  93547. * @param parent defines the object to serialize in
  93548. * @returns the serialized object
  93549. */
  93550. serialize(parent: any): any;
  93551. }
  93552. /**
  93553. * This defines an action helpful to stop a defined sound on a triggered action.
  93554. */
  93555. export class StopSoundAction extends Action {
  93556. private _sound;
  93557. /**
  93558. * Instantiate the action
  93559. * @param triggerOptions defines the trigger options
  93560. * @param sound defines the sound to stop
  93561. * @param condition defines the trigger related conditions
  93562. */
  93563. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93564. /** @hidden */
  93565. _prepare(): void;
  93566. /**
  93567. * Execute the action and stop the sound.
  93568. */
  93569. execute(): void;
  93570. /**
  93571. * Serializes the actions and its related information.
  93572. * @param parent defines the object to serialize in
  93573. * @returns the serialized object
  93574. */
  93575. serialize(parent: any): any;
  93576. }
  93577. }
  93578. declare module BABYLON {
  93579. /**
  93580. * This defines an action responsible to change the value of a property
  93581. * by interpolating between its current value and the newly set one once triggered.
  93582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93583. */
  93584. export class InterpolateValueAction extends Action {
  93585. /**
  93586. * Defines the path of the property where the value should be interpolated
  93587. */
  93588. propertyPath: string;
  93589. /**
  93590. * Defines the target value at the end of the interpolation.
  93591. */
  93592. value: any;
  93593. /**
  93594. * Defines the time it will take for the property to interpolate to the value.
  93595. */
  93596. duration: number;
  93597. /**
  93598. * Defines if the other scene animations should be stopped when the action has been triggered
  93599. */
  93600. stopOtherAnimations?: boolean;
  93601. /**
  93602. * Defines a callback raised once the interpolation animation has been done.
  93603. */
  93604. onInterpolationDone?: () => void;
  93605. /**
  93606. * Observable triggered once the interpolation animation has been done.
  93607. */
  93608. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93609. private _target;
  93610. private _effectiveTarget;
  93611. private _property;
  93612. /**
  93613. * Instantiate the action
  93614. * @param triggerOptions defines the trigger options
  93615. * @param target defines the object containing the value to interpolate
  93616. * @param propertyPath defines the path to the property in the target object
  93617. * @param value defines the target value at the end of the interpolation
  93618. * @param duration deines the time it will take for the property to interpolate to the value.
  93619. * @param condition defines the trigger related conditions
  93620. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93621. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93622. */
  93623. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93624. /** @hidden */
  93625. _prepare(): void;
  93626. /**
  93627. * Execute the action starts the value interpolation.
  93628. */
  93629. execute(): void;
  93630. /**
  93631. * Serializes the actions and its related information.
  93632. * @param parent defines the object to serialize in
  93633. * @returns the serialized object
  93634. */
  93635. serialize(parent: any): any;
  93636. }
  93637. }
  93638. declare module BABYLON {
  93639. /**
  93640. * Options allowed during the creation of a sound track.
  93641. */
  93642. export interface ISoundTrackOptions {
  93643. /**
  93644. * The volume the sound track should take during creation
  93645. */
  93646. volume?: number;
  93647. /**
  93648. * Define if the sound track is the main sound track of the scene
  93649. */
  93650. mainTrack?: boolean;
  93651. }
  93652. /**
  93653. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93654. * It will be also used in a future release to apply effects on a specific track.
  93655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93656. */
  93657. export class SoundTrack {
  93658. /**
  93659. * The unique identifier of the sound track in the scene.
  93660. */
  93661. id: number;
  93662. /**
  93663. * The list of sounds included in the sound track.
  93664. */
  93665. soundCollection: Array<Sound>;
  93666. private _outputAudioNode;
  93667. private _scene;
  93668. private _isMainTrack;
  93669. private _connectedAnalyser;
  93670. private _options;
  93671. private _isInitialized;
  93672. /**
  93673. * Creates a new sound track.
  93674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93675. * @param scene Define the scene the sound track belongs to
  93676. * @param options
  93677. */
  93678. constructor(scene: Scene, options?: ISoundTrackOptions);
  93679. private _initializeSoundTrackAudioGraph;
  93680. /**
  93681. * Release the sound track and its associated resources
  93682. */
  93683. dispose(): void;
  93684. /**
  93685. * Adds a sound to this sound track
  93686. * @param sound define the cound to add
  93687. * @ignoreNaming
  93688. */
  93689. AddSound(sound: Sound): void;
  93690. /**
  93691. * Removes a sound to this sound track
  93692. * @param sound define the cound to remove
  93693. * @ignoreNaming
  93694. */
  93695. RemoveSound(sound: Sound): void;
  93696. /**
  93697. * Set a global volume for the full sound track.
  93698. * @param newVolume Define the new volume of the sound track
  93699. */
  93700. setVolume(newVolume: number): void;
  93701. /**
  93702. * Switch the panning model to HRTF:
  93703. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93704. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93705. */
  93706. switchPanningModelToHRTF(): void;
  93707. /**
  93708. * Switch the panning model to Equal Power:
  93709. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93711. */
  93712. switchPanningModelToEqualPower(): void;
  93713. /**
  93714. * Connect the sound track to an audio analyser allowing some amazing
  93715. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93717. * @param analyser The analyser to connect to the engine
  93718. */
  93719. connectToAnalyser(analyser: Analyser): void;
  93720. }
  93721. }
  93722. declare module BABYLON {
  93723. interface AbstractScene {
  93724. /**
  93725. * The list of sounds used in the scene.
  93726. */
  93727. sounds: Nullable<Array<Sound>>;
  93728. }
  93729. interface Scene {
  93730. /**
  93731. * @hidden
  93732. * Backing field
  93733. */
  93734. _mainSoundTrack: SoundTrack;
  93735. /**
  93736. * The main sound track played by the scene.
  93737. * It cotains your primary collection of sounds.
  93738. */
  93739. mainSoundTrack: SoundTrack;
  93740. /**
  93741. * The list of sound tracks added to the scene
  93742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93743. */
  93744. soundTracks: Nullable<Array<SoundTrack>>;
  93745. /**
  93746. * Gets a sound using a given name
  93747. * @param name defines the name to search for
  93748. * @return the found sound or null if not found at all.
  93749. */
  93750. getSoundByName(name: string): Nullable<Sound>;
  93751. /**
  93752. * Gets or sets if audio support is enabled
  93753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93754. */
  93755. audioEnabled: boolean;
  93756. /**
  93757. * Gets or sets if audio will be output to headphones
  93758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93759. */
  93760. headphone: boolean;
  93761. }
  93762. /**
  93763. * Defines the sound scene component responsible to manage any sounds
  93764. * in a given scene.
  93765. */
  93766. export class AudioSceneComponent implements ISceneSerializableComponent {
  93767. /**
  93768. * The component name helpfull to identify the component in the list of scene components.
  93769. */
  93770. readonly name: string;
  93771. /**
  93772. * The scene the component belongs to.
  93773. */
  93774. scene: Scene;
  93775. private _audioEnabled;
  93776. /**
  93777. * Gets whether audio is enabled or not.
  93778. * Please use related enable/disable method to switch state.
  93779. */
  93780. readonly audioEnabled: boolean;
  93781. private _headphone;
  93782. /**
  93783. * Gets whether audio is outputing to headphone or not.
  93784. * Please use the according Switch methods to change output.
  93785. */
  93786. readonly headphone: boolean;
  93787. /**
  93788. * Creates a new instance of the component for the given scene
  93789. * @param scene Defines the scene to register the component in
  93790. */
  93791. constructor(scene: Scene);
  93792. /**
  93793. * Registers the component in a given scene
  93794. */
  93795. register(): void;
  93796. /**
  93797. * Rebuilds the elements related to this component in case of
  93798. * context lost for instance.
  93799. */
  93800. rebuild(): void;
  93801. /**
  93802. * Serializes the component data to the specified json object
  93803. * @param serializationObject The object to serialize to
  93804. */
  93805. serialize(serializationObject: any): void;
  93806. /**
  93807. * Adds all the element from the container to the scene
  93808. * @param container the container holding the elements
  93809. */
  93810. addFromContainer(container: AbstractScene): void;
  93811. /**
  93812. * Removes all the elements in the container from the scene
  93813. * @param container contains the elements to remove
  93814. * @param dispose if the removed element should be disposed (default: false)
  93815. */
  93816. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93817. /**
  93818. * Disposes the component and the associated ressources.
  93819. */
  93820. dispose(): void;
  93821. /**
  93822. * Disables audio in the associated scene.
  93823. */
  93824. disableAudio(): void;
  93825. /**
  93826. * Enables audio in the associated scene.
  93827. */
  93828. enableAudio(): void;
  93829. /**
  93830. * Switch audio to headphone output.
  93831. */
  93832. switchAudioModeForHeadphones(): void;
  93833. /**
  93834. * Switch audio to normal speakers.
  93835. */
  93836. switchAudioModeForNormalSpeakers(): void;
  93837. private _afterRender;
  93838. }
  93839. }
  93840. declare module BABYLON {
  93841. /**
  93842. * Wraps one or more Sound objects and selects one with random weight for playback.
  93843. */
  93844. export class WeightedSound {
  93845. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93846. loop: boolean;
  93847. private _coneInnerAngle;
  93848. private _coneOuterAngle;
  93849. private _volume;
  93850. /** A Sound is currently playing. */
  93851. isPlaying: boolean;
  93852. /** A Sound is currently paused. */
  93853. isPaused: boolean;
  93854. private _sounds;
  93855. private _weights;
  93856. private _currentIndex?;
  93857. /**
  93858. * Creates a new WeightedSound from the list of sounds given.
  93859. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  93860. * @param sounds Array of Sounds that will be selected from.
  93861. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  93862. */
  93863. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  93864. /**
  93865. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  93866. */
  93867. /**
  93868. * The size of cone in degress for a directional sound in which there will be no attenuation.
  93869. */
  93870. directionalConeInnerAngle: number;
  93871. /**
  93872. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93873. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93874. */
  93875. /**
  93876. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93877. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93878. */
  93879. directionalConeOuterAngle: number;
  93880. /**
  93881. * Playback volume.
  93882. */
  93883. /**
  93884. * Playback volume.
  93885. */
  93886. volume: number;
  93887. private _onended;
  93888. /**
  93889. * Suspend playback
  93890. */
  93891. pause(): void;
  93892. /**
  93893. * Stop playback
  93894. */
  93895. stop(): void;
  93896. /**
  93897. * Start playback.
  93898. * @param startOffset Position the clip head at a specific time in seconds.
  93899. */
  93900. play(startOffset?: number): void;
  93901. }
  93902. }
  93903. declare module BABYLON {
  93904. /**
  93905. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  93906. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93907. */
  93908. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  93909. /**
  93910. * Gets the name of the behavior.
  93911. */
  93912. readonly name: string;
  93913. /**
  93914. * The easing function used by animations
  93915. */
  93916. static EasingFunction: BackEase;
  93917. /**
  93918. * The easing mode used by animations
  93919. */
  93920. static EasingMode: number;
  93921. /**
  93922. * The duration of the animation, in milliseconds
  93923. */
  93924. transitionDuration: number;
  93925. /**
  93926. * Length of the distance animated by the transition when lower radius is reached
  93927. */
  93928. lowerRadiusTransitionRange: number;
  93929. /**
  93930. * Length of the distance animated by the transition when upper radius is reached
  93931. */
  93932. upperRadiusTransitionRange: number;
  93933. private _autoTransitionRange;
  93934. /**
  93935. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93936. */
  93937. /**
  93938. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93939. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  93940. */
  93941. autoTransitionRange: boolean;
  93942. private _attachedCamera;
  93943. private _onAfterCheckInputsObserver;
  93944. private _onMeshTargetChangedObserver;
  93945. /**
  93946. * Initializes the behavior.
  93947. */
  93948. init(): void;
  93949. /**
  93950. * Attaches the behavior to its arc rotate camera.
  93951. * @param camera Defines the camera to attach the behavior to
  93952. */
  93953. attach(camera: ArcRotateCamera): void;
  93954. /**
  93955. * Detaches the behavior from its current arc rotate camera.
  93956. */
  93957. detach(): void;
  93958. private _radiusIsAnimating;
  93959. private _radiusBounceTransition;
  93960. private _animatables;
  93961. private _cachedWheelPrecision;
  93962. /**
  93963. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  93964. * @param radiusLimit The limit to check against.
  93965. * @return Bool to indicate if at limit.
  93966. */
  93967. private _isRadiusAtLimit;
  93968. /**
  93969. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  93970. * @param radiusDelta The delta by which to animate to. Can be negative.
  93971. */
  93972. private _applyBoundRadiusAnimation;
  93973. /**
  93974. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  93975. */
  93976. protected _clearAnimationLocks(): void;
  93977. /**
  93978. * Stops and removes all animations that have been applied to the camera
  93979. */
  93980. stopAllAnimations(): void;
  93981. }
  93982. }
  93983. declare module BABYLON {
  93984. /**
  93985. * 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.
  93986. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93987. */
  93988. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93989. /**
  93990. * Gets the name of the behavior.
  93991. */
  93992. readonly name: string;
  93993. private _mode;
  93994. private _radiusScale;
  93995. private _positionScale;
  93996. private _defaultElevation;
  93997. private _elevationReturnTime;
  93998. private _elevationReturnWaitTime;
  93999. private _zoomStopsAnimation;
  94000. private _framingTime;
  94001. /**
  94002. * The easing function used by animations
  94003. */
  94004. static EasingFunction: ExponentialEase;
  94005. /**
  94006. * The easing mode used by animations
  94007. */
  94008. static EasingMode: number;
  94009. /**
  94010. * Sets the current mode used by the behavior
  94011. */
  94012. /**
  94013. * Gets current mode used by the behavior.
  94014. */
  94015. mode: number;
  94016. /**
  94017. * Sets the scale applied to the radius (1 by default)
  94018. */
  94019. /**
  94020. * Gets the scale applied to the radius
  94021. */
  94022. radiusScale: number;
  94023. /**
  94024. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94025. */
  94026. /**
  94027. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94028. */
  94029. positionScale: number;
  94030. /**
  94031. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94032. * behaviour is triggered, in radians.
  94033. */
  94034. /**
  94035. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94036. * behaviour is triggered, in radians.
  94037. */
  94038. defaultElevation: number;
  94039. /**
  94040. * Sets the time (in milliseconds) taken to return to the default beta position.
  94041. * Negative value indicates camera should not return to default.
  94042. */
  94043. /**
  94044. * Gets the time (in milliseconds) taken to return to the default beta position.
  94045. * Negative value indicates camera should not return to default.
  94046. */
  94047. elevationReturnTime: number;
  94048. /**
  94049. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94050. */
  94051. /**
  94052. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94053. */
  94054. elevationReturnWaitTime: number;
  94055. /**
  94056. * Sets the flag that indicates if user zooming should stop animation.
  94057. */
  94058. /**
  94059. * Gets the flag that indicates if user zooming should stop animation.
  94060. */
  94061. zoomStopsAnimation: boolean;
  94062. /**
  94063. * Sets the transition time when framing the mesh, in milliseconds
  94064. */
  94065. /**
  94066. * Gets the transition time when framing the mesh, in milliseconds
  94067. */
  94068. framingTime: number;
  94069. /**
  94070. * Define if the behavior should automatically change the configured
  94071. * camera limits and sensibilities.
  94072. */
  94073. autoCorrectCameraLimitsAndSensibility: boolean;
  94074. private _onPrePointerObservableObserver;
  94075. private _onAfterCheckInputsObserver;
  94076. private _onMeshTargetChangedObserver;
  94077. private _attachedCamera;
  94078. private _isPointerDown;
  94079. private _lastInteractionTime;
  94080. /**
  94081. * Initializes the behavior.
  94082. */
  94083. init(): void;
  94084. /**
  94085. * Attaches the behavior to its arc rotate camera.
  94086. * @param camera Defines the camera to attach the behavior to
  94087. */
  94088. attach(camera: ArcRotateCamera): void;
  94089. /**
  94090. * Detaches the behavior from its current arc rotate camera.
  94091. */
  94092. detach(): void;
  94093. private _animatables;
  94094. private _betaIsAnimating;
  94095. private _betaTransition;
  94096. private _radiusTransition;
  94097. private _vectorTransition;
  94098. /**
  94099. * Targets the given mesh and updates zoom level accordingly.
  94100. * @param mesh The mesh to target.
  94101. * @param radius Optional. If a cached radius position already exists, overrides default.
  94102. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94103. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94104. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94105. */
  94106. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94107. /**
  94108. * Targets the given mesh with its children and updates zoom level accordingly.
  94109. * @param mesh The mesh to target.
  94110. * @param radius Optional. If a cached radius position already exists, overrides default.
  94111. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94112. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94113. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94114. */
  94115. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94116. /**
  94117. * Targets the given meshes with their children and updates zoom level accordingly.
  94118. * @param meshes The mesh to target.
  94119. * @param radius Optional. If a cached radius position already exists, overrides default.
  94120. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94121. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94122. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94123. */
  94124. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94125. /**
  94126. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94127. * @param minimumWorld Determines the smaller position of the bounding box extend
  94128. * @param maximumWorld Determines the bigger position of the bounding box extend
  94129. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94130. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94131. */
  94132. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94133. /**
  94134. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94135. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94136. * frustum width.
  94137. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94138. * to fully enclose the mesh in the viewing frustum.
  94139. */
  94140. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94141. /**
  94142. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94143. * is automatically returned to its default position (expected to be above ground plane).
  94144. */
  94145. private _maintainCameraAboveGround;
  94146. /**
  94147. * Returns the frustum slope based on the canvas ratio and camera FOV
  94148. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94149. */
  94150. private _getFrustumSlope;
  94151. /**
  94152. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94153. */
  94154. private _clearAnimationLocks;
  94155. /**
  94156. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94157. */
  94158. private _applyUserInteraction;
  94159. /**
  94160. * Stops and removes all animations that have been applied to the camera
  94161. */
  94162. stopAllAnimations(): void;
  94163. /**
  94164. * Gets a value indicating if the user is moving the camera
  94165. */
  94166. readonly isUserIsMoving: boolean;
  94167. /**
  94168. * The camera can move all the way towards the mesh.
  94169. */
  94170. static IgnoreBoundsSizeMode: number;
  94171. /**
  94172. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94173. */
  94174. static FitFrustumSidesMode: number;
  94175. }
  94176. }
  94177. declare module BABYLON {
  94178. /**
  94179. * Base class for Camera Pointer Inputs.
  94180. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94181. * for example usage.
  94182. */
  94183. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94184. /**
  94185. * Defines the camera the input is attached to.
  94186. */
  94187. abstract camera: Camera;
  94188. /**
  94189. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94190. */
  94191. protected _altKey: boolean;
  94192. protected _ctrlKey: boolean;
  94193. protected _metaKey: boolean;
  94194. protected _shiftKey: boolean;
  94195. /**
  94196. * Which mouse buttons were pressed at time of last mouse event.
  94197. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94198. */
  94199. protected _buttonsPressed: number;
  94200. /**
  94201. * Defines the buttons associated with the input to handle camera move.
  94202. */
  94203. buttons: number[];
  94204. /**
  94205. * Attach the input controls to a specific dom element to get the input from.
  94206. * @param element Defines the element the controls should be listened from
  94207. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94208. */
  94209. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94210. /**
  94211. * Detach the current controls from the specified dom element.
  94212. * @param element Defines the element to stop listening the inputs from
  94213. */
  94214. detachControl(element: Nullable<HTMLElement>): void;
  94215. /**
  94216. * Gets the class name of the current input.
  94217. * @returns the class name
  94218. */
  94219. getClassName(): string;
  94220. /**
  94221. * Get the friendly name associated with the input class.
  94222. * @returns the input friendly name
  94223. */
  94224. getSimpleName(): string;
  94225. /**
  94226. * Called on pointer POINTERDOUBLETAP event.
  94227. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94228. */
  94229. protected onDoubleTap(type: string): void;
  94230. /**
  94231. * Called on pointer POINTERMOVE event if only a single touch is active.
  94232. * Override this method to provide functionality.
  94233. */
  94234. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94235. /**
  94236. * Called on pointer POINTERMOVE event if multiple touches are active.
  94237. * Override this method to provide functionality.
  94238. */
  94239. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94240. /**
  94241. * Called on JS contextmenu event.
  94242. * Override this method to provide functionality.
  94243. */
  94244. protected onContextMenu(evt: PointerEvent): void;
  94245. /**
  94246. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94247. * press.
  94248. * Override this method to provide functionality.
  94249. */
  94250. protected onButtonDown(evt: PointerEvent): void;
  94251. /**
  94252. * Called each time a new POINTERUP event occurs. Ie, for each button
  94253. * release.
  94254. * Override this method to provide functionality.
  94255. */
  94256. protected onButtonUp(evt: PointerEvent): void;
  94257. /**
  94258. * Called when window becomes inactive.
  94259. * Override this method to provide functionality.
  94260. */
  94261. protected onLostFocus(): void;
  94262. private _pointerInput;
  94263. private _observer;
  94264. private _onLostFocus;
  94265. private pointA;
  94266. private pointB;
  94267. }
  94268. }
  94269. declare module BABYLON {
  94270. /**
  94271. * Manage the pointers inputs to control an arc rotate camera.
  94272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94273. */
  94274. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94275. /**
  94276. * Defines the camera the input is attached to.
  94277. */
  94278. camera: ArcRotateCamera;
  94279. /**
  94280. * Gets the class name of the current input.
  94281. * @returns the class name
  94282. */
  94283. getClassName(): string;
  94284. /**
  94285. * Defines the buttons associated with the input to handle camera move.
  94286. */
  94287. buttons: number[];
  94288. /**
  94289. * Defines the pointer angular sensibility along the X axis or how fast is
  94290. * the camera rotating.
  94291. */
  94292. angularSensibilityX: number;
  94293. /**
  94294. * Defines the pointer angular sensibility along the Y axis or how fast is
  94295. * the camera rotating.
  94296. */
  94297. angularSensibilityY: number;
  94298. /**
  94299. * Defines the pointer pinch precision or how fast is the camera zooming.
  94300. */
  94301. pinchPrecision: number;
  94302. /**
  94303. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94304. * from 0.
  94305. * It defines the percentage of current camera.radius to use as delta when
  94306. * pinch zoom is used.
  94307. */
  94308. pinchDeltaPercentage: number;
  94309. /**
  94310. * Defines the pointer panning sensibility or how fast is the camera moving.
  94311. */
  94312. panningSensibility: number;
  94313. /**
  94314. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94315. */
  94316. multiTouchPanning: boolean;
  94317. /**
  94318. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94319. * zoom (pinch) through multitouch.
  94320. */
  94321. multiTouchPanAndZoom: boolean;
  94322. /**
  94323. * Revers pinch action direction.
  94324. */
  94325. pinchInwards: boolean;
  94326. private _isPanClick;
  94327. private _twoFingerActivityCount;
  94328. private _isPinching;
  94329. /**
  94330. * Called on pointer POINTERMOVE event if only a single touch is active.
  94331. */
  94332. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94333. /**
  94334. * Called on pointer POINTERDOUBLETAP event.
  94335. */
  94336. protected onDoubleTap(type: string): void;
  94337. /**
  94338. * Called on pointer POINTERMOVE event if multiple touches are active.
  94339. */
  94340. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94341. /**
  94342. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94343. * press.
  94344. */
  94345. protected onButtonDown(evt: PointerEvent): void;
  94346. /**
  94347. * Called each time a new POINTERUP event occurs. Ie, for each button
  94348. * release.
  94349. */
  94350. protected onButtonUp(evt: PointerEvent): void;
  94351. /**
  94352. * Called when window becomes inactive.
  94353. */
  94354. protected onLostFocus(): void;
  94355. }
  94356. }
  94357. declare module BABYLON {
  94358. /**
  94359. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94361. */
  94362. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94363. /**
  94364. * Defines the camera the input is attached to.
  94365. */
  94366. camera: ArcRotateCamera;
  94367. /**
  94368. * Defines the list of key codes associated with the up action (increase alpha)
  94369. */
  94370. keysUp: number[];
  94371. /**
  94372. * Defines the list of key codes associated with the down action (decrease alpha)
  94373. */
  94374. keysDown: number[];
  94375. /**
  94376. * Defines the list of key codes associated with the left action (increase beta)
  94377. */
  94378. keysLeft: number[];
  94379. /**
  94380. * Defines the list of key codes associated with the right action (decrease beta)
  94381. */
  94382. keysRight: number[];
  94383. /**
  94384. * Defines the list of key codes associated with the reset action.
  94385. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94386. */
  94387. keysReset: number[];
  94388. /**
  94389. * Defines the panning sensibility of the inputs.
  94390. * (How fast is the camera paning)
  94391. */
  94392. panningSensibility: number;
  94393. /**
  94394. * Defines the zooming sensibility of the inputs.
  94395. * (How fast is the camera zooming)
  94396. */
  94397. zoomingSensibility: number;
  94398. /**
  94399. * Defines wether maintaining the alt key down switch the movement mode from
  94400. * orientation to zoom.
  94401. */
  94402. useAltToZoom: boolean;
  94403. /**
  94404. * Rotation speed of the camera
  94405. */
  94406. angularSpeed: number;
  94407. private _keys;
  94408. private _ctrlPressed;
  94409. private _altPressed;
  94410. private _onCanvasBlurObserver;
  94411. private _onKeyboardObserver;
  94412. private _engine;
  94413. private _scene;
  94414. /**
  94415. * Attach the input controls to a specific dom element to get the input from.
  94416. * @param element Defines the element the controls should be listened from
  94417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94418. */
  94419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94420. /**
  94421. * Detach the current controls from the specified dom element.
  94422. * @param element Defines the element to stop listening the inputs from
  94423. */
  94424. detachControl(element: Nullable<HTMLElement>): void;
  94425. /**
  94426. * Update the current camera state depending on the inputs that have been used this frame.
  94427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94428. */
  94429. checkInputs(): void;
  94430. /**
  94431. * Gets the class name of the current intput.
  94432. * @returns the class name
  94433. */
  94434. getClassName(): string;
  94435. /**
  94436. * Get the friendly name associated with the input class.
  94437. * @returns the input friendly name
  94438. */
  94439. getSimpleName(): string;
  94440. }
  94441. }
  94442. declare module BABYLON {
  94443. /**
  94444. * Manage the mouse wheel inputs to control an arc rotate camera.
  94445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94446. */
  94447. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94448. /**
  94449. * Defines the camera the input is attached to.
  94450. */
  94451. camera: ArcRotateCamera;
  94452. /**
  94453. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94454. */
  94455. wheelPrecision: number;
  94456. /**
  94457. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94458. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94459. */
  94460. wheelDeltaPercentage: number;
  94461. private _wheel;
  94462. private _observer;
  94463. /**
  94464. * Attach the input controls to a specific dom element to get the input from.
  94465. * @param element Defines the element the controls should be listened from
  94466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94467. */
  94468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94469. /**
  94470. * Detach the current controls from the specified dom element.
  94471. * @param element Defines the element to stop listening the inputs from
  94472. */
  94473. detachControl(element: Nullable<HTMLElement>): void;
  94474. /**
  94475. * Gets the class name of the current intput.
  94476. * @returns the class name
  94477. */
  94478. getClassName(): string;
  94479. /**
  94480. * Get the friendly name associated with the input class.
  94481. * @returns the input friendly name
  94482. */
  94483. getSimpleName(): string;
  94484. }
  94485. }
  94486. declare module BABYLON {
  94487. /**
  94488. * Default Inputs manager for the ArcRotateCamera.
  94489. * It groups all the default supported inputs for ease of use.
  94490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94491. */
  94492. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94493. /**
  94494. * Instantiates a new ArcRotateCameraInputsManager.
  94495. * @param camera Defines the camera the inputs belong to
  94496. */
  94497. constructor(camera: ArcRotateCamera);
  94498. /**
  94499. * Add mouse wheel input support to the input manager.
  94500. * @returns the current input manager
  94501. */
  94502. addMouseWheel(): ArcRotateCameraInputsManager;
  94503. /**
  94504. * Add pointers input support to the input manager.
  94505. * @returns the current input manager
  94506. */
  94507. addPointers(): ArcRotateCameraInputsManager;
  94508. /**
  94509. * Add keyboard input support to the input manager.
  94510. * @returns the current input manager
  94511. */
  94512. addKeyboard(): ArcRotateCameraInputsManager;
  94513. }
  94514. }
  94515. declare module BABYLON {
  94516. /**
  94517. * This represents an orbital type of camera.
  94518. *
  94519. * 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.
  94520. * 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.
  94521. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  94522. */
  94523. export class ArcRotateCamera extends TargetCamera {
  94524. /**
  94525. * Defines the rotation angle of the camera along the longitudinal axis.
  94526. */
  94527. alpha: number;
  94528. /**
  94529. * Defines the rotation angle of the camera along the latitudinal axis.
  94530. */
  94531. beta: number;
  94532. /**
  94533. * Defines the radius of the camera from it s target point.
  94534. */
  94535. radius: number;
  94536. protected _target: Vector3;
  94537. protected _targetHost: Nullable<AbstractMesh>;
  94538. /**
  94539. * Defines the target point of the camera.
  94540. * The camera looks towards it form the radius distance.
  94541. */
  94542. target: Vector3;
  94543. /**
  94544. * Define the current local position of the camera in the scene
  94545. */
  94546. position: Vector3;
  94547. protected _upVector: Vector3;
  94548. protected _upToYMatrix: Matrix;
  94549. protected _YToUpMatrix: Matrix;
  94550. /**
  94551. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  94552. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  94553. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  94554. */
  94555. upVector: Vector3;
  94556. /**
  94557. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  94558. */
  94559. setMatUp(): void;
  94560. /**
  94561. * Current inertia value on the longitudinal axis.
  94562. * The bigger this number the longer it will take for the camera to stop.
  94563. */
  94564. inertialAlphaOffset: number;
  94565. /**
  94566. * Current inertia value on the latitudinal axis.
  94567. * The bigger this number the longer it will take for the camera to stop.
  94568. */
  94569. inertialBetaOffset: number;
  94570. /**
  94571. * Current inertia value on the radius axis.
  94572. * The bigger this number the longer it will take for the camera to stop.
  94573. */
  94574. inertialRadiusOffset: number;
  94575. /**
  94576. * Minimum allowed angle on the longitudinal axis.
  94577. * This can help limiting how the Camera is able to move in the scene.
  94578. */
  94579. lowerAlphaLimit: Nullable<number>;
  94580. /**
  94581. * Maximum allowed angle on the longitudinal axis.
  94582. * This can help limiting how the Camera is able to move in the scene.
  94583. */
  94584. upperAlphaLimit: Nullable<number>;
  94585. /**
  94586. * Minimum allowed angle on the latitudinal axis.
  94587. * This can help limiting how the Camera is able to move in the scene.
  94588. */
  94589. lowerBetaLimit: number;
  94590. /**
  94591. * Maximum allowed angle on the latitudinal axis.
  94592. * This can help limiting how the Camera is able to move in the scene.
  94593. */
  94594. upperBetaLimit: number;
  94595. /**
  94596. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94597. * This can help limiting how the Camera is able to move in the scene.
  94598. */
  94599. lowerRadiusLimit: Nullable<number>;
  94600. /**
  94601. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94602. * This can help limiting how the Camera is able to move in the scene.
  94603. */
  94604. upperRadiusLimit: Nullable<number>;
  94605. /**
  94606. * Defines the current inertia value used during panning of the camera along the X axis.
  94607. */
  94608. inertialPanningX: number;
  94609. /**
  94610. * Defines the current inertia value used during panning of the camera along the Y axis.
  94611. */
  94612. inertialPanningY: number;
  94613. /**
  94614. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94615. * Basically if your fingers moves away from more than this distance you will be considered
  94616. * in pinch mode.
  94617. */
  94618. pinchToPanMaxDistance: number;
  94619. /**
  94620. * Defines the maximum distance the camera can pan.
  94621. * This could help keeping the cammera always in your scene.
  94622. */
  94623. panningDistanceLimit: Nullable<number>;
  94624. /**
  94625. * Defines the target of the camera before paning.
  94626. */
  94627. panningOriginTarget: Vector3;
  94628. /**
  94629. * Defines the value of the inertia used during panning.
  94630. * 0 would mean stop inertia and one would mean no decelleration at all.
  94631. */
  94632. panningInertia: number;
  94633. /**
  94634. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94635. */
  94636. angularSensibilityX: number;
  94637. /**
  94638. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94639. */
  94640. angularSensibilityY: number;
  94641. /**
  94642. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94643. */
  94644. pinchPrecision: number;
  94645. /**
  94646. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94647. * It will be used instead of pinchDeltaPrecision if different from 0.
  94648. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94649. */
  94650. pinchDeltaPercentage: number;
  94651. /**
  94652. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94653. */
  94654. panningSensibility: number;
  94655. /**
  94656. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94657. */
  94658. keysUp: number[];
  94659. /**
  94660. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94661. */
  94662. keysDown: number[];
  94663. /**
  94664. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94665. */
  94666. keysLeft: number[];
  94667. /**
  94668. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94669. */
  94670. keysRight: number[];
  94671. /**
  94672. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94673. */
  94674. wheelPrecision: number;
  94675. /**
  94676. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94677. * It will be used instead of pinchDeltaPrecision if different from 0.
  94678. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94679. */
  94680. wheelDeltaPercentage: number;
  94681. /**
  94682. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94683. */
  94684. zoomOnFactor: number;
  94685. /**
  94686. * Defines a screen offset for the camera position.
  94687. */
  94688. targetScreenOffset: Vector2;
  94689. /**
  94690. * Allows the camera to be completely reversed.
  94691. * If false the camera can not arrive upside down.
  94692. */
  94693. allowUpsideDown: boolean;
  94694. /**
  94695. * Define if double tap/click is used to restore the previously saved state of the camera.
  94696. */
  94697. useInputToRestoreState: boolean;
  94698. /** @hidden */
  94699. _viewMatrix: Matrix;
  94700. /** @hidden */
  94701. _useCtrlForPanning: boolean;
  94702. /** @hidden */
  94703. _panningMouseButton: number;
  94704. /**
  94705. * Defines the input associated to the camera.
  94706. */
  94707. inputs: ArcRotateCameraInputsManager;
  94708. /** @hidden */
  94709. _reset: () => void;
  94710. /**
  94711. * Defines the allowed panning axis.
  94712. */
  94713. panningAxis: Vector3;
  94714. protected _localDirection: Vector3;
  94715. protected _transformedDirection: Vector3;
  94716. private _bouncingBehavior;
  94717. /**
  94718. * Gets the bouncing behavior of the camera if it has been enabled.
  94719. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94720. */
  94721. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94722. /**
  94723. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94724. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94725. */
  94726. useBouncingBehavior: boolean;
  94727. private _framingBehavior;
  94728. /**
  94729. * Gets the framing behavior of the camera if it has been enabled.
  94730. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94731. */
  94732. readonly framingBehavior: Nullable<FramingBehavior>;
  94733. /**
  94734. * Defines if the framing behavior of the camera is enabled on the camera.
  94735. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94736. */
  94737. useFramingBehavior: boolean;
  94738. private _autoRotationBehavior;
  94739. /**
  94740. * Gets the auto rotation behavior of the camera if it has been enabled.
  94741. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94742. */
  94743. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94744. /**
  94745. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94746. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94747. */
  94748. useAutoRotationBehavior: boolean;
  94749. /**
  94750. * Observable triggered when the mesh target has been changed on the camera.
  94751. */
  94752. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94753. /**
  94754. * Event raised when the camera is colliding with a mesh.
  94755. */
  94756. onCollide: (collidedMesh: AbstractMesh) => void;
  94757. /**
  94758. * Defines whether the camera should check collision with the objects oh the scene.
  94759. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94760. */
  94761. checkCollisions: boolean;
  94762. /**
  94763. * Defines the collision radius of the camera.
  94764. * This simulates a sphere around the camera.
  94765. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94766. */
  94767. collisionRadius: Vector3;
  94768. protected _collider: Collider;
  94769. protected _previousPosition: Vector3;
  94770. protected _collisionVelocity: Vector3;
  94771. protected _newPosition: Vector3;
  94772. protected _previousAlpha: number;
  94773. protected _previousBeta: number;
  94774. protected _previousRadius: number;
  94775. protected _collisionTriggered: boolean;
  94776. protected _targetBoundingCenter: Nullable<Vector3>;
  94777. private _computationVector;
  94778. /**
  94779. * Instantiates a new ArcRotateCamera in a given scene
  94780. * @param name Defines the name of the camera
  94781. * @param alpha Defines the camera rotation along the logitudinal axis
  94782. * @param beta Defines the camera rotation along the latitudinal axis
  94783. * @param radius Defines the camera distance from its target
  94784. * @param target Defines the camera target
  94785. * @param scene Defines the scene the camera belongs to
  94786. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94787. */
  94788. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94789. /** @hidden */
  94790. _initCache(): void;
  94791. /** @hidden */
  94792. _updateCache(ignoreParentClass?: boolean): void;
  94793. protected _getTargetPosition(): Vector3;
  94794. private _storedAlpha;
  94795. private _storedBeta;
  94796. private _storedRadius;
  94797. private _storedTarget;
  94798. /**
  94799. * Stores the current state of the camera (alpha, beta, radius and target)
  94800. * @returns the camera itself
  94801. */
  94802. storeState(): Camera;
  94803. /**
  94804. * @hidden
  94805. * Restored camera state. You must call storeState() first
  94806. */
  94807. _restoreStateValues(): boolean;
  94808. /** @hidden */
  94809. _isSynchronizedViewMatrix(): boolean;
  94810. /**
  94811. * Attached controls to the current camera.
  94812. * @param element Defines the element the controls should be listened from
  94813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94814. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94815. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94816. */
  94817. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94818. /**
  94819. * Detach the current controls from the camera.
  94820. * The camera will stop reacting to inputs.
  94821. * @param element Defines the element to stop listening the inputs from
  94822. */
  94823. detachControl(element: HTMLElement): void;
  94824. /** @hidden */
  94825. _checkInputs(): void;
  94826. protected _checkLimits(): void;
  94827. /**
  94828. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94829. */
  94830. rebuildAnglesAndRadius(): void;
  94831. /**
  94832. * Use a position to define the current camera related information like aplha, beta and radius
  94833. * @param position Defines the position to set the camera at
  94834. */
  94835. setPosition(position: Vector3): void;
  94836. /**
  94837. * Defines the target the camera should look at.
  94838. * This will automatically adapt alpha beta and radius to fit within the new target.
  94839. * @param target Defines the new target as a Vector or a mesh
  94840. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94841. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94842. */
  94843. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94844. /** @hidden */
  94845. _getViewMatrix(): Matrix;
  94846. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94847. /**
  94848. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  94849. * @param meshes Defines the mesh to zoom on
  94850. * @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)
  94851. */
  94852. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  94853. /**
  94854. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  94855. * The target will be changed but the radius
  94856. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus 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. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  94860. min: Vector3;
  94861. max: Vector3;
  94862. distance: number;
  94863. }, doNotUpdateMaxZ?: boolean): void;
  94864. /**
  94865. * @override
  94866. * Override Camera.createRigCamera
  94867. */
  94868. createRigCamera(name: string, cameraIndex: number): Camera;
  94869. /**
  94870. * @hidden
  94871. * @override
  94872. * Override Camera._updateRigCameras
  94873. */
  94874. _updateRigCameras(): void;
  94875. /**
  94876. * Destroy the camera and release the current resources hold by it.
  94877. */
  94878. dispose(): void;
  94879. /**
  94880. * Gets the current object class name.
  94881. * @return the class name
  94882. */
  94883. getClassName(): string;
  94884. }
  94885. }
  94886. declare module BABYLON {
  94887. /**
  94888. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  94889. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94890. */
  94891. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  94892. /**
  94893. * Gets the name of the behavior.
  94894. */
  94895. readonly name: string;
  94896. private _zoomStopsAnimation;
  94897. private _idleRotationSpeed;
  94898. private _idleRotationWaitTime;
  94899. private _idleRotationSpinupTime;
  94900. /**
  94901. * Sets the flag that indicates if user zooming should stop animation.
  94902. */
  94903. /**
  94904. * Gets the flag that indicates if user zooming should stop animation.
  94905. */
  94906. zoomStopsAnimation: boolean;
  94907. /**
  94908. * Sets the default speed at which the camera rotates around the model.
  94909. */
  94910. /**
  94911. * Gets the default speed at which the camera rotates around the model.
  94912. */
  94913. idleRotationSpeed: number;
  94914. /**
  94915. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  94916. */
  94917. /**
  94918. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  94919. */
  94920. idleRotationWaitTime: number;
  94921. /**
  94922. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94923. */
  94924. /**
  94925. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94926. */
  94927. idleRotationSpinupTime: number;
  94928. /**
  94929. * Gets a value indicating if the camera is currently rotating because of this behavior
  94930. */
  94931. readonly rotationInProgress: boolean;
  94932. private _onPrePointerObservableObserver;
  94933. private _onAfterCheckInputsObserver;
  94934. private _attachedCamera;
  94935. private _isPointerDown;
  94936. private _lastFrameTime;
  94937. private _lastInteractionTime;
  94938. private _cameraRotationSpeed;
  94939. /**
  94940. * Initializes the behavior.
  94941. */
  94942. init(): void;
  94943. /**
  94944. * Attaches the behavior to its arc rotate camera.
  94945. * @param camera Defines the camera to attach the behavior to
  94946. */
  94947. attach(camera: ArcRotateCamera): void;
  94948. /**
  94949. * Detaches the behavior from its current arc rotate camera.
  94950. */
  94951. detach(): void;
  94952. /**
  94953. * Returns true if user is scrolling.
  94954. * @return true if user is scrolling.
  94955. */
  94956. private _userIsZooming;
  94957. private _lastFrameRadius;
  94958. private _shouldAnimationStopForInteraction;
  94959. /**
  94960. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94961. */
  94962. private _applyUserInteraction;
  94963. private _userIsMoving;
  94964. }
  94965. }
  94966. declare module BABYLON {
  94967. /**
  94968. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  94969. */
  94970. export class AttachToBoxBehavior implements Behavior<Mesh> {
  94971. private ui;
  94972. /**
  94973. * The name of the behavior
  94974. */
  94975. name: string;
  94976. /**
  94977. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  94978. */
  94979. distanceAwayFromFace: number;
  94980. /**
  94981. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  94982. */
  94983. distanceAwayFromBottomOfFace: number;
  94984. private _faceVectors;
  94985. private _target;
  94986. private _scene;
  94987. private _onRenderObserver;
  94988. private _tmpMatrix;
  94989. private _tmpVector;
  94990. /**
  94991. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94992. * @param ui The transform node that should be attched to the mesh
  94993. */
  94994. constructor(ui: TransformNode);
  94995. /**
  94996. * Initializes the behavior
  94997. */
  94998. init(): void;
  94999. private _closestFace;
  95000. private _zeroVector;
  95001. private _lookAtTmpMatrix;
  95002. private _lookAtToRef;
  95003. /**
  95004. * Attaches the AttachToBoxBehavior to the passed in mesh
  95005. * @param target The mesh that the specified node will be attached to
  95006. */
  95007. attach(target: Mesh): void;
  95008. /**
  95009. * Detaches the behavior from the mesh
  95010. */
  95011. detach(): void;
  95012. }
  95013. }
  95014. declare module BABYLON {
  95015. /**
  95016. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95017. */
  95018. export class FadeInOutBehavior implements Behavior<Mesh> {
  95019. /**
  95020. * Time in milliseconds to delay before fading in (Default: 0)
  95021. */
  95022. delay: number;
  95023. /**
  95024. * Time in milliseconds for the mesh to fade in (Default: 300)
  95025. */
  95026. fadeInTime: number;
  95027. private _millisecondsPerFrame;
  95028. private _hovered;
  95029. private _hoverValue;
  95030. private _ownerNode;
  95031. /**
  95032. * Instatiates the FadeInOutBehavior
  95033. */
  95034. constructor();
  95035. /**
  95036. * The name of the behavior
  95037. */
  95038. readonly name: string;
  95039. /**
  95040. * Initializes the behavior
  95041. */
  95042. init(): void;
  95043. /**
  95044. * Attaches the fade behavior on the passed in mesh
  95045. * @param ownerNode The mesh that will be faded in/out once attached
  95046. */
  95047. attach(ownerNode: Mesh): void;
  95048. /**
  95049. * Detaches the behavior from the mesh
  95050. */
  95051. detach(): void;
  95052. /**
  95053. * Triggers the mesh to begin fading in or out
  95054. * @param value if the object should fade in or out (true to fade in)
  95055. */
  95056. fadeIn(value: boolean): void;
  95057. private _update;
  95058. private _setAllVisibility;
  95059. }
  95060. }
  95061. declare module BABYLON {
  95062. /**
  95063. * Class containing a set of static utilities functions for managing Pivots
  95064. * @hidden
  95065. */
  95066. export class PivotTools {
  95067. private static _PivotCached;
  95068. private static _OldPivotPoint;
  95069. private static _PivotTranslation;
  95070. private static _PivotTmpVector;
  95071. /** @hidden */
  95072. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95073. /** @hidden */
  95074. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95075. }
  95076. }
  95077. declare module BABYLON {
  95078. /**
  95079. * Class containing static functions to help procedurally build meshes
  95080. */
  95081. export class PlaneBuilder {
  95082. /**
  95083. * Creates a plane mesh
  95084. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95085. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95086. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95090. * @param name defines the name of the mesh
  95091. * @param options defines the options used to create the mesh
  95092. * @param scene defines the hosting scene
  95093. * @returns the plane mesh
  95094. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95095. */
  95096. static CreatePlane(name: string, options: {
  95097. size?: number;
  95098. width?: number;
  95099. height?: number;
  95100. sideOrientation?: number;
  95101. frontUVs?: Vector4;
  95102. backUVs?: Vector4;
  95103. updatable?: boolean;
  95104. sourcePlane?: Plane;
  95105. }, scene?: Nullable<Scene>): Mesh;
  95106. }
  95107. }
  95108. declare module BABYLON {
  95109. /**
  95110. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95111. */
  95112. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95113. private static _AnyMouseID;
  95114. private _attachedNode;
  95115. private _dragPlane;
  95116. private _scene;
  95117. private _pointerObserver;
  95118. private _beforeRenderObserver;
  95119. private static _planeScene;
  95120. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95121. /**
  95122. * 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)
  95123. */
  95124. maxDragAngle: number;
  95125. /**
  95126. * @hidden
  95127. */
  95128. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95129. /**
  95130. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95131. */
  95132. currentDraggingPointerID: number;
  95133. /**
  95134. * The last position where the pointer hit the drag plane in world space
  95135. */
  95136. lastDragPosition: Vector3;
  95137. /**
  95138. * If the behavior is currently in a dragging state
  95139. */
  95140. dragging: boolean;
  95141. /**
  95142. * 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)
  95143. */
  95144. dragDeltaRatio: number;
  95145. /**
  95146. * If the drag plane orientation should be updated during the dragging (Default: true)
  95147. */
  95148. updateDragPlane: boolean;
  95149. private _debugMode;
  95150. private _moving;
  95151. /**
  95152. * Fires each time the attached mesh is dragged with the pointer
  95153. * * delta between last drag position and current drag position in world space
  95154. * * dragDistance along the drag axis
  95155. * * dragPlaneNormal normal of the current drag plane used during the drag
  95156. * * dragPlanePoint in world space where the drag intersects the drag plane
  95157. */
  95158. onDragObservable: Observable<{
  95159. delta: Vector3;
  95160. dragPlanePoint: Vector3;
  95161. dragPlaneNormal: Vector3;
  95162. dragDistance: number;
  95163. pointerId: number;
  95164. }>;
  95165. /**
  95166. * Fires each time a drag begins (eg. mouse down on mesh)
  95167. */
  95168. onDragStartObservable: Observable<{
  95169. dragPlanePoint: Vector3;
  95170. pointerId: number;
  95171. }>;
  95172. /**
  95173. * Fires each time a drag ends (eg. mouse release after drag)
  95174. */
  95175. onDragEndObservable: Observable<{
  95176. dragPlanePoint: Vector3;
  95177. pointerId: number;
  95178. }>;
  95179. /**
  95180. * If the attached mesh should be moved when dragged
  95181. */
  95182. moveAttached: boolean;
  95183. /**
  95184. * If the drag behavior will react to drag events (Default: true)
  95185. */
  95186. enabled: boolean;
  95187. /**
  95188. * If camera controls should be detached during the drag
  95189. */
  95190. detachCameraControls: boolean;
  95191. /**
  95192. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95193. */
  95194. useObjectOrienationForDragging: boolean;
  95195. private _options;
  95196. /**
  95197. * Creates a pointer drag behavior that can be attached to a mesh
  95198. * @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)
  95199. */
  95200. constructor(options?: {
  95201. dragAxis?: Vector3;
  95202. dragPlaneNormal?: Vector3;
  95203. });
  95204. /**
  95205. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95206. */
  95207. validateDrag: (targetPosition: Vector3) => boolean;
  95208. /**
  95209. * The name of the behavior
  95210. */
  95211. readonly name: string;
  95212. /**
  95213. * Initializes the behavior
  95214. */
  95215. init(): void;
  95216. private _tmpVector;
  95217. private _alternatePickedPoint;
  95218. private _worldDragAxis;
  95219. private _targetPosition;
  95220. private _attachedElement;
  95221. /**
  95222. * Attaches the drag behavior the passed in mesh
  95223. * @param ownerNode The mesh that will be dragged around once attached
  95224. */
  95225. attach(ownerNode: AbstractMesh): void;
  95226. /**
  95227. * Force relase the drag action by code.
  95228. */
  95229. releaseDrag(): void;
  95230. private _startDragRay;
  95231. private _lastPointerRay;
  95232. /**
  95233. * Simulates the start of a pointer drag event on the behavior
  95234. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95235. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95236. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95237. */
  95238. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95239. private _startDrag;
  95240. private _dragDelta;
  95241. private _moveDrag;
  95242. private _pickWithRayOnDragPlane;
  95243. private _pointA;
  95244. private _pointB;
  95245. private _pointC;
  95246. private _lineA;
  95247. private _lineB;
  95248. private _localAxis;
  95249. private _lookAt;
  95250. private _updateDragPlanePosition;
  95251. /**
  95252. * Detaches the behavior from the mesh
  95253. */
  95254. detach(): void;
  95255. }
  95256. }
  95257. declare module BABYLON {
  95258. /**
  95259. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95260. */
  95261. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95262. private _dragBehaviorA;
  95263. private _dragBehaviorB;
  95264. private _startDistance;
  95265. private _initialScale;
  95266. private _targetScale;
  95267. private _ownerNode;
  95268. private _sceneRenderObserver;
  95269. /**
  95270. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95271. */
  95272. constructor();
  95273. /**
  95274. * The name of the behavior
  95275. */
  95276. readonly name: string;
  95277. /**
  95278. * Initializes the behavior
  95279. */
  95280. init(): void;
  95281. private _getCurrentDistance;
  95282. /**
  95283. * Attaches the scale behavior the passed in mesh
  95284. * @param ownerNode The mesh that will be scaled around once attached
  95285. */
  95286. attach(ownerNode: Mesh): void;
  95287. /**
  95288. * Detaches the behavior from the mesh
  95289. */
  95290. detach(): void;
  95291. }
  95292. }
  95293. declare module BABYLON {
  95294. /**
  95295. * 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
  95296. */
  95297. export class SixDofDragBehavior implements Behavior<Mesh> {
  95298. private static _virtualScene;
  95299. private _ownerNode;
  95300. private _sceneRenderObserver;
  95301. private _scene;
  95302. private _targetPosition;
  95303. private _virtualOriginMesh;
  95304. private _virtualDragMesh;
  95305. private _pointerObserver;
  95306. private _moving;
  95307. private _startingOrientation;
  95308. /**
  95309. * 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)
  95310. */
  95311. private zDragFactor;
  95312. /**
  95313. * If the object should rotate to face the drag origin
  95314. */
  95315. rotateDraggedObject: boolean;
  95316. /**
  95317. * If the behavior is currently in a dragging state
  95318. */
  95319. dragging: boolean;
  95320. /**
  95321. * 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)
  95322. */
  95323. dragDeltaRatio: number;
  95324. /**
  95325. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95326. */
  95327. currentDraggingPointerID: number;
  95328. /**
  95329. * If camera controls should be detached during the drag
  95330. */
  95331. detachCameraControls: boolean;
  95332. /**
  95333. * Fires each time a drag starts
  95334. */
  95335. onDragStartObservable: Observable<{}>;
  95336. /**
  95337. * Fires each time a drag ends (eg. mouse release after drag)
  95338. */
  95339. onDragEndObservable: Observable<{}>;
  95340. /**
  95341. * 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
  95342. */
  95343. constructor();
  95344. /**
  95345. * The name of the behavior
  95346. */
  95347. readonly name: string;
  95348. /**
  95349. * Initializes the behavior
  95350. */
  95351. init(): void;
  95352. /**
  95353. * Attaches the scale behavior the passed in mesh
  95354. * @param ownerNode The mesh that will be scaled around once attached
  95355. */
  95356. attach(ownerNode: Mesh): void;
  95357. /**
  95358. * Detaches the behavior from the mesh
  95359. */
  95360. detach(): void;
  95361. }
  95362. }
  95363. declare module BABYLON {
  95364. /**
  95365. * Class used to apply inverse kinematics to bones
  95366. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95367. */
  95368. export class BoneIKController {
  95369. private static _tmpVecs;
  95370. private static _tmpQuat;
  95371. private static _tmpMats;
  95372. /**
  95373. * Gets or sets the target mesh
  95374. */
  95375. targetMesh: AbstractMesh;
  95376. /** Gets or sets the mesh used as pole */
  95377. poleTargetMesh: AbstractMesh;
  95378. /**
  95379. * Gets or sets the bone used as pole
  95380. */
  95381. poleTargetBone: Nullable<Bone>;
  95382. /**
  95383. * Gets or sets the target position
  95384. */
  95385. targetPosition: Vector3;
  95386. /**
  95387. * Gets or sets the pole target position
  95388. */
  95389. poleTargetPosition: Vector3;
  95390. /**
  95391. * Gets or sets the pole target local offset
  95392. */
  95393. poleTargetLocalOffset: Vector3;
  95394. /**
  95395. * Gets or sets the pole angle
  95396. */
  95397. poleAngle: number;
  95398. /**
  95399. * Gets or sets the mesh associated with the controller
  95400. */
  95401. mesh: AbstractMesh;
  95402. /**
  95403. * 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)
  95404. */
  95405. slerpAmount: number;
  95406. private _bone1Quat;
  95407. private _bone1Mat;
  95408. private _bone2Ang;
  95409. private _bone1;
  95410. private _bone2;
  95411. private _bone1Length;
  95412. private _bone2Length;
  95413. private _maxAngle;
  95414. private _maxReach;
  95415. private _rightHandedSystem;
  95416. private _bendAxis;
  95417. private _slerping;
  95418. private _adjustRoll;
  95419. /**
  95420. * Gets or sets maximum allowed angle
  95421. */
  95422. maxAngle: number;
  95423. /**
  95424. * Creates a new BoneIKController
  95425. * @param mesh defines the mesh to control
  95426. * @param bone defines the bone to control
  95427. * @param options defines options to set up the controller
  95428. */
  95429. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95430. targetMesh?: AbstractMesh;
  95431. poleTargetMesh?: AbstractMesh;
  95432. poleTargetBone?: Bone;
  95433. poleTargetLocalOffset?: Vector3;
  95434. poleAngle?: number;
  95435. bendAxis?: Vector3;
  95436. maxAngle?: number;
  95437. slerpAmount?: number;
  95438. });
  95439. private _setMaxAngle;
  95440. /**
  95441. * Force the controller to update the bones
  95442. */
  95443. update(): void;
  95444. }
  95445. }
  95446. declare module BABYLON {
  95447. /**
  95448. * Class used to make a bone look toward a point in space
  95449. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95450. */
  95451. export class BoneLookController {
  95452. private static _tmpVecs;
  95453. private static _tmpQuat;
  95454. private static _tmpMats;
  95455. /**
  95456. * The target Vector3 that the bone will look at
  95457. */
  95458. target: Vector3;
  95459. /**
  95460. * The mesh that the bone is attached to
  95461. */
  95462. mesh: AbstractMesh;
  95463. /**
  95464. * The bone that will be looking to the target
  95465. */
  95466. bone: Bone;
  95467. /**
  95468. * The up axis of the coordinate system that is used when the bone is rotated
  95469. */
  95470. upAxis: Vector3;
  95471. /**
  95472. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95473. */
  95474. upAxisSpace: Space;
  95475. /**
  95476. * Used to make an adjustment to the yaw of the bone
  95477. */
  95478. adjustYaw: number;
  95479. /**
  95480. * Used to make an adjustment to the pitch of the bone
  95481. */
  95482. adjustPitch: number;
  95483. /**
  95484. * Used to make an adjustment to the roll of the bone
  95485. */
  95486. adjustRoll: number;
  95487. /**
  95488. * 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)
  95489. */
  95490. slerpAmount: number;
  95491. private _minYaw;
  95492. private _maxYaw;
  95493. private _minPitch;
  95494. private _maxPitch;
  95495. private _minYawSin;
  95496. private _minYawCos;
  95497. private _maxYawSin;
  95498. private _maxYawCos;
  95499. private _midYawConstraint;
  95500. private _minPitchTan;
  95501. private _maxPitchTan;
  95502. private _boneQuat;
  95503. private _slerping;
  95504. private _transformYawPitch;
  95505. private _transformYawPitchInv;
  95506. private _firstFrameSkipped;
  95507. private _yawRange;
  95508. private _fowardAxis;
  95509. /**
  95510. * Gets or sets the minimum yaw angle that the bone can look to
  95511. */
  95512. minYaw: number;
  95513. /**
  95514. * Gets or sets the maximum yaw angle that the bone can look to
  95515. */
  95516. maxYaw: number;
  95517. /**
  95518. * Gets or sets the minimum pitch angle that the bone can look to
  95519. */
  95520. minPitch: number;
  95521. /**
  95522. * Gets or sets the maximum pitch angle that the bone can look to
  95523. */
  95524. maxPitch: number;
  95525. /**
  95526. * Create a BoneLookController
  95527. * @param mesh the mesh that the bone belongs to
  95528. * @param bone the bone that will be looking to the target
  95529. * @param target the target Vector3 to look at
  95530. * @param options optional settings:
  95531. * * maxYaw: the maximum angle the bone will yaw to
  95532. * * minYaw: the minimum angle the bone will yaw to
  95533. * * maxPitch: the maximum angle the bone will pitch to
  95534. * * minPitch: the minimum angle the bone will yaw to
  95535. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  95536. * * upAxis: the up axis of the coordinate system
  95537. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  95538. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  95539. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  95540. * * adjustYaw: used to make an adjustment to the yaw of the bone
  95541. * * adjustPitch: used to make an adjustment to the pitch of the bone
  95542. * * adjustRoll: used to make an adjustment to the roll of the bone
  95543. **/
  95544. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  95545. maxYaw?: number;
  95546. minYaw?: number;
  95547. maxPitch?: number;
  95548. minPitch?: number;
  95549. slerpAmount?: number;
  95550. upAxis?: Vector3;
  95551. upAxisSpace?: Space;
  95552. yawAxis?: Vector3;
  95553. pitchAxis?: Vector3;
  95554. adjustYaw?: number;
  95555. adjustPitch?: number;
  95556. adjustRoll?: number;
  95557. });
  95558. /**
  95559. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  95560. */
  95561. update(): void;
  95562. private _getAngleDiff;
  95563. private _getAngleBetween;
  95564. private _isAngleBetween;
  95565. }
  95566. }
  95567. declare module BABYLON {
  95568. /**
  95569. * Manage the gamepad inputs to control an arc rotate camera.
  95570. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95571. */
  95572. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95573. /**
  95574. * Defines the camera the input is attached to.
  95575. */
  95576. camera: ArcRotateCamera;
  95577. /**
  95578. * Defines the gamepad the input is gathering event from.
  95579. */
  95580. gamepad: Nullable<Gamepad>;
  95581. /**
  95582. * Defines the gamepad rotation sensiblity.
  95583. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95584. */
  95585. gamepadRotationSensibility: number;
  95586. /**
  95587. * Defines the gamepad move sensiblity.
  95588. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95589. */
  95590. gamepadMoveSensibility: number;
  95591. private _onGamepadConnectedObserver;
  95592. private _onGamepadDisconnectedObserver;
  95593. /**
  95594. * Attach the input controls to a specific dom element to get the input from.
  95595. * @param element Defines the element the controls should be listened from
  95596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95597. */
  95598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95599. /**
  95600. * Detach the current controls from the specified dom element.
  95601. * @param element Defines the element to stop listening the inputs from
  95602. */
  95603. detachControl(element: Nullable<HTMLElement>): void;
  95604. /**
  95605. * Update the current camera state depending on the inputs that have been used this frame.
  95606. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95607. */
  95608. checkInputs(): void;
  95609. /**
  95610. * Gets the class name of the current intput.
  95611. * @returns the class name
  95612. */
  95613. getClassName(): string;
  95614. /**
  95615. * Get the friendly name associated with the input class.
  95616. * @returns the input friendly name
  95617. */
  95618. getSimpleName(): string;
  95619. }
  95620. }
  95621. declare module BABYLON {
  95622. interface ArcRotateCameraInputsManager {
  95623. /**
  95624. * Add orientation input support to the input manager.
  95625. * @returns the current input manager
  95626. */
  95627. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95628. }
  95629. /**
  95630. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95632. */
  95633. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95634. /**
  95635. * Defines the camera the input is attached to.
  95636. */
  95637. camera: ArcRotateCamera;
  95638. /**
  95639. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95640. */
  95641. alphaCorrection: number;
  95642. /**
  95643. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95644. */
  95645. gammaCorrection: number;
  95646. private _alpha;
  95647. private _gamma;
  95648. private _dirty;
  95649. private _deviceOrientationHandler;
  95650. /**
  95651. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95652. */
  95653. constructor();
  95654. /**
  95655. * Attach the input controls to a specific dom element to get the input from.
  95656. * @param element Defines the element the controls should be listened from
  95657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95658. */
  95659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95660. /** @hidden */
  95661. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95662. /**
  95663. * Update the current camera state depending on the inputs that have been used this frame.
  95664. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95665. */
  95666. checkInputs(): void;
  95667. /**
  95668. * Detach the current controls from the specified dom element.
  95669. * @param element Defines the element to stop listening the inputs from
  95670. */
  95671. detachControl(element: Nullable<HTMLElement>): void;
  95672. /**
  95673. * Gets the class name of the current intput.
  95674. * @returns the class name
  95675. */
  95676. getClassName(): string;
  95677. /**
  95678. * Get the friendly name associated with the input class.
  95679. * @returns the input friendly name
  95680. */
  95681. getSimpleName(): string;
  95682. }
  95683. }
  95684. declare module BABYLON {
  95685. /**
  95686. * Listen to mouse events to control the camera.
  95687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95688. */
  95689. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95690. /**
  95691. * Defines the camera the input is attached to.
  95692. */
  95693. camera: FlyCamera;
  95694. /**
  95695. * Defines if touch is enabled. (Default is true.)
  95696. */
  95697. touchEnabled: boolean;
  95698. /**
  95699. * Defines the buttons associated with the input to handle camera rotation.
  95700. */
  95701. buttons: number[];
  95702. /**
  95703. * Assign buttons for Yaw control.
  95704. */
  95705. buttonsYaw: number[];
  95706. /**
  95707. * Assign buttons for Pitch control.
  95708. */
  95709. buttonsPitch: number[];
  95710. /**
  95711. * Assign buttons for Roll control.
  95712. */
  95713. buttonsRoll: number[];
  95714. /**
  95715. * Detect if any button is being pressed while mouse is moved.
  95716. * -1 = Mouse locked.
  95717. * 0 = Left button.
  95718. * 1 = Middle Button.
  95719. * 2 = Right Button.
  95720. */
  95721. activeButton: number;
  95722. /**
  95723. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95724. * Higher values reduce its sensitivity.
  95725. */
  95726. angularSensibility: number;
  95727. private _mousemoveCallback;
  95728. private _observer;
  95729. private _rollObserver;
  95730. private previousPosition;
  95731. private noPreventDefault;
  95732. private element;
  95733. /**
  95734. * Listen to mouse events to control the camera.
  95735. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95737. */
  95738. constructor(touchEnabled?: boolean);
  95739. /**
  95740. * Attach the mouse control to the HTML DOM element.
  95741. * @param element Defines the element that listens to the input events.
  95742. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95743. */
  95744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95745. /**
  95746. * Detach the current controls from the specified dom element.
  95747. * @param element Defines the element to stop listening the inputs from
  95748. */
  95749. detachControl(element: Nullable<HTMLElement>): void;
  95750. /**
  95751. * Gets the class name of the current input.
  95752. * @returns the class name.
  95753. */
  95754. getClassName(): string;
  95755. /**
  95756. * Get the friendly name associated with the input class.
  95757. * @returns the input's friendly name.
  95758. */
  95759. getSimpleName(): string;
  95760. private _pointerInput;
  95761. private _onMouseMove;
  95762. /**
  95763. * Rotate camera by mouse offset.
  95764. */
  95765. private rotateCamera;
  95766. }
  95767. }
  95768. declare module BABYLON {
  95769. /**
  95770. * Default Inputs manager for the FlyCamera.
  95771. * It groups all the default supported inputs for ease of use.
  95772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95773. */
  95774. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95775. /**
  95776. * Instantiates a new FlyCameraInputsManager.
  95777. * @param camera Defines the camera the inputs belong to.
  95778. */
  95779. constructor(camera: FlyCamera);
  95780. /**
  95781. * Add keyboard input support to the input manager.
  95782. * @returns the new FlyCameraKeyboardMoveInput().
  95783. */
  95784. addKeyboard(): FlyCameraInputsManager;
  95785. /**
  95786. * Add mouse input support to the input manager.
  95787. * @param touchEnabled Enable touch screen support.
  95788. * @returns the new FlyCameraMouseInput().
  95789. */
  95790. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95791. }
  95792. }
  95793. declare module BABYLON {
  95794. /**
  95795. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95796. * such as in a 3D Space Shooter or a Flight Simulator.
  95797. */
  95798. export class FlyCamera extends TargetCamera {
  95799. /**
  95800. * Define the collision ellipsoid of the camera.
  95801. * This is helpful for simulating a camera body, like a player's body.
  95802. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95803. */
  95804. ellipsoid: Vector3;
  95805. /**
  95806. * Define an offset for the position of the ellipsoid around the camera.
  95807. * This can be helpful if the camera is attached away from the player's body center,
  95808. * such as at its head.
  95809. */
  95810. ellipsoidOffset: Vector3;
  95811. /**
  95812. * Enable or disable collisions of the camera with the rest of the scene objects.
  95813. */
  95814. checkCollisions: boolean;
  95815. /**
  95816. * Enable or disable gravity on the camera.
  95817. */
  95818. applyGravity: boolean;
  95819. /**
  95820. * Define the current direction the camera is moving to.
  95821. */
  95822. cameraDirection: Vector3;
  95823. /**
  95824. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95825. * This overrides and empties cameraRotation.
  95826. */
  95827. rotationQuaternion: Quaternion;
  95828. /**
  95829. * Track Roll to maintain the wanted Rolling when looking around.
  95830. */
  95831. _trackRoll: number;
  95832. /**
  95833. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95834. */
  95835. rollCorrect: number;
  95836. /**
  95837. * Mimic a banked turn, Rolling the camera when Yawing.
  95838. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95839. */
  95840. bankedTurn: boolean;
  95841. /**
  95842. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95843. */
  95844. bankedTurnLimit: number;
  95845. /**
  95846. * Value of 0 disables the banked Roll.
  95847. * Value of 1 is equal to the Yaw angle in radians.
  95848. */
  95849. bankedTurnMultiplier: number;
  95850. /**
  95851. * The inputs manager loads all the input sources, such as keyboard and mouse.
  95852. */
  95853. inputs: FlyCameraInputsManager;
  95854. /**
  95855. * Gets the input sensibility for mouse input.
  95856. * Higher values reduce sensitivity.
  95857. */
  95858. /**
  95859. * Sets the input sensibility for a mouse input.
  95860. * Higher values reduce sensitivity.
  95861. */
  95862. angularSensibility: number;
  95863. /**
  95864. * Get the keys for camera movement forward.
  95865. */
  95866. /**
  95867. * Set the keys for camera movement forward.
  95868. */
  95869. keysForward: number[];
  95870. /**
  95871. * Get the keys for camera movement backward.
  95872. */
  95873. keysBackward: number[];
  95874. /**
  95875. * Get the keys for camera movement up.
  95876. */
  95877. /**
  95878. * Set the keys for camera movement up.
  95879. */
  95880. keysUp: number[];
  95881. /**
  95882. * Get the keys for camera movement down.
  95883. */
  95884. /**
  95885. * Set the keys for camera movement down.
  95886. */
  95887. keysDown: number[];
  95888. /**
  95889. * Get the keys for camera movement left.
  95890. */
  95891. /**
  95892. * Set the keys for camera movement left.
  95893. */
  95894. keysLeft: number[];
  95895. /**
  95896. * Set the keys for camera movement right.
  95897. */
  95898. /**
  95899. * Set the keys for camera movement right.
  95900. */
  95901. keysRight: number[];
  95902. /**
  95903. * Event raised when the camera collides with a mesh in the scene.
  95904. */
  95905. onCollide: (collidedMesh: AbstractMesh) => void;
  95906. private _collider;
  95907. private _needMoveForGravity;
  95908. private _oldPosition;
  95909. private _diffPosition;
  95910. private _newPosition;
  95911. /** @hidden */
  95912. _localDirection: Vector3;
  95913. /** @hidden */
  95914. _transformedDirection: Vector3;
  95915. /**
  95916. * Instantiates a FlyCamera.
  95917. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95918. * such as in a 3D Space Shooter or a Flight Simulator.
  95919. * @param name Define the name of the camera in the scene.
  95920. * @param position Define the starting position of the camera in the scene.
  95921. * @param scene Define the scene the camera belongs to.
  95922. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  95923. */
  95924. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95925. /**
  95926. * Attach a control to the HTML DOM element.
  95927. * @param element Defines the element that listens to the input events.
  95928. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  95929. */
  95930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95931. /**
  95932. * Detach a control from the HTML DOM element.
  95933. * The camera will stop reacting to that input.
  95934. * @param element Defines the element that listens to the input events.
  95935. */
  95936. detachControl(element: HTMLElement): void;
  95937. private _collisionMask;
  95938. /**
  95939. * Get the mask that the camera ignores in collision events.
  95940. */
  95941. /**
  95942. * Set the mask that the camera ignores in collision events.
  95943. */
  95944. collisionMask: number;
  95945. /** @hidden */
  95946. _collideWithWorld(displacement: Vector3): void;
  95947. /** @hidden */
  95948. private _onCollisionPositionChange;
  95949. /** @hidden */
  95950. _checkInputs(): void;
  95951. /** @hidden */
  95952. _decideIfNeedsToMove(): boolean;
  95953. /** @hidden */
  95954. _updatePosition(): void;
  95955. /**
  95956. * Restore the Roll to its target value at the rate specified.
  95957. * @param rate - Higher means slower restoring.
  95958. * @hidden
  95959. */
  95960. restoreRoll(rate: number): void;
  95961. /**
  95962. * Destroy the camera and release the current resources held by it.
  95963. */
  95964. dispose(): void;
  95965. /**
  95966. * Get the current object class name.
  95967. * @returns the class name.
  95968. */
  95969. getClassName(): string;
  95970. }
  95971. }
  95972. declare module BABYLON {
  95973. /**
  95974. * Listen to keyboard events to control the camera.
  95975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95976. */
  95977. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  95978. /**
  95979. * Defines the camera the input is attached to.
  95980. */
  95981. camera: FlyCamera;
  95982. /**
  95983. * The list of keyboard keys used to control the forward move of the camera.
  95984. */
  95985. keysForward: number[];
  95986. /**
  95987. * The list of keyboard keys used to control the backward move of the camera.
  95988. */
  95989. keysBackward: number[];
  95990. /**
  95991. * The list of keyboard keys used to control the forward move of the camera.
  95992. */
  95993. keysUp: number[];
  95994. /**
  95995. * The list of keyboard keys used to control the backward move of the camera.
  95996. */
  95997. keysDown: number[];
  95998. /**
  95999. * The list of keyboard keys used to control the right strafe move of the camera.
  96000. */
  96001. keysRight: number[];
  96002. /**
  96003. * The list of keyboard keys used to control the left strafe move of the camera.
  96004. */
  96005. keysLeft: number[];
  96006. private _keys;
  96007. private _onCanvasBlurObserver;
  96008. private _onKeyboardObserver;
  96009. private _engine;
  96010. private _scene;
  96011. /**
  96012. * Attach the input controls to a specific dom element to get the input from.
  96013. * @param element Defines the element the controls should be listened from
  96014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96015. */
  96016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96017. /**
  96018. * Detach the current controls from the specified dom element.
  96019. * @param element Defines the element to stop listening the inputs from
  96020. */
  96021. detachControl(element: Nullable<HTMLElement>): void;
  96022. /**
  96023. * Gets the class name of the current intput.
  96024. * @returns the class name
  96025. */
  96026. getClassName(): string;
  96027. /** @hidden */
  96028. _onLostFocus(e: FocusEvent): void;
  96029. /**
  96030. * Get the friendly name associated with the input class.
  96031. * @returns the input friendly name
  96032. */
  96033. getSimpleName(): string;
  96034. /**
  96035. * Update the current camera state depending on the inputs that have been used this frame.
  96036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96037. */
  96038. checkInputs(): void;
  96039. }
  96040. }
  96041. declare module BABYLON {
  96042. /**
  96043. * Manage the mouse wheel inputs to control a follow camera.
  96044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96045. */
  96046. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96047. /**
  96048. * Defines the camera the input is attached to.
  96049. */
  96050. camera: FollowCamera;
  96051. /**
  96052. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96053. */
  96054. axisControlRadius: boolean;
  96055. /**
  96056. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96057. */
  96058. axisControlHeight: boolean;
  96059. /**
  96060. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96061. */
  96062. axisControlRotation: boolean;
  96063. /**
  96064. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96065. * relation to mouseWheel events.
  96066. */
  96067. wheelPrecision: number;
  96068. /**
  96069. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96070. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96071. */
  96072. wheelDeltaPercentage: number;
  96073. private _wheel;
  96074. private _observer;
  96075. /**
  96076. * Attach the input controls to a specific dom element to get the input from.
  96077. * @param element Defines the element the controls should be listened from
  96078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96079. */
  96080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96081. /**
  96082. * Detach the current controls from the specified dom element.
  96083. * @param element Defines the element to stop listening the inputs from
  96084. */
  96085. detachControl(element: Nullable<HTMLElement>): void;
  96086. /**
  96087. * Gets the class name of the current intput.
  96088. * @returns the class name
  96089. */
  96090. getClassName(): string;
  96091. /**
  96092. * Get the friendly name associated with the input class.
  96093. * @returns the input friendly name
  96094. */
  96095. getSimpleName(): string;
  96096. }
  96097. }
  96098. declare module BABYLON {
  96099. /**
  96100. * Manage the pointers inputs to control an follow camera.
  96101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96102. */
  96103. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96104. /**
  96105. * Defines the camera the input is attached to.
  96106. */
  96107. camera: FollowCamera;
  96108. /**
  96109. * Gets the class name of the current input.
  96110. * @returns the class name
  96111. */
  96112. getClassName(): string;
  96113. /**
  96114. * Defines the pointer angular sensibility along the X axis or how fast is
  96115. * the camera rotating.
  96116. * A negative number will reverse the axis direction.
  96117. */
  96118. angularSensibilityX: number;
  96119. /**
  96120. * Defines the pointer angular sensibility along the Y axis or how fast is
  96121. * the camera rotating.
  96122. * A negative number will reverse the axis direction.
  96123. */
  96124. angularSensibilityY: number;
  96125. /**
  96126. * Defines the pointer pinch precision or how fast is the camera zooming.
  96127. * A negative number will reverse the axis direction.
  96128. */
  96129. pinchPrecision: number;
  96130. /**
  96131. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96132. * from 0.
  96133. * It defines the percentage of current camera.radius to use as delta when
  96134. * pinch zoom is used.
  96135. */
  96136. pinchDeltaPercentage: number;
  96137. /**
  96138. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96139. */
  96140. axisXControlRadius: boolean;
  96141. /**
  96142. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96143. */
  96144. axisXControlHeight: boolean;
  96145. /**
  96146. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96147. */
  96148. axisXControlRotation: boolean;
  96149. /**
  96150. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96151. */
  96152. axisYControlRadius: boolean;
  96153. /**
  96154. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96155. */
  96156. axisYControlHeight: boolean;
  96157. /**
  96158. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96159. */
  96160. axisYControlRotation: boolean;
  96161. /**
  96162. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96163. */
  96164. axisPinchControlRadius: boolean;
  96165. /**
  96166. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96167. */
  96168. axisPinchControlHeight: boolean;
  96169. /**
  96170. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96171. */
  96172. axisPinchControlRotation: boolean;
  96173. /**
  96174. * Log error messages if basic misconfiguration has occurred.
  96175. */
  96176. warningEnable: boolean;
  96177. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96178. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96179. private _warningCounter;
  96180. private _warning;
  96181. }
  96182. }
  96183. declare module BABYLON {
  96184. /**
  96185. * Default Inputs manager for the FollowCamera.
  96186. * It groups all the default supported inputs for ease of use.
  96187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96188. */
  96189. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96190. /**
  96191. * Instantiates a new FollowCameraInputsManager.
  96192. * @param camera Defines the camera the inputs belong to
  96193. */
  96194. constructor(camera: FollowCamera);
  96195. /**
  96196. * Add keyboard input support to the input manager.
  96197. * @returns the current input manager
  96198. */
  96199. addKeyboard(): FollowCameraInputsManager;
  96200. /**
  96201. * Add mouse wheel input support to the input manager.
  96202. * @returns the current input manager
  96203. */
  96204. addMouseWheel(): FollowCameraInputsManager;
  96205. /**
  96206. * Add pointers input support to the input manager.
  96207. * @returns the current input manager
  96208. */
  96209. addPointers(): FollowCameraInputsManager;
  96210. /**
  96211. * Add orientation input support to the input manager.
  96212. * @returns the current input manager
  96213. */
  96214. addVRDeviceOrientation(): FollowCameraInputsManager;
  96215. }
  96216. }
  96217. declare module BABYLON {
  96218. /**
  96219. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96220. * an arc rotate version arcFollowCamera are available.
  96221. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96222. */
  96223. export class FollowCamera extends TargetCamera {
  96224. /**
  96225. * Distance the follow camera should follow an object at
  96226. */
  96227. radius: number;
  96228. /**
  96229. * Minimum allowed distance of the camera to the axis of rotation
  96230. * (The camera can not get closer).
  96231. * This can help limiting how the Camera is able to move in the scene.
  96232. */
  96233. lowerRadiusLimit: Nullable<number>;
  96234. /**
  96235. * Maximum allowed distance of the camera to the axis of rotation
  96236. * (The camera can not get further).
  96237. * This can help limiting how the Camera is able to move in the scene.
  96238. */
  96239. upperRadiusLimit: Nullable<number>;
  96240. /**
  96241. * Define a rotation offset between the camera and the object it follows
  96242. */
  96243. rotationOffset: number;
  96244. /**
  96245. * Minimum allowed angle to camera position relative to target object.
  96246. * This can help limiting how the Camera is able to move in the scene.
  96247. */
  96248. lowerRotationOffsetLimit: Nullable<number>;
  96249. /**
  96250. * Maximum allowed angle to camera position relative to target object.
  96251. * This can help limiting how the Camera is able to move in the scene.
  96252. */
  96253. upperRotationOffsetLimit: Nullable<number>;
  96254. /**
  96255. * Define a height offset between the camera and the object it follows.
  96256. * It can help following an object from the top (like a car chaing a plane)
  96257. */
  96258. heightOffset: number;
  96259. /**
  96260. * Minimum allowed height of camera position relative to target object.
  96261. * This can help limiting how the Camera is able to move in the scene.
  96262. */
  96263. lowerHeightOffsetLimit: Nullable<number>;
  96264. /**
  96265. * Maximum allowed height of camera position relative to target object.
  96266. * This can help limiting how the Camera is able to move in the scene.
  96267. */
  96268. upperHeightOffsetLimit: Nullable<number>;
  96269. /**
  96270. * Define how fast the camera can accelerate to follow it s target.
  96271. */
  96272. cameraAcceleration: number;
  96273. /**
  96274. * Define the speed limit of the camera following an object.
  96275. */
  96276. maxCameraSpeed: number;
  96277. /**
  96278. * Define the target of the camera.
  96279. */
  96280. lockedTarget: Nullable<AbstractMesh>;
  96281. /**
  96282. * Defines the input associated with the camera.
  96283. */
  96284. inputs: FollowCameraInputsManager;
  96285. /**
  96286. * Instantiates the follow camera.
  96287. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96288. * @param name Define the name of the camera in the scene
  96289. * @param position Define the position of the camera
  96290. * @param scene Define the scene the camera belong to
  96291. * @param lockedTarget Define the target of the camera
  96292. */
  96293. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96294. private _follow;
  96295. /**
  96296. * Attached controls to the current camera.
  96297. * @param element Defines the element the controls should be listened from
  96298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96299. */
  96300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96301. /**
  96302. * Detach the current controls from the camera.
  96303. * The camera will stop reacting to inputs.
  96304. * @param element Defines the element to stop listening the inputs from
  96305. */
  96306. detachControl(element: HTMLElement): void;
  96307. /** @hidden */
  96308. _checkInputs(): void;
  96309. private _checkLimits;
  96310. /**
  96311. * Gets the camera class name.
  96312. * @returns the class name
  96313. */
  96314. getClassName(): string;
  96315. }
  96316. /**
  96317. * Arc Rotate version of the follow camera.
  96318. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96319. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96320. */
  96321. export class ArcFollowCamera extends TargetCamera {
  96322. /** The longitudinal angle of the camera */
  96323. alpha: number;
  96324. /** The latitudinal angle of the camera */
  96325. beta: number;
  96326. /** The radius of the camera from its target */
  96327. radius: number;
  96328. /** Define the camera target (the messh it should follow) */
  96329. target: Nullable<AbstractMesh>;
  96330. private _cartesianCoordinates;
  96331. /**
  96332. * Instantiates a new ArcFollowCamera
  96333. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96334. * @param name Define the name of the camera
  96335. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96336. * @param beta Define the rotation angle of the camera around the elevation axis
  96337. * @param radius Define the radius of the camera from its target point
  96338. * @param target Define the target of the camera
  96339. * @param scene Define the scene the camera belongs to
  96340. */
  96341. constructor(name: string,
  96342. /** The longitudinal angle of the camera */
  96343. alpha: number,
  96344. /** The latitudinal angle of the camera */
  96345. beta: number,
  96346. /** The radius of the camera from its target */
  96347. radius: number,
  96348. /** Define the camera target (the messh it should follow) */
  96349. target: Nullable<AbstractMesh>, scene: Scene);
  96350. private _follow;
  96351. /** @hidden */
  96352. _checkInputs(): void;
  96353. /**
  96354. * Returns the class name of the object.
  96355. * It is mostly used internally for serialization purposes.
  96356. */
  96357. getClassName(): string;
  96358. }
  96359. }
  96360. declare module BABYLON {
  96361. /**
  96362. * Manage the keyboard inputs to control the movement of a follow camera.
  96363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96364. */
  96365. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96366. /**
  96367. * Defines the camera the input is attached to.
  96368. */
  96369. camera: FollowCamera;
  96370. /**
  96371. * Defines the list of key codes associated with the up action (increase heightOffset)
  96372. */
  96373. keysHeightOffsetIncr: number[];
  96374. /**
  96375. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96376. */
  96377. keysHeightOffsetDecr: number[];
  96378. /**
  96379. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96380. */
  96381. keysHeightOffsetModifierAlt: boolean;
  96382. /**
  96383. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96384. */
  96385. keysHeightOffsetModifierCtrl: boolean;
  96386. /**
  96387. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96388. */
  96389. keysHeightOffsetModifierShift: boolean;
  96390. /**
  96391. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96392. */
  96393. keysRotationOffsetIncr: number[];
  96394. /**
  96395. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96396. */
  96397. keysRotationOffsetDecr: number[];
  96398. /**
  96399. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96400. */
  96401. keysRotationOffsetModifierAlt: boolean;
  96402. /**
  96403. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96404. */
  96405. keysRotationOffsetModifierCtrl: boolean;
  96406. /**
  96407. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96408. */
  96409. keysRotationOffsetModifierShift: boolean;
  96410. /**
  96411. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96412. */
  96413. keysRadiusIncr: number[];
  96414. /**
  96415. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96416. */
  96417. keysRadiusDecr: number[];
  96418. /**
  96419. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96420. */
  96421. keysRadiusModifierAlt: boolean;
  96422. /**
  96423. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96424. */
  96425. keysRadiusModifierCtrl: boolean;
  96426. /**
  96427. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96428. */
  96429. keysRadiusModifierShift: boolean;
  96430. /**
  96431. * Defines the rate of change of heightOffset.
  96432. */
  96433. heightSensibility: number;
  96434. /**
  96435. * Defines the rate of change of rotationOffset.
  96436. */
  96437. rotationSensibility: number;
  96438. /**
  96439. * Defines the rate of change of radius.
  96440. */
  96441. radiusSensibility: number;
  96442. private _keys;
  96443. private _ctrlPressed;
  96444. private _altPressed;
  96445. private _shiftPressed;
  96446. private _onCanvasBlurObserver;
  96447. private _onKeyboardObserver;
  96448. private _engine;
  96449. private _scene;
  96450. /**
  96451. * Attach the input controls to a specific dom element to get the input from.
  96452. * @param element Defines the element the controls should be listened from
  96453. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96454. */
  96455. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96456. /**
  96457. * Detach the current controls from the specified dom element.
  96458. * @param element Defines the element to stop listening the inputs from
  96459. */
  96460. detachControl(element: Nullable<HTMLElement>): void;
  96461. /**
  96462. * Update the current camera state depending on the inputs that have been used this frame.
  96463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96464. */
  96465. checkInputs(): void;
  96466. /**
  96467. * Gets the class name of the current input.
  96468. * @returns the class name
  96469. */
  96470. getClassName(): string;
  96471. /**
  96472. * Get the friendly name associated with the input class.
  96473. * @returns the input friendly name
  96474. */
  96475. getSimpleName(): string;
  96476. /**
  96477. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96478. * allow modification of the heightOffset value.
  96479. */
  96480. private _modifierHeightOffset;
  96481. /**
  96482. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96483. * allow modification of the rotationOffset value.
  96484. */
  96485. private _modifierRotationOffset;
  96486. /**
  96487. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96488. * allow modification of the radius value.
  96489. */
  96490. private _modifierRadius;
  96491. }
  96492. }
  96493. declare module BABYLON {
  96494. interface FreeCameraInputsManager {
  96495. /**
  96496. * @hidden
  96497. */
  96498. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  96499. /**
  96500. * Add orientation input support to the input manager.
  96501. * @returns the current input manager
  96502. */
  96503. addDeviceOrientation(): FreeCameraInputsManager;
  96504. }
  96505. /**
  96506. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  96507. * Screen rotation is taken into account.
  96508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96509. */
  96510. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  96511. private _camera;
  96512. private _screenOrientationAngle;
  96513. private _constantTranform;
  96514. private _screenQuaternion;
  96515. private _alpha;
  96516. private _beta;
  96517. private _gamma;
  96518. /**
  96519. * @hidden
  96520. */
  96521. _onDeviceOrientationChangedObservable: Observable<void>;
  96522. /**
  96523. * Instantiates a new input
  96524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96525. */
  96526. constructor();
  96527. /**
  96528. * Define the camera controlled by the input.
  96529. */
  96530. camera: FreeCamera;
  96531. /**
  96532. * Attach the input controls to a specific dom element to get the input from.
  96533. * @param element Defines the element the controls should be listened from
  96534. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96535. */
  96536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96537. private _orientationChanged;
  96538. private _deviceOrientation;
  96539. /**
  96540. * Detach the current controls from the specified dom element.
  96541. * @param element Defines the element to stop listening the inputs from
  96542. */
  96543. detachControl(element: Nullable<HTMLElement>): void;
  96544. /**
  96545. * Update the current camera state depending on the inputs that have been used this frame.
  96546. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96547. */
  96548. checkInputs(): void;
  96549. /**
  96550. * Gets the class name of the current intput.
  96551. * @returns the class name
  96552. */
  96553. getClassName(): string;
  96554. /**
  96555. * Get the friendly name associated with the input class.
  96556. * @returns the input friendly name
  96557. */
  96558. getSimpleName(): string;
  96559. }
  96560. }
  96561. declare module BABYLON {
  96562. /**
  96563. * Manage the gamepad inputs to control a free camera.
  96564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96565. */
  96566. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  96567. /**
  96568. * Define the camera the input is attached to.
  96569. */
  96570. camera: FreeCamera;
  96571. /**
  96572. * Define the Gamepad controlling the input
  96573. */
  96574. gamepad: Nullable<Gamepad>;
  96575. /**
  96576. * Defines the gamepad rotation sensiblity.
  96577. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96578. */
  96579. gamepadAngularSensibility: number;
  96580. /**
  96581. * Defines the gamepad move sensiblity.
  96582. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96583. */
  96584. gamepadMoveSensibility: number;
  96585. private _onGamepadConnectedObserver;
  96586. private _onGamepadDisconnectedObserver;
  96587. private _cameraTransform;
  96588. private _deltaTransform;
  96589. private _vector3;
  96590. private _vector2;
  96591. /**
  96592. * Attach the input controls to a specific dom element to get the input from.
  96593. * @param element Defines the element the controls should be listened from
  96594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96595. */
  96596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96597. /**
  96598. * Detach the current controls from the specified dom element.
  96599. * @param element Defines the element to stop listening the inputs from
  96600. */
  96601. detachControl(element: Nullable<HTMLElement>): void;
  96602. /**
  96603. * Update the current camera state depending on the inputs that have been used this frame.
  96604. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96605. */
  96606. checkInputs(): void;
  96607. /**
  96608. * Gets the class name of the current intput.
  96609. * @returns the class name
  96610. */
  96611. getClassName(): string;
  96612. /**
  96613. * Get the friendly name associated with the input class.
  96614. * @returns the input friendly name
  96615. */
  96616. getSimpleName(): string;
  96617. }
  96618. }
  96619. declare module BABYLON {
  96620. /**
  96621. * Defines the potential axis of a Joystick
  96622. */
  96623. export enum JoystickAxis {
  96624. /** X axis */
  96625. X = 0,
  96626. /** Y axis */
  96627. Y = 1,
  96628. /** Z axis */
  96629. Z = 2
  96630. }
  96631. /**
  96632. * Class used to define virtual joystick (used in touch mode)
  96633. */
  96634. export class VirtualJoystick {
  96635. /**
  96636. * Gets or sets a boolean indicating that left and right values must be inverted
  96637. */
  96638. reverseLeftRight: boolean;
  96639. /**
  96640. * Gets or sets a boolean indicating that up and down values must be inverted
  96641. */
  96642. reverseUpDown: boolean;
  96643. /**
  96644. * Gets the offset value for the position (ie. the change of the position value)
  96645. */
  96646. deltaPosition: Vector3;
  96647. /**
  96648. * Gets a boolean indicating if the virtual joystick was pressed
  96649. */
  96650. pressed: boolean;
  96651. /**
  96652. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96653. */
  96654. static Canvas: Nullable<HTMLCanvasElement>;
  96655. private static _globalJoystickIndex;
  96656. private static vjCanvasContext;
  96657. private static vjCanvasWidth;
  96658. private static vjCanvasHeight;
  96659. private static halfWidth;
  96660. private _action;
  96661. private _axisTargetedByLeftAndRight;
  96662. private _axisTargetedByUpAndDown;
  96663. private _joystickSensibility;
  96664. private _inversedSensibility;
  96665. private _joystickPointerID;
  96666. private _joystickColor;
  96667. private _joystickPointerPos;
  96668. private _joystickPreviousPointerPos;
  96669. private _joystickPointerStartPos;
  96670. private _deltaJoystickVector;
  96671. private _leftJoystick;
  96672. private _touches;
  96673. private _onPointerDownHandlerRef;
  96674. private _onPointerMoveHandlerRef;
  96675. private _onPointerUpHandlerRef;
  96676. private _onResize;
  96677. /**
  96678. * Creates a new virtual joystick
  96679. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96680. */
  96681. constructor(leftJoystick?: boolean);
  96682. /**
  96683. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96684. * @param newJoystickSensibility defines the new sensibility
  96685. */
  96686. setJoystickSensibility(newJoystickSensibility: number): void;
  96687. private _onPointerDown;
  96688. private _onPointerMove;
  96689. private _onPointerUp;
  96690. /**
  96691. * Change the color of the virtual joystick
  96692. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96693. */
  96694. setJoystickColor(newColor: string): void;
  96695. /**
  96696. * Defines a callback to call when the joystick is touched
  96697. * @param action defines the callback
  96698. */
  96699. setActionOnTouch(action: () => any): void;
  96700. /**
  96701. * Defines which axis you'd like to control for left & right
  96702. * @param axis defines the axis to use
  96703. */
  96704. setAxisForLeftRight(axis: JoystickAxis): void;
  96705. /**
  96706. * Defines which axis you'd like to control for up & down
  96707. * @param axis defines the axis to use
  96708. */
  96709. setAxisForUpDown(axis: JoystickAxis): void;
  96710. private _drawVirtualJoystick;
  96711. /**
  96712. * Release internal HTML canvas
  96713. */
  96714. releaseCanvas(): void;
  96715. }
  96716. }
  96717. declare module BABYLON {
  96718. interface FreeCameraInputsManager {
  96719. /**
  96720. * Add virtual joystick input support to the input manager.
  96721. * @returns the current input manager
  96722. */
  96723. addVirtualJoystick(): FreeCameraInputsManager;
  96724. }
  96725. /**
  96726. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96728. */
  96729. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96730. /**
  96731. * Defines the camera the input is attached to.
  96732. */
  96733. camera: FreeCamera;
  96734. private _leftjoystick;
  96735. private _rightjoystick;
  96736. /**
  96737. * Gets the left stick of the virtual joystick.
  96738. * @returns The virtual Joystick
  96739. */
  96740. getLeftJoystick(): VirtualJoystick;
  96741. /**
  96742. * Gets the right stick of the virtual joystick.
  96743. * @returns The virtual Joystick
  96744. */
  96745. getRightJoystick(): VirtualJoystick;
  96746. /**
  96747. * Update the current camera state depending on the inputs that have been used this frame.
  96748. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96749. */
  96750. checkInputs(): void;
  96751. /**
  96752. * Attach the input controls to a specific dom element to get the input from.
  96753. * @param element Defines the element the controls should be listened from
  96754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96755. */
  96756. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96757. /**
  96758. * Detach the current controls from the specified dom element.
  96759. * @param element Defines the element to stop listening the inputs from
  96760. */
  96761. detachControl(element: Nullable<HTMLElement>): void;
  96762. /**
  96763. * Gets the class name of the current intput.
  96764. * @returns the class name
  96765. */
  96766. getClassName(): string;
  96767. /**
  96768. * Get the friendly name associated with the input class.
  96769. * @returns the input friendly name
  96770. */
  96771. getSimpleName(): string;
  96772. }
  96773. }
  96774. declare module BABYLON {
  96775. /**
  96776. * This represents a FPS type of camera controlled by touch.
  96777. * This is like a universal camera minus the Gamepad controls.
  96778. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96779. */
  96780. export class TouchCamera extends FreeCamera {
  96781. /**
  96782. * Defines the touch sensibility for rotation.
  96783. * The higher the faster.
  96784. */
  96785. touchAngularSensibility: number;
  96786. /**
  96787. * Defines the touch sensibility for move.
  96788. * The higher the faster.
  96789. */
  96790. touchMoveSensibility: number;
  96791. /**
  96792. * Instantiates a new touch camera.
  96793. * This represents a FPS type of camera controlled by touch.
  96794. * This is like a universal camera minus the Gamepad controls.
  96795. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96796. * @param name Define the name of the camera in the scene
  96797. * @param position Define the start position of the camera in the scene
  96798. * @param scene Define the scene the camera belongs to
  96799. */
  96800. constructor(name: string, position: Vector3, scene: Scene);
  96801. /**
  96802. * Gets the current object class name.
  96803. * @return the class name
  96804. */
  96805. getClassName(): string;
  96806. /** @hidden */
  96807. _setupInputs(): void;
  96808. }
  96809. }
  96810. declare module BABYLON {
  96811. /**
  96812. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96813. * being tilted forward or back and left or right.
  96814. */
  96815. export class DeviceOrientationCamera extends FreeCamera {
  96816. private _initialQuaternion;
  96817. private _quaternionCache;
  96818. private _tmpDragQuaternion;
  96819. /**
  96820. * Creates a new device orientation camera
  96821. * @param name The name of the camera
  96822. * @param position The start position camera
  96823. * @param scene The scene the camera belongs to
  96824. */
  96825. constructor(name: string, position: Vector3, scene: Scene);
  96826. /**
  96827. * @hidden
  96828. * Disabled pointer input on first orientation sensor update (Default: true)
  96829. */
  96830. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  96831. private _dragFactor;
  96832. /**
  96833. * Enabled turning on the y axis when the orientation sensor is active
  96834. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96835. */
  96836. enableHorizontalDragging(dragFactor?: number): void;
  96837. /**
  96838. * Gets the current instance class name ("DeviceOrientationCamera").
  96839. * This helps avoiding instanceof at run time.
  96840. * @returns the class name
  96841. */
  96842. getClassName(): string;
  96843. /**
  96844. * @hidden
  96845. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96846. */
  96847. _checkInputs(): void;
  96848. /**
  96849. * Reset the camera to its default orientation on the specified axis only.
  96850. * @param axis The axis to reset
  96851. */
  96852. resetToCurrentRotation(axis?: Axis): void;
  96853. }
  96854. }
  96855. declare module BABYLON {
  96856. /**
  96857. * 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,
  96858. * which still works and will still be found in many Playgrounds.
  96859. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96860. */
  96861. export class UniversalCamera extends TouchCamera {
  96862. /**
  96863. * Defines the gamepad rotation sensiblity.
  96864. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96865. */
  96866. gamepadAngularSensibility: number;
  96867. /**
  96868. * Defines the gamepad move sensiblity.
  96869. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96870. */
  96871. gamepadMoveSensibility: number;
  96872. /**
  96873. * 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,
  96874. * which still works and will still be found in many Playgrounds.
  96875. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96876. * @param name Define the name of the camera in the scene
  96877. * @param position Define the start position of the camera in the scene
  96878. * @param scene Define the scene the camera belongs to
  96879. */
  96880. constructor(name: string, position: Vector3, scene: Scene);
  96881. /**
  96882. * Gets the current object class name.
  96883. * @return the class name
  96884. */
  96885. getClassName(): string;
  96886. }
  96887. }
  96888. declare module BABYLON {
  96889. /**
  96890. * This represents a FPS type of camera. This is only here for back compat purpose.
  96891. * Please use the UniversalCamera instead as both are identical.
  96892. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96893. */
  96894. export class GamepadCamera extends UniversalCamera {
  96895. /**
  96896. * Instantiates a new Gamepad Camera
  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. * @param name Define the name of the camera in the scene
  96901. * @param position Define the start position of the camera in the scene
  96902. * @param scene Define the scene the camera belongs to
  96903. */
  96904. constructor(name: string, position: Vector3, scene: Scene);
  96905. /**
  96906. * Gets the current object class name.
  96907. * @return the class name
  96908. */
  96909. getClassName(): string;
  96910. }
  96911. }
  96912. declare module BABYLON {
  96913. /** @hidden */
  96914. export var passPixelShader: {
  96915. name: string;
  96916. shader: string;
  96917. };
  96918. }
  96919. declare module BABYLON {
  96920. /** @hidden */
  96921. export var passCubePixelShader: {
  96922. name: string;
  96923. shader: string;
  96924. };
  96925. }
  96926. declare module BABYLON {
  96927. /**
  96928. * PassPostProcess which produces an output the same as it's input
  96929. */
  96930. export class PassPostProcess extends PostProcess {
  96931. /**
  96932. * Creates the PassPostProcess
  96933. * @param name The name of the effect.
  96934. * @param options The required width/height ratio to downsize to before computing the render pass.
  96935. * @param camera The camera to apply the render pass to.
  96936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96937. * @param engine The engine which the post process will be applied. (default: current engine)
  96938. * @param reusable If the post process can be reused on the same frame. (default: false)
  96939. * @param textureType The type of texture to be used when performing the post processing.
  96940. * @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)
  96941. */
  96942. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96943. }
  96944. /**
  96945. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  96946. */
  96947. export class PassCubePostProcess extends PostProcess {
  96948. private _face;
  96949. /**
  96950. * Gets or sets the cube face to display.
  96951. * * 0 is +X
  96952. * * 1 is -X
  96953. * * 2 is +Y
  96954. * * 3 is -Y
  96955. * * 4 is +Z
  96956. * * 5 is -Z
  96957. */
  96958. face: number;
  96959. /**
  96960. * Creates the PassCubePostProcess
  96961. * @param name The name of the effect.
  96962. * @param options The required width/height ratio to downsize to before computing the render pass.
  96963. * @param camera The camera to apply the render pass to.
  96964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96965. * @param engine The engine which the post process will be applied. (default: current engine)
  96966. * @param reusable If the post process can be reused on the same frame. (default: false)
  96967. * @param textureType The type of texture to be used when performing the post processing.
  96968. * @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)
  96969. */
  96970. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96971. }
  96972. }
  96973. declare module BABYLON {
  96974. /** @hidden */
  96975. export var anaglyphPixelShader: {
  96976. name: string;
  96977. shader: string;
  96978. };
  96979. }
  96980. declare module BABYLON {
  96981. /**
  96982. * Postprocess used to generate anaglyphic rendering
  96983. */
  96984. export class AnaglyphPostProcess extends PostProcess {
  96985. private _passedProcess;
  96986. /**
  96987. * Creates a new AnaglyphPostProcess
  96988. * @param name defines postprocess name
  96989. * @param options defines creation options or target ratio scale
  96990. * @param rigCameras defines cameras using this postprocess
  96991. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  96992. * @param engine defines hosting engine
  96993. * @param reusable defines if the postprocess will be reused multiple times per frame
  96994. */
  96995. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  96996. }
  96997. }
  96998. declare module BABYLON {
  96999. /**
  97000. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97001. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97002. */
  97003. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97004. /**
  97005. * Creates a new AnaglyphArcRotateCamera
  97006. * @param name defines camera name
  97007. * @param alpha defines alpha angle (in radians)
  97008. * @param beta defines beta angle (in radians)
  97009. * @param radius defines radius
  97010. * @param target defines camera target
  97011. * @param interaxialDistance defines distance between each color axis
  97012. * @param scene defines the hosting scene
  97013. */
  97014. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97015. /**
  97016. * Gets camera class name
  97017. * @returns AnaglyphArcRotateCamera
  97018. */
  97019. getClassName(): string;
  97020. }
  97021. }
  97022. declare module BABYLON {
  97023. /**
  97024. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97025. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97026. */
  97027. export class AnaglyphFreeCamera extends FreeCamera {
  97028. /**
  97029. * Creates a new AnaglyphFreeCamera
  97030. * @param name defines camera name
  97031. * @param position defines initial position
  97032. * @param interaxialDistance defines distance between each color axis
  97033. * @param scene defines the hosting scene
  97034. */
  97035. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97036. /**
  97037. * Gets camera class name
  97038. * @returns AnaglyphFreeCamera
  97039. */
  97040. getClassName(): string;
  97041. }
  97042. }
  97043. declare module BABYLON {
  97044. /**
  97045. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97046. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97047. */
  97048. export class AnaglyphGamepadCamera extends GamepadCamera {
  97049. /**
  97050. * Creates a new AnaglyphGamepadCamera
  97051. * @param name defines camera name
  97052. * @param position defines initial position
  97053. * @param interaxialDistance defines distance between each color axis
  97054. * @param scene defines the hosting scene
  97055. */
  97056. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97057. /**
  97058. * Gets camera class name
  97059. * @returns AnaglyphGamepadCamera
  97060. */
  97061. getClassName(): string;
  97062. }
  97063. }
  97064. declare module BABYLON {
  97065. /**
  97066. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97067. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97068. */
  97069. export class AnaglyphUniversalCamera extends UniversalCamera {
  97070. /**
  97071. * Creates a new AnaglyphUniversalCamera
  97072. * @param name defines camera name
  97073. * @param position defines initial position
  97074. * @param interaxialDistance defines distance between each color axis
  97075. * @param scene defines the hosting scene
  97076. */
  97077. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97078. /**
  97079. * Gets camera class name
  97080. * @returns AnaglyphUniversalCamera
  97081. */
  97082. getClassName(): string;
  97083. }
  97084. }
  97085. declare module BABYLON {
  97086. /** @hidden */
  97087. export var stereoscopicInterlacePixelShader: {
  97088. name: string;
  97089. shader: string;
  97090. };
  97091. }
  97092. declare module BABYLON {
  97093. /**
  97094. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  97095. */
  97096. export class StereoscopicInterlacePostProcess extends PostProcess {
  97097. private _stepSize;
  97098. private _passedProcess;
  97099. /**
  97100. * Initializes a StereoscopicInterlacePostProcess
  97101. * @param name The name of the effect.
  97102. * @param rigCameras The rig cameras to be appled to the post process
  97103. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  97104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97105. * @param engine The engine which the post process will be applied. (default: current engine)
  97106. * @param reusable If the post process can be reused on the same frame. (default: false)
  97107. */
  97108. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  97109. }
  97110. }
  97111. declare module BABYLON {
  97112. /**
  97113. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  97114. * @see http://doc.babylonjs.com/features/cameras
  97115. */
  97116. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  97117. /**
  97118. * Creates a new StereoscopicArcRotateCamera
  97119. * @param name defines camera name
  97120. * @param alpha defines alpha angle (in radians)
  97121. * @param beta defines beta angle (in radians)
  97122. * @param radius defines radius
  97123. * @param target defines camera target
  97124. * @param interaxialDistance defines distance between each color axis
  97125. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97126. * @param scene defines the hosting scene
  97127. */
  97128. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97129. /**
  97130. * Gets camera class name
  97131. * @returns StereoscopicArcRotateCamera
  97132. */
  97133. getClassName(): string;
  97134. }
  97135. }
  97136. declare module BABYLON {
  97137. /**
  97138. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  97139. * @see http://doc.babylonjs.com/features/cameras
  97140. */
  97141. export class StereoscopicFreeCamera extends FreeCamera {
  97142. /**
  97143. * Creates a new StereoscopicFreeCamera
  97144. * @param name defines camera name
  97145. * @param position defines initial position
  97146. * @param interaxialDistance defines distance between each color axis
  97147. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97148. * @param scene defines the hosting scene
  97149. */
  97150. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97151. /**
  97152. * Gets camera class name
  97153. * @returns StereoscopicFreeCamera
  97154. */
  97155. getClassName(): string;
  97156. }
  97157. }
  97158. declare module BABYLON {
  97159. /**
  97160. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  97161. * @see http://doc.babylonjs.com/features/cameras
  97162. */
  97163. export class StereoscopicGamepadCamera extends GamepadCamera {
  97164. /**
  97165. * Creates a new StereoscopicGamepadCamera
  97166. * @param name defines camera name
  97167. * @param position defines initial position
  97168. * @param interaxialDistance defines distance between each color axis
  97169. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97170. * @param scene defines the hosting scene
  97171. */
  97172. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97173. /**
  97174. * Gets camera class name
  97175. * @returns StereoscopicGamepadCamera
  97176. */
  97177. getClassName(): string;
  97178. }
  97179. }
  97180. declare module BABYLON {
  97181. /**
  97182. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  97183. * @see http://doc.babylonjs.com/features/cameras
  97184. */
  97185. export class StereoscopicUniversalCamera extends UniversalCamera {
  97186. /**
  97187. * Creates a new StereoscopicUniversalCamera
  97188. * @param name defines camera name
  97189. * @param position defines initial position
  97190. * @param interaxialDistance defines distance between each color axis
  97191. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97192. * @param scene defines the hosting scene
  97193. */
  97194. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97195. /**
  97196. * Gets camera class name
  97197. * @returns StereoscopicUniversalCamera
  97198. */
  97199. getClassName(): string;
  97200. }
  97201. }
  97202. declare module BABYLON {
  97203. /**
  97204. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97205. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97206. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97207. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97208. */
  97209. export class VirtualJoysticksCamera extends FreeCamera {
  97210. /**
  97211. * Intantiates a VirtualJoysticksCamera. 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. * @param name Define the name of the camera in the scene
  97216. * @param position Define the start position of the camera in the scene
  97217. * @param scene Define the scene the camera belongs to
  97218. */
  97219. constructor(name: string, position: Vector3, scene: Scene);
  97220. /**
  97221. * Gets the current object class name.
  97222. * @return the class name
  97223. */
  97224. getClassName(): string;
  97225. }
  97226. }
  97227. declare module BABYLON {
  97228. /**
  97229. * This represents all the required metrics to create a VR camera.
  97230. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97231. */
  97232. export class VRCameraMetrics {
  97233. /**
  97234. * Define the horizontal resolution off the screen.
  97235. */
  97236. hResolution: number;
  97237. /**
  97238. * Define the vertical resolution off the screen.
  97239. */
  97240. vResolution: number;
  97241. /**
  97242. * Define the horizontal screen size.
  97243. */
  97244. hScreenSize: number;
  97245. /**
  97246. * Define the vertical screen size.
  97247. */
  97248. vScreenSize: number;
  97249. /**
  97250. * Define the vertical screen center position.
  97251. */
  97252. vScreenCenter: number;
  97253. /**
  97254. * Define the distance of the eyes to the screen.
  97255. */
  97256. eyeToScreenDistance: number;
  97257. /**
  97258. * Define the distance between both lenses
  97259. */
  97260. lensSeparationDistance: number;
  97261. /**
  97262. * Define the distance between both viewer's eyes.
  97263. */
  97264. interpupillaryDistance: number;
  97265. /**
  97266. * Define the distortion factor of the VR postprocess.
  97267. * Please, touch with care.
  97268. */
  97269. distortionK: number[];
  97270. /**
  97271. * Define the chromatic aberration correction factors for the VR post process.
  97272. */
  97273. chromaAbCorrection: number[];
  97274. /**
  97275. * Define the scale factor of the post process.
  97276. * The smaller the better but the slower.
  97277. */
  97278. postProcessScaleFactor: number;
  97279. /**
  97280. * Define an offset for the lens center.
  97281. */
  97282. lensCenterOffset: number;
  97283. /**
  97284. * Define if the current vr camera should compensate the distortion of the lense or not.
  97285. */
  97286. compensateDistortion: boolean;
  97287. /**
  97288. * Defines if multiview should be enabled when rendering (Default: false)
  97289. */
  97290. multiviewEnabled: boolean;
  97291. /**
  97292. * Gets the rendering aspect ratio based on the provided resolutions.
  97293. */
  97294. readonly aspectRatio: number;
  97295. /**
  97296. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97297. */
  97298. readonly aspectRatioFov: number;
  97299. /**
  97300. * @hidden
  97301. */
  97302. readonly leftHMatrix: Matrix;
  97303. /**
  97304. * @hidden
  97305. */
  97306. readonly rightHMatrix: Matrix;
  97307. /**
  97308. * @hidden
  97309. */
  97310. readonly leftPreViewMatrix: Matrix;
  97311. /**
  97312. * @hidden
  97313. */
  97314. readonly rightPreViewMatrix: Matrix;
  97315. /**
  97316. * Get the default VRMetrics based on the most generic setup.
  97317. * @returns the default vr metrics
  97318. */
  97319. static GetDefault(): VRCameraMetrics;
  97320. }
  97321. }
  97322. declare module BABYLON {
  97323. /** @hidden */
  97324. export var vrDistortionCorrectionPixelShader: {
  97325. name: string;
  97326. shader: string;
  97327. };
  97328. }
  97329. declare module BABYLON {
  97330. /**
  97331. * VRDistortionCorrectionPostProcess used for mobile VR
  97332. */
  97333. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97334. private _isRightEye;
  97335. private _distortionFactors;
  97336. private _postProcessScaleFactor;
  97337. private _lensCenterOffset;
  97338. private _scaleIn;
  97339. private _scaleFactor;
  97340. private _lensCenter;
  97341. /**
  97342. * Initializes the VRDistortionCorrectionPostProcess
  97343. * @param name The name of the effect.
  97344. * @param camera The camera to apply the render pass to.
  97345. * @param isRightEye If this is for the right eye distortion
  97346. * @param vrMetrics All the required metrics for the VR camera
  97347. */
  97348. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97349. }
  97350. }
  97351. declare module BABYLON {
  97352. /**
  97353. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97354. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97355. */
  97356. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97357. /**
  97358. * Creates a new VRDeviceOrientationArcRotateCamera
  97359. * @param name defines camera name
  97360. * @param alpha defines the camera rotation along the logitudinal axis
  97361. * @param beta defines the camera rotation along the latitudinal axis
  97362. * @param radius defines the camera distance from its target
  97363. * @param target defines the camera target
  97364. * @param scene defines the scene the camera belongs to
  97365. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97366. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97367. */
  97368. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97369. /**
  97370. * Gets camera class name
  97371. * @returns VRDeviceOrientationArcRotateCamera
  97372. */
  97373. getClassName(): string;
  97374. }
  97375. }
  97376. declare module BABYLON {
  97377. /**
  97378. * Camera used to simulate VR rendering (based on FreeCamera)
  97379. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97380. */
  97381. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97382. /**
  97383. * Creates a new VRDeviceOrientationFreeCamera
  97384. * @param name defines camera name
  97385. * @param position defines the start position of the camera
  97386. * @param scene defines the scene the camera belongs to
  97387. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97388. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97389. */
  97390. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97391. /**
  97392. * Gets camera class name
  97393. * @returns VRDeviceOrientationFreeCamera
  97394. */
  97395. getClassName(): string;
  97396. }
  97397. }
  97398. declare module BABYLON {
  97399. /**
  97400. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97401. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97402. */
  97403. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97404. /**
  97405. * Creates a new VRDeviceOrientationGamepadCamera
  97406. * @param name defines camera name
  97407. * @param position defines the start position of the camera
  97408. * @param scene defines the scene the camera belongs to
  97409. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97410. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97411. */
  97412. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97413. /**
  97414. * Gets camera class name
  97415. * @returns VRDeviceOrientationGamepadCamera
  97416. */
  97417. getClassName(): string;
  97418. }
  97419. }
  97420. declare module BABYLON {
  97421. /**
  97422. * Defines supported buttons for XBox360 compatible gamepads
  97423. */
  97424. export enum Xbox360Button {
  97425. /** A */
  97426. A = 0,
  97427. /** B */
  97428. B = 1,
  97429. /** X */
  97430. X = 2,
  97431. /** Y */
  97432. Y = 3,
  97433. /** Start */
  97434. Start = 4,
  97435. /** Back */
  97436. Back = 5,
  97437. /** Left button */
  97438. LB = 6,
  97439. /** Right button */
  97440. RB = 7,
  97441. /** Left stick */
  97442. LeftStick = 8,
  97443. /** Right stick */
  97444. RightStick = 9
  97445. }
  97446. /** Defines values for XBox360 DPad */
  97447. export enum Xbox360Dpad {
  97448. /** Up */
  97449. Up = 0,
  97450. /** Down */
  97451. Down = 1,
  97452. /** Left */
  97453. Left = 2,
  97454. /** Right */
  97455. Right = 3
  97456. }
  97457. /**
  97458. * Defines a XBox360 gamepad
  97459. */
  97460. export class Xbox360Pad extends Gamepad {
  97461. private _leftTrigger;
  97462. private _rightTrigger;
  97463. private _onlefttriggerchanged;
  97464. private _onrighttriggerchanged;
  97465. private _onbuttondown;
  97466. private _onbuttonup;
  97467. private _ondpaddown;
  97468. private _ondpadup;
  97469. /** Observable raised when a button is pressed */
  97470. onButtonDownObservable: Observable<Xbox360Button>;
  97471. /** Observable raised when a button is released */
  97472. onButtonUpObservable: Observable<Xbox360Button>;
  97473. /** Observable raised when a pad is pressed */
  97474. onPadDownObservable: Observable<Xbox360Dpad>;
  97475. /** Observable raised when a pad is released */
  97476. onPadUpObservable: Observable<Xbox360Dpad>;
  97477. private _buttonA;
  97478. private _buttonB;
  97479. private _buttonX;
  97480. private _buttonY;
  97481. private _buttonBack;
  97482. private _buttonStart;
  97483. private _buttonLB;
  97484. private _buttonRB;
  97485. private _buttonLeftStick;
  97486. private _buttonRightStick;
  97487. private _dPadUp;
  97488. private _dPadDown;
  97489. private _dPadLeft;
  97490. private _dPadRight;
  97491. private _isXboxOnePad;
  97492. /**
  97493. * Creates a new XBox360 gamepad object
  97494. * @param id defines the id of this gamepad
  97495. * @param index defines its index
  97496. * @param gamepad defines the internal HTML gamepad object
  97497. * @param xboxOne defines if it is a XBox One gamepad
  97498. */
  97499. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97500. /**
  97501. * Defines the callback to call when left trigger is pressed
  97502. * @param callback defines the callback to use
  97503. */
  97504. onlefttriggerchanged(callback: (value: number) => void): void;
  97505. /**
  97506. * Defines the callback to call when right trigger is pressed
  97507. * @param callback defines the callback to use
  97508. */
  97509. onrighttriggerchanged(callback: (value: number) => void): void;
  97510. /**
  97511. * Gets the left trigger value
  97512. */
  97513. /**
  97514. * Sets the left trigger value
  97515. */
  97516. leftTrigger: number;
  97517. /**
  97518. * Gets the right trigger value
  97519. */
  97520. /**
  97521. * Sets the right trigger value
  97522. */
  97523. rightTrigger: number;
  97524. /**
  97525. * Defines the callback to call when a button is pressed
  97526. * @param callback defines the callback to use
  97527. */
  97528. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97529. /**
  97530. * Defines the callback to call when a button is released
  97531. * @param callback defines the callback to use
  97532. */
  97533. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97534. /**
  97535. * Defines the callback to call when a pad is pressed
  97536. * @param callback defines the callback to use
  97537. */
  97538. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97539. /**
  97540. * Defines the callback to call when a pad is released
  97541. * @param callback defines the callback to use
  97542. */
  97543. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97544. private _setButtonValue;
  97545. private _setDPadValue;
  97546. /**
  97547. * Gets the value of the `A` button
  97548. */
  97549. /**
  97550. * Sets the value of the `A` button
  97551. */
  97552. buttonA: number;
  97553. /**
  97554. * Gets the value of the `B` button
  97555. */
  97556. /**
  97557. * Sets the value of the `B` button
  97558. */
  97559. buttonB: number;
  97560. /**
  97561. * Gets the value of the `X` button
  97562. */
  97563. /**
  97564. * Sets the value of the `X` button
  97565. */
  97566. buttonX: number;
  97567. /**
  97568. * Gets the value of the `Y` button
  97569. */
  97570. /**
  97571. * Sets the value of the `Y` button
  97572. */
  97573. buttonY: number;
  97574. /**
  97575. * Gets the value of the `Start` button
  97576. */
  97577. /**
  97578. * Sets the value of the `Start` button
  97579. */
  97580. buttonStart: number;
  97581. /**
  97582. * Gets the value of the `Back` button
  97583. */
  97584. /**
  97585. * Sets the value of the `Back` button
  97586. */
  97587. buttonBack: number;
  97588. /**
  97589. * Gets the value of the `Left` button
  97590. */
  97591. /**
  97592. * Sets the value of the `Left` button
  97593. */
  97594. buttonLB: number;
  97595. /**
  97596. * Gets the value of the `Right` button
  97597. */
  97598. /**
  97599. * Sets the value of the `Right` button
  97600. */
  97601. buttonRB: number;
  97602. /**
  97603. * Gets the value of the Left joystick
  97604. */
  97605. /**
  97606. * Sets the value of the Left joystick
  97607. */
  97608. buttonLeftStick: number;
  97609. /**
  97610. * Gets the value of the Right joystick
  97611. */
  97612. /**
  97613. * Sets the value of the Right joystick
  97614. */
  97615. buttonRightStick: number;
  97616. /**
  97617. * Gets the value of D-pad up
  97618. */
  97619. /**
  97620. * Sets the value of D-pad up
  97621. */
  97622. dPadUp: number;
  97623. /**
  97624. * Gets the value of D-pad down
  97625. */
  97626. /**
  97627. * Sets the value of D-pad down
  97628. */
  97629. dPadDown: number;
  97630. /**
  97631. * Gets the value of D-pad left
  97632. */
  97633. /**
  97634. * Sets the value of D-pad left
  97635. */
  97636. dPadLeft: number;
  97637. /**
  97638. * Gets the value of D-pad right
  97639. */
  97640. /**
  97641. * Sets the value of D-pad right
  97642. */
  97643. dPadRight: number;
  97644. /**
  97645. * Force the gamepad to synchronize with device values
  97646. */
  97647. update(): void;
  97648. /**
  97649. * Disposes the gamepad
  97650. */
  97651. dispose(): void;
  97652. }
  97653. }
  97654. declare module BABYLON {
  97655. /**
  97656. * Base class of materials working in push mode in babylon JS
  97657. * @hidden
  97658. */
  97659. export class PushMaterial extends Material {
  97660. protected _activeEffect: Effect;
  97661. protected _normalMatrix: Matrix;
  97662. /**
  97663. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97664. * This means that the material can keep using a previous shader while a new one is being compiled.
  97665. * This is mostly used when shader parallel compilation is supported (true by default)
  97666. */
  97667. allowShaderHotSwapping: boolean;
  97668. constructor(name: string, scene: Scene);
  97669. getEffect(): Effect;
  97670. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97671. /**
  97672. * Binds the given world matrix to the active effect
  97673. *
  97674. * @param world the matrix to bind
  97675. */
  97676. bindOnlyWorldMatrix(world: Matrix): void;
  97677. /**
  97678. * Binds the given normal matrix to the active effect
  97679. *
  97680. * @param normalMatrix the matrix to bind
  97681. */
  97682. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97683. bind(world: Matrix, mesh?: Mesh): void;
  97684. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97685. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97686. }
  97687. }
  97688. declare module BABYLON {
  97689. /**
  97690. * This groups all the flags used to control the materials channel.
  97691. */
  97692. export class MaterialFlags {
  97693. private static _DiffuseTextureEnabled;
  97694. /**
  97695. * Are diffuse textures enabled in the application.
  97696. */
  97697. static DiffuseTextureEnabled: boolean;
  97698. private static _AmbientTextureEnabled;
  97699. /**
  97700. * Are ambient textures enabled in the application.
  97701. */
  97702. static AmbientTextureEnabled: boolean;
  97703. private static _OpacityTextureEnabled;
  97704. /**
  97705. * Are opacity textures enabled in the application.
  97706. */
  97707. static OpacityTextureEnabled: boolean;
  97708. private static _ReflectionTextureEnabled;
  97709. /**
  97710. * Are reflection textures enabled in the application.
  97711. */
  97712. static ReflectionTextureEnabled: boolean;
  97713. private static _EmissiveTextureEnabled;
  97714. /**
  97715. * Are emissive textures enabled in the application.
  97716. */
  97717. static EmissiveTextureEnabled: boolean;
  97718. private static _SpecularTextureEnabled;
  97719. /**
  97720. * Are specular textures enabled in the application.
  97721. */
  97722. static SpecularTextureEnabled: boolean;
  97723. private static _BumpTextureEnabled;
  97724. /**
  97725. * Are bump textures enabled in the application.
  97726. */
  97727. static BumpTextureEnabled: boolean;
  97728. private static _LightmapTextureEnabled;
  97729. /**
  97730. * Are lightmap textures enabled in the application.
  97731. */
  97732. static LightmapTextureEnabled: boolean;
  97733. private static _RefractionTextureEnabled;
  97734. /**
  97735. * Are refraction textures enabled in the application.
  97736. */
  97737. static RefractionTextureEnabled: boolean;
  97738. private static _ColorGradingTextureEnabled;
  97739. /**
  97740. * Are color grading textures enabled in the application.
  97741. */
  97742. static ColorGradingTextureEnabled: boolean;
  97743. private static _FresnelEnabled;
  97744. /**
  97745. * Are fresnels enabled in the application.
  97746. */
  97747. static FresnelEnabled: boolean;
  97748. private static _ClearCoatTextureEnabled;
  97749. /**
  97750. * Are clear coat textures enabled in the application.
  97751. */
  97752. static ClearCoatTextureEnabled: boolean;
  97753. private static _ClearCoatBumpTextureEnabled;
  97754. /**
  97755. * Are clear coat bump textures enabled in the application.
  97756. */
  97757. static ClearCoatBumpTextureEnabled: boolean;
  97758. private static _ClearCoatTintTextureEnabled;
  97759. /**
  97760. * Are clear coat tint textures enabled in the application.
  97761. */
  97762. static ClearCoatTintTextureEnabled: boolean;
  97763. private static _SheenTextureEnabled;
  97764. /**
  97765. * Are sheen textures enabled in the application.
  97766. */
  97767. static SheenTextureEnabled: boolean;
  97768. private static _AnisotropicTextureEnabled;
  97769. /**
  97770. * Are anisotropic textures enabled in the application.
  97771. */
  97772. static AnisotropicTextureEnabled: boolean;
  97773. private static _ThicknessTextureEnabled;
  97774. /**
  97775. * Are thickness textures enabled in the application.
  97776. */
  97777. static ThicknessTextureEnabled: boolean;
  97778. }
  97779. }
  97780. declare module BABYLON {
  97781. /** @hidden */
  97782. export var defaultFragmentDeclaration: {
  97783. name: string;
  97784. shader: string;
  97785. };
  97786. }
  97787. declare module BABYLON {
  97788. /** @hidden */
  97789. export var defaultUboDeclaration: {
  97790. name: string;
  97791. shader: string;
  97792. };
  97793. }
  97794. declare module BABYLON {
  97795. /** @hidden */
  97796. export var lightFragmentDeclaration: {
  97797. name: string;
  97798. shader: string;
  97799. };
  97800. }
  97801. declare module BABYLON {
  97802. /** @hidden */
  97803. export var lightUboDeclaration: {
  97804. name: string;
  97805. shader: string;
  97806. };
  97807. }
  97808. declare module BABYLON {
  97809. /** @hidden */
  97810. export var lightsFragmentFunctions: {
  97811. name: string;
  97812. shader: string;
  97813. };
  97814. }
  97815. declare module BABYLON {
  97816. /** @hidden */
  97817. export var shadowsFragmentFunctions: {
  97818. name: string;
  97819. shader: string;
  97820. };
  97821. }
  97822. declare module BABYLON {
  97823. /** @hidden */
  97824. export var fresnelFunction: {
  97825. name: string;
  97826. shader: string;
  97827. };
  97828. }
  97829. declare module BABYLON {
  97830. /** @hidden */
  97831. export var reflectionFunction: {
  97832. name: string;
  97833. shader: string;
  97834. };
  97835. }
  97836. declare module BABYLON {
  97837. /** @hidden */
  97838. export var bumpFragmentFunctions: {
  97839. name: string;
  97840. shader: string;
  97841. };
  97842. }
  97843. declare module BABYLON {
  97844. /** @hidden */
  97845. export var logDepthDeclaration: {
  97846. name: string;
  97847. shader: string;
  97848. };
  97849. }
  97850. declare module BABYLON {
  97851. /** @hidden */
  97852. export var bumpFragment: {
  97853. name: string;
  97854. shader: string;
  97855. };
  97856. }
  97857. declare module BABYLON {
  97858. /** @hidden */
  97859. export var depthPrePass: {
  97860. name: string;
  97861. shader: string;
  97862. };
  97863. }
  97864. declare module BABYLON {
  97865. /** @hidden */
  97866. export var lightFragment: {
  97867. name: string;
  97868. shader: string;
  97869. };
  97870. }
  97871. declare module BABYLON {
  97872. /** @hidden */
  97873. export var logDepthFragment: {
  97874. name: string;
  97875. shader: string;
  97876. };
  97877. }
  97878. declare module BABYLON {
  97879. /** @hidden */
  97880. export var defaultPixelShader: {
  97881. name: string;
  97882. shader: string;
  97883. };
  97884. }
  97885. declare module BABYLON {
  97886. /** @hidden */
  97887. export var defaultVertexDeclaration: {
  97888. name: string;
  97889. shader: string;
  97890. };
  97891. }
  97892. declare module BABYLON {
  97893. /** @hidden */
  97894. export var bumpVertexDeclaration: {
  97895. name: string;
  97896. shader: string;
  97897. };
  97898. }
  97899. declare module BABYLON {
  97900. /** @hidden */
  97901. export var bumpVertex: {
  97902. name: string;
  97903. shader: string;
  97904. };
  97905. }
  97906. declare module BABYLON {
  97907. /** @hidden */
  97908. export var fogVertex: {
  97909. name: string;
  97910. shader: string;
  97911. };
  97912. }
  97913. declare module BABYLON {
  97914. /** @hidden */
  97915. export var shadowsVertex: {
  97916. name: string;
  97917. shader: string;
  97918. };
  97919. }
  97920. declare module BABYLON {
  97921. /** @hidden */
  97922. export var pointCloudVertex: {
  97923. name: string;
  97924. shader: string;
  97925. };
  97926. }
  97927. declare module BABYLON {
  97928. /** @hidden */
  97929. export var logDepthVertex: {
  97930. name: string;
  97931. shader: string;
  97932. };
  97933. }
  97934. declare module BABYLON {
  97935. /** @hidden */
  97936. export var defaultVertexShader: {
  97937. name: string;
  97938. shader: string;
  97939. };
  97940. }
  97941. declare module BABYLON {
  97942. /** @hidden */
  97943. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97944. MAINUV1: boolean;
  97945. MAINUV2: boolean;
  97946. DIFFUSE: boolean;
  97947. DIFFUSEDIRECTUV: number;
  97948. AMBIENT: boolean;
  97949. AMBIENTDIRECTUV: number;
  97950. OPACITY: boolean;
  97951. OPACITYDIRECTUV: number;
  97952. OPACITYRGB: boolean;
  97953. REFLECTION: boolean;
  97954. EMISSIVE: boolean;
  97955. EMISSIVEDIRECTUV: number;
  97956. SPECULAR: boolean;
  97957. SPECULARDIRECTUV: number;
  97958. BUMP: boolean;
  97959. BUMPDIRECTUV: number;
  97960. PARALLAX: boolean;
  97961. PARALLAXOCCLUSION: boolean;
  97962. SPECULAROVERALPHA: boolean;
  97963. CLIPPLANE: boolean;
  97964. CLIPPLANE2: boolean;
  97965. CLIPPLANE3: boolean;
  97966. CLIPPLANE4: boolean;
  97967. ALPHATEST: boolean;
  97968. DEPTHPREPASS: boolean;
  97969. ALPHAFROMDIFFUSE: boolean;
  97970. POINTSIZE: boolean;
  97971. FOG: boolean;
  97972. SPECULARTERM: boolean;
  97973. DIFFUSEFRESNEL: boolean;
  97974. OPACITYFRESNEL: boolean;
  97975. REFLECTIONFRESNEL: boolean;
  97976. REFRACTIONFRESNEL: boolean;
  97977. EMISSIVEFRESNEL: boolean;
  97978. FRESNEL: boolean;
  97979. NORMAL: boolean;
  97980. UV1: boolean;
  97981. UV2: boolean;
  97982. VERTEXCOLOR: boolean;
  97983. VERTEXALPHA: boolean;
  97984. NUM_BONE_INFLUENCERS: number;
  97985. BonesPerMesh: number;
  97986. BONETEXTURE: boolean;
  97987. INSTANCES: boolean;
  97988. GLOSSINESS: boolean;
  97989. ROUGHNESS: boolean;
  97990. EMISSIVEASILLUMINATION: boolean;
  97991. LINKEMISSIVEWITHDIFFUSE: boolean;
  97992. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97993. LIGHTMAP: boolean;
  97994. LIGHTMAPDIRECTUV: number;
  97995. OBJECTSPACE_NORMALMAP: boolean;
  97996. USELIGHTMAPASSHADOWMAP: boolean;
  97997. REFLECTIONMAP_3D: boolean;
  97998. REFLECTIONMAP_SPHERICAL: boolean;
  97999. REFLECTIONMAP_PLANAR: boolean;
  98000. REFLECTIONMAP_CUBIC: boolean;
  98001. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98002. REFLECTIONMAP_PROJECTION: boolean;
  98003. REFLECTIONMAP_SKYBOX: boolean;
  98004. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98005. REFLECTIONMAP_EXPLICIT: boolean;
  98006. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98007. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98008. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98009. INVERTCUBICMAP: boolean;
  98010. LOGARITHMICDEPTH: boolean;
  98011. REFRACTION: boolean;
  98012. REFRACTIONMAP_3D: boolean;
  98013. REFLECTIONOVERALPHA: boolean;
  98014. TWOSIDEDLIGHTING: boolean;
  98015. SHADOWFLOAT: boolean;
  98016. MORPHTARGETS: boolean;
  98017. MORPHTARGETS_NORMAL: boolean;
  98018. MORPHTARGETS_TANGENT: boolean;
  98019. NUM_MORPH_INFLUENCERS: number;
  98020. NONUNIFORMSCALING: boolean;
  98021. PREMULTIPLYALPHA: boolean;
  98022. IMAGEPROCESSING: boolean;
  98023. VIGNETTE: boolean;
  98024. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98025. VIGNETTEBLENDMODEOPAQUE: boolean;
  98026. TONEMAPPING: boolean;
  98027. TONEMAPPING_ACES: boolean;
  98028. CONTRAST: boolean;
  98029. COLORCURVES: boolean;
  98030. COLORGRADING: boolean;
  98031. COLORGRADING3D: boolean;
  98032. SAMPLER3DGREENDEPTH: boolean;
  98033. SAMPLER3DBGRMAP: boolean;
  98034. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98035. MULTIVIEW: boolean;
  98036. /**
  98037. * If the reflection texture on this material is in linear color space
  98038. * @hidden
  98039. */
  98040. IS_REFLECTION_LINEAR: boolean;
  98041. /**
  98042. * If the refraction texture on this material is in linear color space
  98043. * @hidden
  98044. */
  98045. IS_REFRACTION_LINEAR: boolean;
  98046. EXPOSURE: boolean;
  98047. constructor();
  98048. setReflectionMode(modeToEnable: string): void;
  98049. }
  98050. /**
  98051. * This is the default material used in Babylon. It is the best trade off between quality
  98052. * and performances.
  98053. * @see http://doc.babylonjs.com/babylon101/materials
  98054. */
  98055. export class StandardMaterial extends PushMaterial {
  98056. private _diffuseTexture;
  98057. /**
  98058. * The basic texture of the material as viewed under a light.
  98059. */
  98060. diffuseTexture: Nullable<BaseTexture>;
  98061. private _ambientTexture;
  98062. /**
  98063. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98064. */
  98065. ambientTexture: Nullable<BaseTexture>;
  98066. private _opacityTexture;
  98067. /**
  98068. * Define the transparency of the material from a texture.
  98069. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98070. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98071. */
  98072. opacityTexture: Nullable<BaseTexture>;
  98073. private _reflectionTexture;
  98074. /**
  98075. * Define the texture used to display the reflection.
  98076. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98077. */
  98078. reflectionTexture: Nullable<BaseTexture>;
  98079. private _emissiveTexture;
  98080. /**
  98081. * Define texture of the material as if self lit.
  98082. * This will be mixed in the final result even in the absence of light.
  98083. */
  98084. emissiveTexture: Nullable<BaseTexture>;
  98085. private _specularTexture;
  98086. /**
  98087. * Define how the color and intensity of the highlight given by the light in the material.
  98088. */
  98089. specularTexture: Nullable<BaseTexture>;
  98090. private _bumpTexture;
  98091. /**
  98092. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98093. * 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.
  98094. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98095. */
  98096. bumpTexture: Nullable<BaseTexture>;
  98097. private _lightmapTexture;
  98098. /**
  98099. * Complex lighting can be computationally expensive to compute at runtime.
  98100. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98101. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98102. */
  98103. lightmapTexture: Nullable<BaseTexture>;
  98104. private _refractionTexture;
  98105. /**
  98106. * Define the texture used to display the refraction.
  98107. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98108. */
  98109. refractionTexture: Nullable<BaseTexture>;
  98110. /**
  98111. * The color of the material lit by the environmental background lighting.
  98112. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98113. */
  98114. ambientColor: Color3;
  98115. /**
  98116. * The basic color of the material as viewed under a light.
  98117. */
  98118. diffuseColor: Color3;
  98119. /**
  98120. * Define how the color and intensity of the highlight given by the light in the material.
  98121. */
  98122. specularColor: Color3;
  98123. /**
  98124. * Define the color of the material as if self lit.
  98125. * This will be mixed in the final result even in the absence of light.
  98126. */
  98127. emissiveColor: Color3;
  98128. /**
  98129. * Defines how sharp are the highlights in the material.
  98130. * The bigger the value the sharper giving a more glossy feeling to the result.
  98131. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98132. */
  98133. specularPower: number;
  98134. private _useAlphaFromDiffuseTexture;
  98135. /**
  98136. * Does the transparency come from the diffuse texture alpha channel.
  98137. */
  98138. useAlphaFromDiffuseTexture: boolean;
  98139. private _useEmissiveAsIllumination;
  98140. /**
  98141. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98142. */
  98143. useEmissiveAsIllumination: boolean;
  98144. private _linkEmissiveWithDiffuse;
  98145. /**
  98146. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98147. * the emissive level when the final color is close to one.
  98148. */
  98149. linkEmissiveWithDiffuse: boolean;
  98150. private _useSpecularOverAlpha;
  98151. /**
  98152. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98153. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98154. */
  98155. useSpecularOverAlpha: boolean;
  98156. private _useReflectionOverAlpha;
  98157. /**
  98158. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98159. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98160. */
  98161. useReflectionOverAlpha: boolean;
  98162. private _disableLighting;
  98163. /**
  98164. * Does lights from the scene impacts this material.
  98165. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98166. */
  98167. disableLighting: boolean;
  98168. private _useObjectSpaceNormalMap;
  98169. /**
  98170. * Allows using an object space normal map (instead of tangent space).
  98171. */
  98172. useObjectSpaceNormalMap: boolean;
  98173. private _useParallax;
  98174. /**
  98175. * Is parallax enabled or not.
  98176. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98177. */
  98178. useParallax: boolean;
  98179. private _useParallaxOcclusion;
  98180. /**
  98181. * Is parallax occlusion enabled or not.
  98182. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98183. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98184. */
  98185. useParallaxOcclusion: boolean;
  98186. /**
  98187. * 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.
  98188. */
  98189. parallaxScaleBias: number;
  98190. private _roughness;
  98191. /**
  98192. * Helps to define how blurry the reflections should appears in the material.
  98193. */
  98194. roughness: number;
  98195. /**
  98196. * In case of refraction, define the value of the indice of refraction.
  98197. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98198. */
  98199. indexOfRefraction: number;
  98200. /**
  98201. * Invert the refraction texture alongside the y axis.
  98202. * It can be useful with procedural textures or probe for instance.
  98203. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98204. */
  98205. invertRefractionY: boolean;
  98206. /**
  98207. * Defines the alpha limits in alpha test mode.
  98208. */
  98209. alphaCutOff: number;
  98210. private _useLightmapAsShadowmap;
  98211. /**
  98212. * In case of light mapping, define whether the map contains light or shadow informations.
  98213. */
  98214. useLightmapAsShadowmap: boolean;
  98215. private _diffuseFresnelParameters;
  98216. /**
  98217. * Define the diffuse fresnel parameters of the material.
  98218. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98219. */
  98220. diffuseFresnelParameters: FresnelParameters;
  98221. private _opacityFresnelParameters;
  98222. /**
  98223. * Define the opacity fresnel parameters of the material.
  98224. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98225. */
  98226. opacityFresnelParameters: FresnelParameters;
  98227. private _reflectionFresnelParameters;
  98228. /**
  98229. * Define the reflection fresnel parameters of the material.
  98230. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98231. */
  98232. reflectionFresnelParameters: FresnelParameters;
  98233. private _refractionFresnelParameters;
  98234. /**
  98235. * Define the refraction fresnel parameters of the material.
  98236. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98237. */
  98238. refractionFresnelParameters: FresnelParameters;
  98239. private _emissiveFresnelParameters;
  98240. /**
  98241. * Define the emissive fresnel parameters of the material.
  98242. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98243. */
  98244. emissiveFresnelParameters: FresnelParameters;
  98245. private _useReflectionFresnelFromSpecular;
  98246. /**
  98247. * If true automatically deducts the fresnels values from the material specularity.
  98248. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98249. */
  98250. useReflectionFresnelFromSpecular: boolean;
  98251. private _useGlossinessFromSpecularMapAlpha;
  98252. /**
  98253. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98254. */
  98255. useGlossinessFromSpecularMapAlpha: boolean;
  98256. private _maxSimultaneousLights;
  98257. /**
  98258. * Defines the maximum number of lights that can be used in the material
  98259. */
  98260. maxSimultaneousLights: number;
  98261. private _invertNormalMapX;
  98262. /**
  98263. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98264. */
  98265. invertNormalMapX: boolean;
  98266. private _invertNormalMapY;
  98267. /**
  98268. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98269. */
  98270. invertNormalMapY: boolean;
  98271. private _twoSidedLighting;
  98272. /**
  98273. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98274. */
  98275. twoSidedLighting: boolean;
  98276. /**
  98277. * Default configuration related to image processing available in the standard Material.
  98278. */
  98279. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98280. /**
  98281. * Gets the image processing configuration used either in this material.
  98282. */
  98283. /**
  98284. * Sets the Default image processing configuration used either in the this material.
  98285. *
  98286. * If sets to null, the scene one is in use.
  98287. */
  98288. imageProcessingConfiguration: ImageProcessingConfiguration;
  98289. /**
  98290. * Keep track of the image processing observer to allow dispose and replace.
  98291. */
  98292. private _imageProcessingObserver;
  98293. /**
  98294. * Attaches a new image processing configuration to the Standard Material.
  98295. * @param configuration
  98296. */
  98297. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98298. /**
  98299. * Gets wether the color curves effect is enabled.
  98300. */
  98301. /**
  98302. * Sets wether the color curves effect is enabled.
  98303. */
  98304. cameraColorCurvesEnabled: boolean;
  98305. /**
  98306. * Gets wether the color grading effect is enabled.
  98307. */
  98308. /**
  98309. * Gets wether the color grading effect is enabled.
  98310. */
  98311. cameraColorGradingEnabled: boolean;
  98312. /**
  98313. * Gets wether tonemapping is enabled or not.
  98314. */
  98315. /**
  98316. * Sets wether tonemapping is enabled or not
  98317. */
  98318. cameraToneMappingEnabled: boolean;
  98319. /**
  98320. * The camera exposure used on this material.
  98321. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98322. * This corresponds to a photographic exposure.
  98323. */
  98324. /**
  98325. * The camera exposure used on this material.
  98326. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98327. * This corresponds to a photographic exposure.
  98328. */
  98329. cameraExposure: number;
  98330. /**
  98331. * Gets The camera contrast used on this material.
  98332. */
  98333. /**
  98334. * Sets The camera contrast used on this material.
  98335. */
  98336. cameraContrast: number;
  98337. /**
  98338. * Gets the Color Grading 2D Lookup Texture.
  98339. */
  98340. /**
  98341. * Sets the Color Grading 2D Lookup Texture.
  98342. */
  98343. cameraColorGradingTexture: Nullable<BaseTexture>;
  98344. /**
  98345. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98346. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98347. * 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;
  98348. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98349. */
  98350. /**
  98351. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98352. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98353. * 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;
  98354. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98355. */
  98356. cameraColorCurves: Nullable<ColorCurves>;
  98357. /**
  98358. * Custom callback helping to override the default shader used in the material.
  98359. */
  98360. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98361. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98362. protected _worldViewProjectionMatrix: Matrix;
  98363. protected _globalAmbientColor: Color3;
  98364. protected _useLogarithmicDepth: boolean;
  98365. /**
  98366. * Instantiates a new standard material.
  98367. * This is the default material used in Babylon. It is the best trade off between quality
  98368. * and performances.
  98369. * @see http://doc.babylonjs.com/babylon101/materials
  98370. * @param name Define the name of the material in the scene
  98371. * @param scene Define the scene the material belong to
  98372. */
  98373. constructor(name: string, scene: Scene);
  98374. /**
  98375. * Gets a boolean indicating that current material needs to register RTT
  98376. */
  98377. readonly hasRenderTargetTextures: boolean;
  98378. /**
  98379. * Gets the current class name of the material e.g. "StandardMaterial"
  98380. * Mainly use in serialization.
  98381. * @returns the class name
  98382. */
  98383. getClassName(): string;
  98384. /**
  98385. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98386. * You can try switching to logarithmic depth.
  98387. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98388. */
  98389. useLogarithmicDepth: boolean;
  98390. /**
  98391. * Specifies if the material will require alpha blending
  98392. * @returns a boolean specifying if alpha blending is needed
  98393. */
  98394. needAlphaBlending(): boolean;
  98395. /**
  98396. * Specifies if this material should be rendered in alpha test mode
  98397. * @returns a boolean specifying if an alpha test is needed.
  98398. */
  98399. needAlphaTesting(): boolean;
  98400. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98401. /**
  98402. * Get the texture used for alpha test purpose.
  98403. * @returns the diffuse texture in case of the standard material.
  98404. */
  98405. getAlphaTestTexture(): Nullable<BaseTexture>;
  98406. /**
  98407. * Get if the submesh is ready to be used and all its information available.
  98408. * Child classes can use it to update shaders
  98409. * @param mesh defines the mesh to check
  98410. * @param subMesh defines which submesh to check
  98411. * @param useInstances specifies that instances should be used
  98412. * @returns a boolean indicating that the submesh is ready or not
  98413. */
  98414. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98415. /**
  98416. * Builds the material UBO layouts.
  98417. * Used internally during the effect preparation.
  98418. */
  98419. buildUniformLayout(): void;
  98420. /**
  98421. * Unbinds the material from the mesh
  98422. */
  98423. unbind(): void;
  98424. /**
  98425. * Binds the submesh to this material by preparing the effect and shader to draw
  98426. * @param world defines the world transformation matrix
  98427. * @param mesh defines the mesh containing the submesh
  98428. * @param subMesh defines the submesh to bind the material to
  98429. */
  98430. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98431. /**
  98432. * Get the list of animatables in the material.
  98433. * @returns the list of animatables object used in the material
  98434. */
  98435. getAnimatables(): IAnimatable[];
  98436. /**
  98437. * Gets the active textures from the material
  98438. * @returns an array of textures
  98439. */
  98440. getActiveTextures(): BaseTexture[];
  98441. /**
  98442. * Specifies if the material uses a texture
  98443. * @param texture defines the texture to check against the material
  98444. * @returns a boolean specifying if the material uses the texture
  98445. */
  98446. hasTexture(texture: BaseTexture): boolean;
  98447. /**
  98448. * Disposes the material
  98449. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98450. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98451. */
  98452. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98453. /**
  98454. * Makes a duplicate of the material, and gives it a new name
  98455. * @param name defines the new name for the duplicated material
  98456. * @returns the cloned material
  98457. */
  98458. clone(name: string): StandardMaterial;
  98459. /**
  98460. * Serializes this material in a JSON representation
  98461. * @returns the serialized material object
  98462. */
  98463. serialize(): any;
  98464. /**
  98465. * Creates a standard material from parsed material data
  98466. * @param source defines the JSON representation of the material
  98467. * @param scene defines the hosting scene
  98468. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98469. * @returns a new standard material
  98470. */
  98471. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98472. /**
  98473. * Are diffuse textures enabled in the application.
  98474. */
  98475. static DiffuseTextureEnabled: boolean;
  98476. /**
  98477. * Are ambient textures enabled in the application.
  98478. */
  98479. static AmbientTextureEnabled: boolean;
  98480. /**
  98481. * Are opacity textures enabled in the application.
  98482. */
  98483. static OpacityTextureEnabled: boolean;
  98484. /**
  98485. * Are reflection textures enabled in the application.
  98486. */
  98487. static ReflectionTextureEnabled: boolean;
  98488. /**
  98489. * Are emissive textures enabled in the application.
  98490. */
  98491. static EmissiveTextureEnabled: boolean;
  98492. /**
  98493. * Are specular textures enabled in the application.
  98494. */
  98495. static SpecularTextureEnabled: boolean;
  98496. /**
  98497. * Are bump textures enabled in the application.
  98498. */
  98499. static BumpTextureEnabled: boolean;
  98500. /**
  98501. * Are lightmap textures enabled in the application.
  98502. */
  98503. static LightmapTextureEnabled: boolean;
  98504. /**
  98505. * Are refraction textures enabled in the application.
  98506. */
  98507. static RefractionTextureEnabled: boolean;
  98508. /**
  98509. * Are color grading textures enabled in the application.
  98510. */
  98511. static ColorGradingTextureEnabled: boolean;
  98512. /**
  98513. * Are fresnels enabled in the application.
  98514. */
  98515. static FresnelEnabled: boolean;
  98516. }
  98517. }
  98518. declare module BABYLON {
  98519. /**
  98520. * A class extending Texture allowing drawing on a texture
  98521. * @see http://doc.babylonjs.com/how_to/dynamictexture
  98522. */
  98523. export class DynamicTexture extends Texture {
  98524. private _generateMipMaps;
  98525. private _canvas;
  98526. private _context;
  98527. private _engine;
  98528. /**
  98529. * Creates a DynamicTexture
  98530. * @param name defines the name of the texture
  98531. * @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
  98532. * @param scene defines the scene where you want the texture
  98533. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  98534. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98535. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  98536. */
  98537. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  98538. /**
  98539. * Get the current class name of the texture useful for serialization or dynamic coding.
  98540. * @returns "DynamicTexture"
  98541. */
  98542. getClassName(): string;
  98543. /**
  98544. * Gets the current state of canRescale
  98545. */
  98546. readonly canRescale: boolean;
  98547. private _recreate;
  98548. /**
  98549. * Scales the texture
  98550. * @param ratio the scale factor to apply to both width and height
  98551. */
  98552. scale(ratio: number): void;
  98553. /**
  98554. * Resizes the texture
  98555. * @param width the new width
  98556. * @param height the new height
  98557. */
  98558. scaleTo(width: number, height: number): void;
  98559. /**
  98560. * Gets the context of the canvas used by the texture
  98561. * @returns the canvas context of the dynamic texture
  98562. */
  98563. getContext(): CanvasRenderingContext2D;
  98564. /**
  98565. * Clears the texture
  98566. */
  98567. clear(): void;
  98568. /**
  98569. * Updates the texture
  98570. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98571. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  98572. */
  98573. update(invertY?: boolean, premulAlpha?: boolean): void;
  98574. /**
  98575. * Draws text onto the texture
  98576. * @param text defines the text to be drawn
  98577. * @param x defines the placement of the text from the left
  98578. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98579. * @param font defines the font to be used with font-style, font-size, font-name
  98580. * @param color defines the color used for the text
  98581. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98582. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98583. * @param update defines whether texture is immediately update (default is true)
  98584. */
  98585. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98586. /**
  98587. * Clones the texture
  98588. * @returns the clone of the texture.
  98589. */
  98590. clone(): DynamicTexture;
  98591. /**
  98592. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98593. * @returns a serialized dynamic texture object
  98594. */
  98595. serialize(): any;
  98596. /** @hidden */
  98597. _rebuild(): void;
  98598. }
  98599. }
  98600. declare module BABYLON {
  98601. /** @hidden */
  98602. export var imageProcessingPixelShader: {
  98603. name: string;
  98604. shader: string;
  98605. };
  98606. }
  98607. declare module BABYLON {
  98608. /**
  98609. * ImageProcessingPostProcess
  98610. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98611. */
  98612. export class ImageProcessingPostProcess extends PostProcess {
  98613. /**
  98614. * Default configuration related to image processing available in the PBR Material.
  98615. */
  98616. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98617. /**
  98618. * Gets the image processing configuration used either in this material.
  98619. */
  98620. /**
  98621. * Sets the Default image processing configuration used either in the this material.
  98622. *
  98623. * If sets to null, the scene one is in use.
  98624. */
  98625. imageProcessingConfiguration: ImageProcessingConfiguration;
  98626. /**
  98627. * Keep track of the image processing observer to allow dispose and replace.
  98628. */
  98629. private _imageProcessingObserver;
  98630. /**
  98631. * Attaches a new image processing configuration to the PBR Material.
  98632. * @param configuration
  98633. */
  98634. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98635. /**
  98636. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98637. */
  98638. /**
  98639. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98640. */
  98641. colorCurves: Nullable<ColorCurves>;
  98642. /**
  98643. * Gets wether the color curves effect is enabled.
  98644. */
  98645. /**
  98646. * Sets wether the color curves effect is enabled.
  98647. */
  98648. colorCurvesEnabled: boolean;
  98649. /**
  98650. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98651. */
  98652. /**
  98653. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98654. */
  98655. colorGradingTexture: Nullable<BaseTexture>;
  98656. /**
  98657. * Gets wether the color grading effect is enabled.
  98658. */
  98659. /**
  98660. * Gets wether the color grading effect is enabled.
  98661. */
  98662. colorGradingEnabled: boolean;
  98663. /**
  98664. * Gets exposure used in the effect.
  98665. */
  98666. /**
  98667. * Sets exposure used in the effect.
  98668. */
  98669. exposure: number;
  98670. /**
  98671. * Gets wether tonemapping is enabled or not.
  98672. */
  98673. /**
  98674. * Sets wether tonemapping is enabled or not
  98675. */
  98676. toneMappingEnabled: boolean;
  98677. /**
  98678. * Gets the type of tone mapping effect.
  98679. */
  98680. /**
  98681. * Sets the type of tone mapping effect.
  98682. */
  98683. toneMappingType: number;
  98684. /**
  98685. * Gets contrast used in the effect.
  98686. */
  98687. /**
  98688. * Sets contrast used in the effect.
  98689. */
  98690. contrast: number;
  98691. /**
  98692. * Gets Vignette stretch size.
  98693. */
  98694. /**
  98695. * Sets Vignette stretch size.
  98696. */
  98697. vignetteStretch: number;
  98698. /**
  98699. * Gets Vignette centre X Offset.
  98700. */
  98701. /**
  98702. * Sets Vignette centre X Offset.
  98703. */
  98704. vignetteCentreX: number;
  98705. /**
  98706. * Gets Vignette centre Y Offset.
  98707. */
  98708. /**
  98709. * Sets Vignette centre Y Offset.
  98710. */
  98711. vignetteCentreY: number;
  98712. /**
  98713. * Gets Vignette weight or intensity of the vignette effect.
  98714. */
  98715. /**
  98716. * Sets Vignette weight or intensity of the vignette effect.
  98717. */
  98718. vignetteWeight: number;
  98719. /**
  98720. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98721. * if vignetteEnabled is set to true.
  98722. */
  98723. /**
  98724. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98725. * if vignetteEnabled is set to true.
  98726. */
  98727. vignetteColor: Color4;
  98728. /**
  98729. * Gets Camera field of view used by the Vignette effect.
  98730. */
  98731. /**
  98732. * Sets Camera field of view used by the Vignette effect.
  98733. */
  98734. vignetteCameraFov: number;
  98735. /**
  98736. * Gets the vignette blend mode allowing different kind of effect.
  98737. */
  98738. /**
  98739. * Sets the vignette blend mode allowing different kind of effect.
  98740. */
  98741. vignetteBlendMode: number;
  98742. /**
  98743. * Gets wether the vignette effect is enabled.
  98744. */
  98745. /**
  98746. * Sets wether the vignette effect is enabled.
  98747. */
  98748. vignetteEnabled: boolean;
  98749. private _fromLinearSpace;
  98750. /**
  98751. * Gets wether the input of the processing is in Gamma or Linear Space.
  98752. */
  98753. /**
  98754. * Sets wether the input of the processing is in Gamma or Linear Space.
  98755. */
  98756. fromLinearSpace: boolean;
  98757. /**
  98758. * Defines cache preventing GC.
  98759. */
  98760. private _defines;
  98761. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98762. /**
  98763. * "ImageProcessingPostProcess"
  98764. * @returns "ImageProcessingPostProcess"
  98765. */
  98766. getClassName(): string;
  98767. protected _updateParameters(): void;
  98768. dispose(camera?: Camera): void;
  98769. }
  98770. }
  98771. declare module BABYLON {
  98772. /**
  98773. * Class containing static functions to help procedurally build meshes
  98774. */
  98775. export class GroundBuilder {
  98776. /**
  98777. * Creates a ground mesh
  98778. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98779. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98781. * @param name defines the name of the mesh
  98782. * @param options defines the options used to create the mesh
  98783. * @param scene defines the hosting scene
  98784. * @returns the ground mesh
  98785. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98786. */
  98787. static CreateGround(name: string, options: {
  98788. width?: number;
  98789. height?: number;
  98790. subdivisions?: number;
  98791. subdivisionsX?: number;
  98792. subdivisionsY?: number;
  98793. updatable?: boolean;
  98794. }, scene: any): Mesh;
  98795. /**
  98796. * Creates a tiled ground mesh
  98797. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98798. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98799. * * 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
  98800. * * 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
  98801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98802. * @param name defines the name of the mesh
  98803. * @param options defines the options used to create the mesh
  98804. * @param scene defines the hosting scene
  98805. * @returns the tiled ground mesh
  98806. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98807. */
  98808. static CreateTiledGround(name: string, options: {
  98809. xmin: number;
  98810. zmin: number;
  98811. xmax: number;
  98812. zmax: number;
  98813. subdivisions?: {
  98814. w: number;
  98815. h: number;
  98816. };
  98817. precision?: {
  98818. w: number;
  98819. h: number;
  98820. };
  98821. updatable?: boolean;
  98822. }, scene?: Nullable<Scene>): Mesh;
  98823. /**
  98824. * Creates a ground mesh from a height map
  98825. * * The parameter `url` sets the URL of the height map image resource.
  98826. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98827. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98828. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98829. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98830. * * 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.
  98831. * * 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).
  98832. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98834. * @param name defines the name of the mesh
  98835. * @param url defines the url to the height map
  98836. * @param options defines the options used to create the mesh
  98837. * @param scene defines the hosting scene
  98838. * @returns the ground mesh
  98839. * @see https://doc.babylonjs.com/babylon101/height_map
  98840. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98841. */
  98842. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98843. width?: number;
  98844. height?: number;
  98845. subdivisions?: number;
  98846. minHeight?: number;
  98847. maxHeight?: number;
  98848. colorFilter?: Color3;
  98849. alphaFilter?: number;
  98850. updatable?: boolean;
  98851. onReady?: (mesh: GroundMesh) => void;
  98852. }, scene?: Nullable<Scene>): GroundMesh;
  98853. }
  98854. }
  98855. declare module BABYLON {
  98856. /**
  98857. * Class containing static functions to help procedurally build meshes
  98858. */
  98859. export class TorusBuilder {
  98860. /**
  98861. * Creates a torus mesh
  98862. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  98863. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  98864. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  98865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98868. * @param name defines the name of the mesh
  98869. * @param options defines the options used to create the mesh
  98870. * @param scene defines the hosting scene
  98871. * @returns the torus mesh
  98872. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  98873. */
  98874. static CreateTorus(name: string, options: {
  98875. diameter?: number;
  98876. thickness?: number;
  98877. tessellation?: number;
  98878. updatable?: boolean;
  98879. sideOrientation?: number;
  98880. frontUVs?: Vector4;
  98881. backUVs?: Vector4;
  98882. }, scene: any): Mesh;
  98883. }
  98884. }
  98885. declare module BABYLON {
  98886. /**
  98887. * Class containing static functions to help procedurally build meshes
  98888. */
  98889. export class CylinderBuilder {
  98890. /**
  98891. * Creates a cylinder or a cone mesh
  98892. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  98893. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  98894. * * 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.
  98895. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  98896. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  98897. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  98898. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  98899. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  98900. * * 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).
  98901. * * 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
  98902. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  98903. * * 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
  98904. * * 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.
  98905. * * If `enclose` is false, a ring surface is one element.
  98906. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  98907. * * 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
  98908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98911. * @param name defines the name of the mesh
  98912. * @param options defines the options used to create the mesh
  98913. * @param scene defines the hosting scene
  98914. * @returns the cylinder mesh
  98915. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  98916. */
  98917. static CreateCylinder(name: string, options: {
  98918. height?: number;
  98919. diameterTop?: number;
  98920. diameterBottom?: number;
  98921. diameter?: number;
  98922. tessellation?: number;
  98923. subdivisions?: number;
  98924. arc?: number;
  98925. faceColors?: Color4[];
  98926. faceUV?: Vector4[];
  98927. updatable?: boolean;
  98928. hasRings?: boolean;
  98929. enclose?: boolean;
  98930. sideOrientation?: number;
  98931. frontUVs?: Vector4;
  98932. backUVs?: Vector4;
  98933. }, scene: any): Mesh;
  98934. }
  98935. }
  98936. declare module BABYLON {
  98937. /**
  98938. * Manager for handling gamepads
  98939. */
  98940. export class GamepadManager {
  98941. private _scene?;
  98942. private _babylonGamepads;
  98943. private _oneGamepadConnected;
  98944. /** @hidden */
  98945. _isMonitoring: boolean;
  98946. private _gamepadEventSupported;
  98947. private _gamepadSupport;
  98948. /**
  98949. * observable to be triggered when the gamepad controller has been connected
  98950. */
  98951. onGamepadConnectedObservable: Observable<Gamepad>;
  98952. /**
  98953. * observable to be triggered when the gamepad controller has been disconnected
  98954. */
  98955. onGamepadDisconnectedObservable: Observable<Gamepad>;
  98956. private _onGamepadConnectedEvent;
  98957. private _onGamepadDisconnectedEvent;
  98958. /**
  98959. * Initializes the gamepad manager
  98960. * @param _scene BabylonJS scene
  98961. */
  98962. constructor(_scene?: Scene | undefined);
  98963. /**
  98964. * The gamepads in the game pad manager
  98965. */
  98966. readonly gamepads: Gamepad[];
  98967. /**
  98968. * Get the gamepad controllers based on type
  98969. * @param type The type of gamepad controller
  98970. * @returns Nullable gamepad
  98971. */
  98972. getGamepadByType(type?: number): Nullable<Gamepad>;
  98973. /**
  98974. * Disposes the gamepad manager
  98975. */
  98976. dispose(): void;
  98977. private _addNewGamepad;
  98978. private _startMonitoringGamepads;
  98979. private _stopMonitoringGamepads;
  98980. /** @hidden */
  98981. _checkGamepadsStatus(): void;
  98982. private _updateGamepadObjects;
  98983. }
  98984. }
  98985. declare module BABYLON {
  98986. interface Scene {
  98987. /** @hidden */
  98988. _gamepadManager: Nullable<GamepadManager>;
  98989. /**
  98990. * Gets the gamepad manager associated with the scene
  98991. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  98992. */
  98993. gamepadManager: GamepadManager;
  98994. }
  98995. /**
  98996. * Interface representing a free camera inputs manager
  98997. */
  98998. interface FreeCameraInputsManager {
  98999. /**
  99000. * Adds gamepad input support to the FreeCameraInputsManager.
  99001. * @returns the FreeCameraInputsManager
  99002. */
  99003. addGamepad(): FreeCameraInputsManager;
  99004. }
  99005. /**
  99006. * Interface representing an arc rotate camera inputs manager
  99007. */
  99008. interface ArcRotateCameraInputsManager {
  99009. /**
  99010. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99011. * @returns the camera inputs manager
  99012. */
  99013. addGamepad(): ArcRotateCameraInputsManager;
  99014. }
  99015. /**
  99016. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99017. */
  99018. export class GamepadSystemSceneComponent implements ISceneComponent {
  99019. /**
  99020. * The component name helpfull to identify the component in the list of scene components.
  99021. */
  99022. readonly name: string;
  99023. /**
  99024. * The scene the component belongs to.
  99025. */
  99026. scene: Scene;
  99027. /**
  99028. * Creates a new instance of the component for the given scene
  99029. * @param scene Defines the scene to register the component in
  99030. */
  99031. constructor(scene: Scene);
  99032. /**
  99033. * Registers the component in a given scene
  99034. */
  99035. register(): void;
  99036. /**
  99037. * Rebuilds the elements related to this component in case of
  99038. * context lost for instance.
  99039. */
  99040. rebuild(): void;
  99041. /**
  99042. * Disposes the component and the associated ressources
  99043. */
  99044. dispose(): void;
  99045. private _beforeCameraUpdate;
  99046. }
  99047. }
  99048. declare module BABYLON {
  99049. /**
  99050. * Options to modify the vr teleportation behavior.
  99051. */
  99052. export interface VRTeleportationOptions {
  99053. /**
  99054. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99055. */
  99056. floorMeshName?: string;
  99057. /**
  99058. * A list of meshes to be used as the teleportation floor. (default: empty)
  99059. */
  99060. floorMeshes?: Mesh[];
  99061. }
  99062. /**
  99063. * Options to modify the vr experience helper's behavior.
  99064. */
  99065. export interface VRExperienceHelperOptions extends WebVROptions {
  99066. /**
  99067. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99068. */
  99069. createDeviceOrientationCamera?: boolean;
  99070. /**
  99071. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99072. */
  99073. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99074. /**
  99075. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99076. */
  99077. laserToggle?: boolean;
  99078. /**
  99079. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99080. */
  99081. floorMeshes?: Mesh[];
  99082. /**
  99083. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99084. */
  99085. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99086. }
  99087. /**
  99088. * Event containing information after VR has been entered
  99089. */
  99090. export class OnAfterEnteringVRObservableEvent {
  99091. /**
  99092. * If entering vr was successful
  99093. */
  99094. success: boolean;
  99095. }
  99096. /**
  99097. * Helps to quickly add VR support to an existing scene.
  99098. * See http://doc.babylonjs.com/how_to/webvr_helper
  99099. */
  99100. export class VRExperienceHelper {
  99101. /** Options to modify the vr experience helper's behavior. */
  99102. webVROptions: VRExperienceHelperOptions;
  99103. private _scene;
  99104. private _position;
  99105. private _btnVR;
  99106. private _btnVRDisplayed;
  99107. private _webVRsupported;
  99108. private _webVRready;
  99109. private _webVRrequesting;
  99110. private _webVRpresenting;
  99111. private _hasEnteredVR;
  99112. private _fullscreenVRpresenting;
  99113. private _canvas;
  99114. private _webVRCamera;
  99115. private _vrDeviceOrientationCamera;
  99116. private _deviceOrientationCamera;
  99117. private _existingCamera;
  99118. private _onKeyDown;
  99119. private _onVrDisplayPresentChange;
  99120. private _onVRDisplayChanged;
  99121. private _onVRRequestPresentStart;
  99122. private _onVRRequestPresentComplete;
  99123. /**
  99124. * Observable raised right before entering VR.
  99125. */
  99126. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99127. /**
  99128. * Observable raised when entering VR has completed.
  99129. */
  99130. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99131. /**
  99132. * Observable raised when exiting VR.
  99133. */
  99134. onExitingVRObservable: Observable<VRExperienceHelper>;
  99135. /**
  99136. * Observable raised when controller mesh is loaded.
  99137. */
  99138. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99139. /** Return this.onEnteringVRObservable
  99140. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99141. */
  99142. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99143. /** Return this.onExitingVRObservable
  99144. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99145. */
  99146. readonly onExitingVR: Observable<VRExperienceHelper>;
  99147. /** Return this.onControllerMeshLoadedObservable
  99148. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99149. */
  99150. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99151. private _rayLength;
  99152. private _useCustomVRButton;
  99153. private _teleportationRequested;
  99154. private _teleportActive;
  99155. private _floorMeshName;
  99156. private _floorMeshesCollection;
  99157. private _rotationAllowed;
  99158. private _teleportBackwardsVector;
  99159. private _teleportationTarget;
  99160. private _isDefaultTeleportationTarget;
  99161. private _postProcessMove;
  99162. private _teleportationFillColor;
  99163. private _teleportationBorderColor;
  99164. private _rotationAngle;
  99165. private _haloCenter;
  99166. private _cameraGazer;
  99167. private _padSensibilityUp;
  99168. private _padSensibilityDown;
  99169. private _leftController;
  99170. private _rightController;
  99171. /**
  99172. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99173. */
  99174. onNewMeshSelected: Observable<AbstractMesh>;
  99175. /**
  99176. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99177. */
  99178. onNewMeshPicked: Observable<PickingInfo>;
  99179. private _circleEase;
  99180. /**
  99181. * Observable raised before camera teleportation
  99182. */
  99183. onBeforeCameraTeleport: Observable<Vector3>;
  99184. /**
  99185. * Observable raised after camera teleportation
  99186. */
  99187. onAfterCameraTeleport: Observable<Vector3>;
  99188. /**
  99189. * Observable raised when current selected mesh gets unselected
  99190. */
  99191. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99192. private _raySelectionPredicate;
  99193. /**
  99194. * To be optionaly changed by user to define custom ray selection
  99195. */
  99196. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99197. /**
  99198. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99199. */
  99200. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99201. /**
  99202. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99203. */
  99204. teleportationEnabled: boolean;
  99205. private _defaultHeight;
  99206. private _teleportationInitialized;
  99207. private _interactionsEnabled;
  99208. private _interactionsRequested;
  99209. private _displayGaze;
  99210. private _displayLaserPointer;
  99211. /**
  99212. * The mesh used to display where the user is going to teleport.
  99213. */
  99214. /**
  99215. * Sets the mesh to be used to display where the user is going to teleport.
  99216. */
  99217. teleportationTarget: Mesh;
  99218. /**
  99219. * 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
  99220. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99221. * See http://doc.babylonjs.com/resources/baking_transformations
  99222. */
  99223. gazeTrackerMesh: Mesh;
  99224. /**
  99225. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99226. */
  99227. updateGazeTrackerScale: boolean;
  99228. /**
  99229. * If the gaze trackers color should be updated when selecting meshes
  99230. */
  99231. updateGazeTrackerColor: boolean;
  99232. /**
  99233. * The gaze tracking mesh corresponding to the left controller
  99234. */
  99235. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99236. /**
  99237. * The gaze tracking mesh corresponding to the right controller
  99238. */
  99239. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99240. /**
  99241. * If the ray of the gaze should be displayed.
  99242. */
  99243. /**
  99244. * Sets if the ray of the gaze should be displayed.
  99245. */
  99246. displayGaze: boolean;
  99247. /**
  99248. * If the ray of the LaserPointer should be displayed.
  99249. */
  99250. /**
  99251. * Sets if the ray of the LaserPointer should be displayed.
  99252. */
  99253. displayLaserPointer: boolean;
  99254. /**
  99255. * The deviceOrientationCamera used as the camera when not in VR.
  99256. */
  99257. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99258. /**
  99259. * Based on the current WebVR support, returns the current VR camera used.
  99260. */
  99261. readonly currentVRCamera: Nullable<Camera>;
  99262. /**
  99263. * The webVRCamera which is used when in VR.
  99264. */
  99265. readonly webVRCamera: WebVRFreeCamera;
  99266. /**
  99267. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99268. */
  99269. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99270. private readonly _teleportationRequestInitiated;
  99271. /**
  99272. * Defines wether or not Pointer lock should be requested when switching to
  99273. * full screen.
  99274. */
  99275. requestPointerLockOnFullScreen: boolean;
  99276. /**
  99277. * Instantiates a VRExperienceHelper.
  99278. * Helps to quickly add VR support to an existing scene.
  99279. * @param scene The scene the VRExperienceHelper belongs to.
  99280. * @param webVROptions Options to modify the vr experience helper's behavior.
  99281. */
  99282. constructor(scene: Scene,
  99283. /** Options to modify the vr experience helper's behavior. */
  99284. webVROptions?: VRExperienceHelperOptions);
  99285. private _onDefaultMeshLoaded;
  99286. private _onResize;
  99287. private _onFullscreenChange;
  99288. /**
  99289. * Gets a value indicating if we are currently in VR mode.
  99290. */
  99291. readonly isInVRMode: boolean;
  99292. private onVrDisplayPresentChange;
  99293. private onVRDisplayChanged;
  99294. private moveButtonToBottomRight;
  99295. private displayVRButton;
  99296. private updateButtonVisibility;
  99297. private _cachedAngularSensibility;
  99298. /**
  99299. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99300. * Otherwise, will use the fullscreen API.
  99301. */
  99302. enterVR(): void;
  99303. /**
  99304. * Attempt to exit VR, or fullscreen.
  99305. */
  99306. exitVR(): void;
  99307. /**
  99308. * The position of the vr experience helper.
  99309. */
  99310. /**
  99311. * Sets the position of the vr experience helper.
  99312. */
  99313. position: Vector3;
  99314. /**
  99315. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99316. */
  99317. enableInteractions(): void;
  99318. private readonly _noControllerIsActive;
  99319. private beforeRender;
  99320. private _isTeleportationFloor;
  99321. /**
  99322. * Adds a floor mesh to be used for teleportation.
  99323. * @param floorMesh the mesh to be used for teleportation.
  99324. */
  99325. addFloorMesh(floorMesh: Mesh): void;
  99326. /**
  99327. * Removes a floor mesh from being used for teleportation.
  99328. * @param floorMesh the mesh to be removed.
  99329. */
  99330. removeFloorMesh(floorMesh: Mesh): void;
  99331. /**
  99332. * Enables interactions and teleportation using the VR controllers and gaze.
  99333. * @param vrTeleportationOptions options to modify teleportation behavior.
  99334. */
  99335. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99336. private _onNewGamepadConnected;
  99337. private _tryEnableInteractionOnController;
  99338. private _onNewGamepadDisconnected;
  99339. private _enableInteractionOnController;
  99340. private _checkTeleportWithRay;
  99341. private _checkRotate;
  99342. private _checkTeleportBackwards;
  99343. private _enableTeleportationOnController;
  99344. private _createTeleportationCircles;
  99345. private _displayTeleportationTarget;
  99346. private _hideTeleportationTarget;
  99347. private _rotateCamera;
  99348. private _moveTeleportationSelectorTo;
  99349. private _workingVector;
  99350. private _workingQuaternion;
  99351. private _workingMatrix;
  99352. /**
  99353. * Teleports the users feet to the desired location
  99354. * @param location The location where the user's feet should be placed
  99355. */
  99356. teleportCamera(location: Vector3): void;
  99357. private _convertNormalToDirectionOfRay;
  99358. private _castRayAndSelectObject;
  99359. private _notifySelectedMeshUnselected;
  99360. /**
  99361. * Sets the color of the laser ray from the vr controllers.
  99362. * @param color new color for the ray.
  99363. */
  99364. changeLaserColor(color: Color3): void;
  99365. /**
  99366. * Sets the color of the ray from the vr headsets gaze.
  99367. * @param color new color for the ray.
  99368. */
  99369. changeGazeColor(color: Color3): void;
  99370. /**
  99371. * Exits VR and disposes of the vr experience helper
  99372. */
  99373. dispose(): void;
  99374. /**
  99375. * Gets the name of the VRExperienceHelper class
  99376. * @returns "VRExperienceHelper"
  99377. */
  99378. getClassName(): string;
  99379. }
  99380. }
  99381. declare module BABYLON {
  99382. /**
  99383. * Manages an XRSession
  99384. * @see https://doc.babylonjs.com/how_to/webxr
  99385. */
  99386. export class WebXRSessionManager implements IDisposable {
  99387. private scene;
  99388. /**
  99389. * Fires every time a new xrFrame arrives which can be used to update the camera
  99390. */
  99391. onXRFrameObservable: Observable<any>;
  99392. /**
  99393. * Fires when the xr session is ended either by the device or manually done
  99394. */
  99395. onXRSessionEnded: Observable<any>;
  99396. /** @hidden */
  99397. _xrSession: XRSession;
  99398. /** @hidden */
  99399. _frameOfReference: XRFrameOfReference;
  99400. /** @hidden */
  99401. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99402. /** @hidden */
  99403. _currentXRFrame: Nullable<XRFrame>;
  99404. private _xrNavigator;
  99405. private _xrDevice;
  99406. private _tmpMatrix;
  99407. /**
  99408. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99409. * @param scene The scene which the session should be created for
  99410. */
  99411. constructor(scene: Scene);
  99412. /**
  99413. * Initializes the manager
  99414. * After initialization enterXR can be called to start an XR session
  99415. * @returns Promise which resolves after it is initialized
  99416. */
  99417. initializeAsync(): Promise<void>;
  99418. /**
  99419. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99420. * @param sessionCreationOptions xr options to create the session with
  99421. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99422. * @returns Promise which resolves after it enters XR
  99423. */
  99424. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99425. /**
  99426. * Stops the xrSession and restores the renderloop
  99427. * @returns Promise which resolves after it exits XR
  99428. */
  99429. exitXRAsync(): Promise<void>;
  99430. /**
  99431. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99432. * @param ray ray to cast into the environment
  99433. * @returns Promise which resolves with a collision point in the environment if it exists
  99434. */
  99435. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99436. /**
  99437. * Checks if a session would be supported for the creation options specified
  99438. * @param options creation options to check if they are supported
  99439. * @returns true if supported
  99440. */
  99441. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99442. /**
  99443. * @hidden
  99444. * Converts the render layer of xrSession to a render target
  99445. * @param session session to create render target for
  99446. * @param scene scene the new render target should be created for
  99447. */
  99448. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99449. /**
  99450. * Disposes of the session manager
  99451. */
  99452. dispose(): void;
  99453. }
  99454. }
  99455. declare module BABYLON {
  99456. /**
  99457. * WebXR Camera which holds the views for the xrSession
  99458. * @see https://doc.babylonjs.com/how_to/webxr
  99459. */
  99460. export class WebXRCamera extends FreeCamera {
  99461. private static _TmpMatrix;
  99462. /**
  99463. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99464. * @param name the name of the camera
  99465. * @param scene the scene to add the camera to
  99466. */
  99467. constructor(name: string, scene: Scene);
  99468. private _updateNumberOfRigCameras;
  99469. /** @hidden */
  99470. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99471. /**
  99472. * Updates the cameras position from the current pose information of the XR session
  99473. * @param xrSessionManager the session containing pose information
  99474. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99475. */
  99476. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99477. }
  99478. }
  99479. declare module BABYLON {
  99480. /**
  99481. * States of the webXR experience
  99482. */
  99483. export enum WebXRState {
  99484. /**
  99485. * Transitioning to being in XR mode
  99486. */
  99487. ENTERING_XR = 0,
  99488. /**
  99489. * Transitioning to non XR mode
  99490. */
  99491. EXITING_XR = 1,
  99492. /**
  99493. * In XR mode and presenting
  99494. */
  99495. IN_XR = 2,
  99496. /**
  99497. * Not entered XR mode
  99498. */
  99499. NOT_IN_XR = 3
  99500. }
  99501. /**
  99502. * Helper class used to enable XR
  99503. * @see https://doc.babylonjs.com/how_to/webxr
  99504. */
  99505. export class WebXRExperienceHelper implements IDisposable {
  99506. private scene;
  99507. /**
  99508. * 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
  99509. */
  99510. container: AbstractMesh;
  99511. /**
  99512. * Camera used to render xr content
  99513. */
  99514. camera: WebXRCamera;
  99515. /**
  99516. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  99517. */
  99518. state: WebXRState;
  99519. private _setState;
  99520. private static _TmpVector;
  99521. /**
  99522. * Fires when the state of the experience helper has changed
  99523. */
  99524. onStateChangedObservable: Observable<WebXRState>;
  99525. /** @hidden */
  99526. _sessionManager: WebXRSessionManager;
  99527. private _nonVRCamera;
  99528. private _originalSceneAutoClear;
  99529. private _supported;
  99530. /**
  99531. * Creates the experience helper
  99532. * @param scene the scene to attach the experience helper to
  99533. * @returns a promise for the experience helper
  99534. */
  99535. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  99536. /**
  99537. * Creates a WebXRExperienceHelper
  99538. * @param scene The scene the helper should be created in
  99539. */
  99540. private constructor();
  99541. /**
  99542. * Exits XR mode and returns the scene to its original state
  99543. * @returns promise that resolves after xr mode has exited
  99544. */
  99545. exitXRAsync(): Promise<void>;
  99546. /**
  99547. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  99548. * @param sessionCreationOptions options for the XR session
  99549. * @param frameOfReference frame of reference of the XR session
  99550. * @returns promise that resolves after xr mode has entered
  99551. */
  99552. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  99553. /**
  99554. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99555. * @param ray ray to cast into the environment
  99556. * @returns Promise which resolves with a collision point in the environment if it exists
  99557. */
  99558. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99559. /**
  99560. * Updates the global position of the camera by moving the camera's container
  99561. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  99562. * @param position The desired global position of the camera
  99563. */
  99564. setPositionOfCameraUsingContainer(position: Vector3): void;
  99565. /**
  99566. * Rotates the xr camera by rotating the camera's container around the camera's position
  99567. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  99568. * @param rotation the desired quaternion rotation to apply to the camera
  99569. */
  99570. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  99571. /**
  99572. * Checks if the creation options are supported by the xr session
  99573. * @param options creation options
  99574. * @returns true if supported
  99575. */
  99576. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99577. /**
  99578. * Disposes of the experience helper
  99579. */
  99580. dispose(): void;
  99581. }
  99582. }
  99583. declare module BABYLON {
  99584. /**
  99585. * Button which can be used to enter a different mode of XR
  99586. */
  99587. export class WebXREnterExitUIButton {
  99588. /** button element */
  99589. element: HTMLElement;
  99590. /** XR initialization options for the button */
  99591. initializationOptions: XRSessionCreationOptions;
  99592. /**
  99593. * Creates a WebXREnterExitUIButton
  99594. * @param element button element
  99595. * @param initializationOptions XR initialization options for the button
  99596. */
  99597. constructor(
  99598. /** button element */
  99599. element: HTMLElement,
  99600. /** XR initialization options for the button */
  99601. initializationOptions: XRSessionCreationOptions);
  99602. /**
  99603. * Overwritable function which can be used to update the button's visuals when the state changes
  99604. * @param activeButton the current active button in the UI
  99605. */
  99606. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99607. }
  99608. /**
  99609. * Options to create the webXR UI
  99610. */
  99611. export class WebXREnterExitUIOptions {
  99612. /**
  99613. * Context to enter xr with
  99614. */
  99615. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99616. /**
  99617. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99618. */
  99619. customButtons?: Array<WebXREnterExitUIButton>;
  99620. }
  99621. /**
  99622. * UI to allow the user to enter/exit XR mode
  99623. */
  99624. export class WebXREnterExitUI implements IDisposable {
  99625. private scene;
  99626. private _overlay;
  99627. private _buttons;
  99628. private _activeButton;
  99629. /**
  99630. * Fired every time the active button is changed.
  99631. *
  99632. * When xr is entered via a button that launches xr that button will be the callback parameter
  99633. *
  99634. * When exiting xr the callback parameter will be null)
  99635. */
  99636. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99637. /**
  99638. * Creates UI to allow the user to enter/exit XR mode
  99639. * @param scene the scene to add the ui to
  99640. * @param helper the xr experience helper to enter/exit xr with
  99641. * @param options options to configure the UI
  99642. * @returns the created ui
  99643. */
  99644. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99645. private constructor();
  99646. private _updateButtons;
  99647. /**
  99648. * Disposes of the object
  99649. */
  99650. dispose(): void;
  99651. }
  99652. }
  99653. declare module BABYLON {
  99654. /**
  99655. * Represents an XR input
  99656. */
  99657. export class WebXRController {
  99658. /**
  99659. * 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
  99660. */
  99661. grip?: AbstractMesh;
  99662. /**
  99663. * Pointer which can be used to select objects or attach a visible laser to
  99664. */
  99665. pointer: AbstractMesh;
  99666. /**
  99667. * Creates the controller
  99668. * @see https://doc.babylonjs.com/how_to/webxr
  99669. * @param scene the scene which the controller should be associated to
  99670. */
  99671. constructor(scene: Scene);
  99672. /**
  99673. * Disposes of the object
  99674. */
  99675. dispose(): void;
  99676. }
  99677. /**
  99678. * XR input used to track XR inputs such as controllers/rays
  99679. */
  99680. export class WebXRInput implements IDisposable {
  99681. private helper;
  99682. /**
  99683. * XR controllers being tracked
  99684. */
  99685. controllers: Array<WebXRController>;
  99686. private _tmpMatrix;
  99687. private _frameObserver;
  99688. /**
  99689. * Initializes the WebXRInput
  99690. * @param helper experience helper which the input should be created for
  99691. */
  99692. constructor(helper: WebXRExperienceHelper);
  99693. /**
  99694. * Disposes of the object
  99695. */
  99696. dispose(): void;
  99697. }
  99698. }
  99699. declare module BABYLON {
  99700. /**
  99701. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99702. */
  99703. export class WebXRManagedOutputCanvas implements IDisposable {
  99704. private _canvas;
  99705. /**
  99706. * xrpresent context of the canvas which can be used to display/mirror xr content
  99707. */
  99708. canvasContext: Nullable<WebGLRenderingContext>;
  99709. /**
  99710. * Initializes the canvas to be added/removed upon entering/exiting xr
  99711. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99712. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99713. */
  99714. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99715. /**
  99716. * Disposes of the object
  99717. */
  99718. dispose(): void;
  99719. private _setManagedOutputCanvas;
  99720. private _addCanvas;
  99721. private _removeCanvas;
  99722. }
  99723. }
  99724. declare module BABYLON {
  99725. /**
  99726. * Contains an array of blocks representing the octree
  99727. */
  99728. export interface IOctreeContainer<T> {
  99729. /**
  99730. * Blocks within the octree
  99731. */
  99732. blocks: Array<OctreeBlock<T>>;
  99733. }
  99734. /**
  99735. * Class used to store a cell in an octree
  99736. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99737. */
  99738. export class OctreeBlock<T> {
  99739. /**
  99740. * Gets the content of the current block
  99741. */
  99742. entries: T[];
  99743. /**
  99744. * Gets the list of block children
  99745. */
  99746. blocks: Array<OctreeBlock<T>>;
  99747. private _depth;
  99748. private _maxDepth;
  99749. private _capacity;
  99750. private _minPoint;
  99751. private _maxPoint;
  99752. private _boundingVectors;
  99753. private _creationFunc;
  99754. /**
  99755. * Creates a new block
  99756. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99757. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99758. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99759. * @param depth defines the current depth of this block in the octree
  99760. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99761. * @param creationFunc defines a callback to call when an element is added to the block
  99762. */
  99763. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99764. /**
  99765. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99766. */
  99767. readonly capacity: number;
  99768. /**
  99769. * Gets the minimum vector (in world space) of the block's bounding box
  99770. */
  99771. readonly minPoint: Vector3;
  99772. /**
  99773. * Gets the maximum vector (in world space) of the block's bounding box
  99774. */
  99775. readonly maxPoint: Vector3;
  99776. /**
  99777. * Add a new element to this block
  99778. * @param entry defines the element to add
  99779. */
  99780. addEntry(entry: T): void;
  99781. /**
  99782. * Remove an element from this block
  99783. * @param entry defines the element to remove
  99784. */
  99785. removeEntry(entry: T): void;
  99786. /**
  99787. * Add an array of elements to this block
  99788. * @param entries defines the array of elements to add
  99789. */
  99790. addEntries(entries: T[]): void;
  99791. /**
  99792. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99793. * @param frustumPlanes defines the frustum planes to test
  99794. * @param selection defines the array to store current content if selection is positive
  99795. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99796. */
  99797. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99798. /**
  99799. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99800. * @param sphereCenter defines the bounding sphere center
  99801. * @param sphereRadius defines the bounding sphere radius
  99802. * @param selection defines the array to store current content if selection is positive
  99803. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99804. */
  99805. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99806. /**
  99807. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99808. * @param ray defines the ray to test with
  99809. * @param selection defines the array to store current content if selection is positive
  99810. */
  99811. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99812. /**
  99813. * Subdivide the content into child blocks (this block will then be empty)
  99814. */
  99815. createInnerBlocks(): void;
  99816. /**
  99817. * @hidden
  99818. */
  99819. 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;
  99820. }
  99821. }
  99822. declare module BABYLON {
  99823. /**
  99824. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99825. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99826. */
  99827. export class Octree<T> {
  99828. /** 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.) */
  99829. maxDepth: number;
  99830. /**
  99831. * Blocks within the octree containing objects
  99832. */
  99833. blocks: Array<OctreeBlock<T>>;
  99834. /**
  99835. * Content stored in the octree
  99836. */
  99837. dynamicContent: T[];
  99838. private _maxBlockCapacity;
  99839. private _selectionContent;
  99840. private _creationFunc;
  99841. /**
  99842. * Creates a octree
  99843. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99844. * @param creationFunc function to be used to instatiate the octree
  99845. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99846. * @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.)
  99847. */
  99848. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  99849. /** 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.) */
  99850. maxDepth?: number);
  99851. /**
  99852. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  99853. * @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);
  99854. * @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);
  99855. * @param entries meshes to be added to the octree blocks
  99856. */
  99857. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  99858. /**
  99859. * Adds a mesh to the octree
  99860. * @param entry Mesh to add to the octree
  99861. */
  99862. addMesh(entry: T): void;
  99863. /**
  99864. * Remove an element from the octree
  99865. * @param entry defines the element to remove
  99866. */
  99867. removeMesh(entry: T): void;
  99868. /**
  99869. * Selects an array of meshes within the frustum
  99870. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  99871. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  99872. * @returns array of meshes within the frustum
  99873. */
  99874. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  99875. /**
  99876. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  99877. * @param sphereCenter defines the bounding sphere center
  99878. * @param sphereRadius defines the bounding sphere radius
  99879. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99880. * @returns an array of objects that intersect the sphere
  99881. */
  99882. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  99883. /**
  99884. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  99885. * @param ray defines the ray to test with
  99886. * @returns array of intersected objects
  99887. */
  99888. intersectsRay(ray: Ray): SmartArray<T>;
  99889. /**
  99890. * Adds a mesh into the octree block if it intersects the block
  99891. */
  99892. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  99893. /**
  99894. * Adds a submesh into the octree block if it intersects the block
  99895. */
  99896. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  99897. }
  99898. }
  99899. declare module BABYLON {
  99900. interface Scene {
  99901. /**
  99902. * @hidden
  99903. * Backing Filed
  99904. */
  99905. _selectionOctree: Octree<AbstractMesh>;
  99906. /**
  99907. * Gets the octree used to boost mesh selection (picking)
  99908. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99909. */
  99910. selectionOctree: Octree<AbstractMesh>;
  99911. /**
  99912. * Creates or updates the octree used to boost selection (picking)
  99913. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99914. * @param maxCapacity defines the maximum capacity per leaf
  99915. * @param maxDepth defines the maximum depth of the octree
  99916. * @returns an octree of AbstractMesh
  99917. */
  99918. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  99919. }
  99920. interface AbstractMesh {
  99921. /**
  99922. * @hidden
  99923. * Backing Field
  99924. */
  99925. _submeshesOctree: Octree<SubMesh>;
  99926. /**
  99927. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  99928. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99929. * @param maxCapacity defines the maximum size of each block (64 by default)
  99930. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  99931. * @returns the new octree
  99932. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  99933. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99934. */
  99935. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  99936. }
  99937. /**
  99938. * Defines the octree scene component responsible to manage any octrees
  99939. * in a given scene.
  99940. */
  99941. export class OctreeSceneComponent {
  99942. /**
  99943. * The component name helpfull to identify the component in the list of scene components.
  99944. */
  99945. readonly name: string;
  99946. /**
  99947. * The scene the component belongs to.
  99948. */
  99949. scene: Scene;
  99950. /**
  99951. * Indicates if the meshes have been checked to make sure they are isEnabled()
  99952. */
  99953. readonly checksIsEnabled: boolean;
  99954. /**
  99955. * Creates a new instance of the component for the given scene
  99956. * @param scene Defines the scene to register the component in
  99957. */
  99958. constructor(scene: Scene);
  99959. /**
  99960. * Registers the component in a given scene
  99961. */
  99962. register(): void;
  99963. /**
  99964. * Return the list of active meshes
  99965. * @returns the list of active meshes
  99966. */
  99967. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99968. /**
  99969. * Return the list of active sub meshes
  99970. * @param mesh The mesh to get the candidates sub meshes from
  99971. * @returns the list of active sub meshes
  99972. */
  99973. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99974. private _tempRay;
  99975. /**
  99976. * Return the list of sub meshes intersecting with a given local ray
  99977. * @param mesh defines the mesh to find the submesh for
  99978. * @param localRay defines the ray in local space
  99979. * @returns the list of intersecting sub meshes
  99980. */
  99981. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  99982. /**
  99983. * Return the list of sub meshes colliding with a collider
  99984. * @param mesh defines the mesh to find the submesh for
  99985. * @param collider defines the collider to evaluate the collision against
  99986. * @returns the list of colliding sub meshes
  99987. */
  99988. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  99989. /**
  99990. * Rebuilds the elements related to this component in case of
  99991. * context lost for instance.
  99992. */
  99993. rebuild(): void;
  99994. /**
  99995. * Disposes the component and the associated ressources.
  99996. */
  99997. dispose(): void;
  99998. }
  99999. }
  100000. declare module BABYLON {
  100001. /**
  100002. * Renders a layer on top of an existing scene
  100003. */
  100004. export class UtilityLayerRenderer implements IDisposable {
  100005. /** the original scene that will be rendered on top of */
  100006. originalScene: Scene;
  100007. private _pointerCaptures;
  100008. private _lastPointerEvents;
  100009. private static _DefaultUtilityLayer;
  100010. private static _DefaultKeepDepthUtilityLayer;
  100011. private _sharedGizmoLight;
  100012. /**
  100013. * @hidden
  100014. * Light which used by gizmos to get light shading
  100015. */
  100016. _getSharedGizmoLight(): HemisphericLight;
  100017. /**
  100018. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100019. */
  100020. pickUtilitySceneFirst: boolean;
  100021. /**
  100022. * 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)
  100023. */
  100024. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100025. /**
  100026. * 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)
  100027. */
  100028. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100029. /**
  100030. * The scene that is rendered on top of the original scene
  100031. */
  100032. utilityLayerScene: Scene;
  100033. /**
  100034. * If the utility layer should automatically be rendered on top of existing scene
  100035. */
  100036. shouldRender: boolean;
  100037. /**
  100038. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100039. */
  100040. onlyCheckPointerDownEvents: boolean;
  100041. /**
  100042. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100043. */
  100044. processAllEvents: boolean;
  100045. /**
  100046. * Observable raised when the pointer move from the utility layer scene to the main scene
  100047. */
  100048. onPointerOutObservable: Observable<number>;
  100049. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100050. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100051. private _afterRenderObserver;
  100052. private _sceneDisposeObserver;
  100053. private _originalPointerObserver;
  100054. /**
  100055. * Instantiates a UtilityLayerRenderer
  100056. * @param originalScene the original scene that will be rendered on top of
  100057. * @param handleEvents boolean indicating if the utility layer should handle events
  100058. */
  100059. constructor(
  100060. /** the original scene that will be rendered on top of */
  100061. originalScene: Scene, handleEvents?: boolean);
  100062. private _notifyObservers;
  100063. /**
  100064. * Renders the utility layers scene on top of the original scene
  100065. */
  100066. render(): void;
  100067. /**
  100068. * Disposes of the renderer
  100069. */
  100070. dispose(): void;
  100071. private _updateCamera;
  100072. }
  100073. }
  100074. declare module BABYLON {
  100075. /**
  100076. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100077. */
  100078. export class Gizmo implements IDisposable {
  100079. /** The utility layer the gizmo will be added to */
  100080. gizmoLayer: UtilityLayerRenderer;
  100081. /**
  100082. * The root mesh of the gizmo
  100083. */
  100084. _rootMesh: Mesh;
  100085. private _attachedMesh;
  100086. /**
  100087. * Ratio for the scale of the gizmo (Default: 1)
  100088. */
  100089. scaleRatio: number;
  100090. /**
  100091. * If a custom mesh has been set (Default: false)
  100092. */
  100093. protected _customMeshSet: boolean;
  100094. /**
  100095. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100096. * * When set, interactions will be enabled
  100097. */
  100098. attachedMesh: Nullable<AbstractMesh>;
  100099. /**
  100100. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100101. * @param mesh The mesh to replace the default mesh of the gizmo
  100102. */
  100103. setCustomMesh(mesh: Mesh): void;
  100104. /**
  100105. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100106. */
  100107. updateGizmoRotationToMatchAttachedMesh: boolean;
  100108. /**
  100109. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100110. */
  100111. updateGizmoPositionToMatchAttachedMesh: boolean;
  100112. /**
  100113. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100114. */
  100115. protected _updateScale: boolean;
  100116. protected _interactionsEnabled: boolean;
  100117. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100118. private _beforeRenderObserver;
  100119. private _tempVector;
  100120. /**
  100121. * Creates a gizmo
  100122. * @param gizmoLayer The utility layer the gizmo will be added to
  100123. */
  100124. constructor(
  100125. /** The utility layer the gizmo will be added to */
  100126. gizmoLayer?: UtilityLayerRenderer);
  100127. /**
  100128. * Updates the gizmo to match the attached mesh's position/rotation
  100129. */
  100130. protected _update(): void;
  100131. /**
  100132. * Disposes of the gizmo
  100133. */
  100134. dispose(): void;
  100135. }
  100136. }
  100137. declare module BABYLON {
  100138. /**
  100139. * Single axis drag gizmo
  100140. */
  100141. export class AxisDragGizmo extends Gizmo {
  100142. /**
  100143. * Drag behavior responsible for the gizmos dragging interactions
  100144. */
  100145. dragBehavior: PointerDragBehavior;
  100146. private _pointerObserver;
  100147. /**
  100148. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100149. */
  100150. snapDistance: number;
  100151. /**
  100152. * Event that fires each time the gizmo snaps to a new location.
  100153. * * snapDistance is the the change in distance
  100154. */
  100155. onSnapObservable: Observable<{
  100156. snapDistance: number;
  100157. }>;
  100158. /** @hidden */
  100159. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100160. /** @hidden */
  100161. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100162. /**
  100163. * Creates an AxisDragGizmo
  100164. * @param gizmoLayer The utility layer the gizmo will be added to
  100165. * @param dragAxis The axis which the gizmo will be able to drag on
  100166. * @param color The color of the gizmo
  100167. */
  100168. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100169. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100170. /**
  100171. * Disposes of the gizmo
  100172. */
  100173. dispose(): void;
  100174. }
  100175. }
  100176. declare module BABYLON.Debug {
  100177. /**
  100178. * The Axes viewer will show 3 axes in a specific point in space
  100179. */
  100180. export class AxesViewer {
  100181. private _xAxis;
  100182. private _yAxis;
  100183. private _zAxis;
  100184. private _scaleLinesFactor;
  100185. private _instanced;
  100186. /**
  100187. * Gets the hosting scene
  100188. */
  100189. scene: Scene;
  100190. /**
  100191. * Gets or sets a number used to scale line length
  100192. */
  100193. scaleLines: number;
  100194. /** Gets the node hierarchy used to render x-axis */
  100195. readonly xAxis: TransformNode;
  100196. /** Gets the node hierarchy used to render y-axis */
  100197. readonly yAxis: TransformNode;
  100198. /** Gets the node hierarchy used to render z-axis */
  100199. readonly zAxis: TransformNode;
  100200. /**
  100201. * Creates a new AxesViewer
  100202. * @param scene defines the hosting scene
  100203. * @param scaleLines defines a number used to scale line length (1 by default)
  100204. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100205. * @param xAxis defines the node hierarchy used to render the x-axis
  100206. * @param yAxis defines the node hierarchy used to render the y-axis
  100207. * @param zAxis defines the node hierarchy used to render the z-axis
  100208. */
  100209. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100210. /**
  100211. * Force the viewer to update
  100212. * @param position defines the position of the viewer
  100213. * @param xaxis defines the x axis of the viewer
  100214. * @param yaxis defines the y axis of the viewer
  100215. * @param zaxis defines the z axis of the viewer
  100216. */
  100217. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100218. /**
  100219. * Creates an instance of this axes viewer.
  100220. * @returns a new axes viewer with instanced meshes
  100221. */
  100222. createInstance(): AxesViewer;
  100223. /** Releases resources */
  100224. dispose(): void;
  100225. private static _SetRenderingGroupId;
  100226. }
  100227. }
  100228. declare module BABYLON.Debug {
  100229. /**
  100230. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100231. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100232. */
  100233. export class BoneAxesViewer extends AxesViewer {
  100234. /**
  100235. * Gets or sets the target mesh where to display the axes viewer
  100236. */
  100237. mesh: Nullable<Mesh>;
  100238. /**
  100239. * Gets or sets the target bone where to display the axes viewer
  100240. */
  100241. bone: Nullable<Bone>;
  100242. /** Gets current position */
  100243. pos: Vector3;
  100244. /** Gets direction of X axis */
  100245. xaxis: Vector3;
  100246. /** Gets direction of Y axis */
  100247. yaxis: Vector3;
  100248. /** Gets direction of Z axis */
  100249. zaxis: Vector3;
  100250. /**
  100251. * Creates a new BoneAxesViewer
  100252. * @param scene defines the hosting scene
  100253. * @param bone defines the target bone
  100254. * @param mesh defines the target mesh
  100255. * @param scaleLines defines a scaling factor for line length (1 by default)
  100256. */
  100257. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100258. /**
  100259. * Force the viewer to update
  100260. */
  100261. update(): void;
  100262. /** Releases resources */
  100263. dispose(): void;
  100264. }
  100265. }
  100266. declare module BABYLON {
  100267. /**
  100268. * Interface used to define scene explorer extensibility option
  100269. */
  100270. export interface IExplorerExtensibilityOption {
  100271. /**
  100272. * Define the option label
  100273. */
  100274. label: string;
  100275. /**
  100276. * Defines the action to execute on click
  100277. */
  100278. action: (entity: any) => void;
  100279. }
  100280. /**
  100281. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100282. */
  100283. export interface IExplorerExtensibilityGroup {
  100284. /**
  100285. * Defines a predicate to test if a given type mut be extended
  100286. */
  100287. predicate: (entity: any) => boolean;
  100288. /**
  100289. * Gets the list of options added to a type
  100290. */
  100291. entries: IExplorerExtensibilityOption[];
  100292. }
  100293. /**
  100294. * Interface used to define the options to use to create the Inspector
  100295. */
  100296. export interface IInspectorOptions {
  100297. /**
  100298. * Display in overlay mode (default: false)
  100299. */
  100300. overlay?: boolean;
  100301. /**
  100302. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100303. */
  100304. globalRoot?: HTMLElement;
  100305. /**
  100306. * Display the Scene explorer
  100307. */
  100308. showExplorer?: boolean;
  100309. /**
  100310. * Display the property inspector
  100311. */
  100312. showInspector?: boolean;
  100313. /**
  100314. * Display in embed mode (both panes on the right)
  100315. */
  100316. embedMode?: boolean;
  100317. /**
  100318. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100319. */
  100320. handleResize?: boolean;
  100321. /**
  100322. * Allow the panes to popup (default: true)
  100323. */
  100324. enablePopup?: boolean;
  100325. /**
  100326. * Allow the panes to be closed by users (default: true)
  100327. */
  100328. enableClose?: boolean;
  100329. /**
  100330. * Optional list of extensibility entries
  100331. */
  100332. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100333. /**
  100334. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100335. */
  100336. inspectorURL?: string;
  100337. }
  100338. interface Scene {
  100339. /**
  100340. * @hidden
  100341. * Backing field
  100342. */
  100343. _debugLayer: DebugLayer;
  100344. /**
  100345. * Gets the debug layer (aka Inspector) associated with the scene
  100346. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100347. */
  100348. debugLayer: DebugLayer;
  100349. }
  100350. /**
  100351. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100352. * what is happening in your scene
  100353. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100354. */
  100355. export class DebugLayer {
  100356. /**
  100357. * Define the url to get the inspector script from.
  100358. * By default it uses the babylonjs CDN.
  100359. * @ignoreNaming
  100360. */
  100361. static InspectorURL: string;
  100362. private _scene;
  100363. private BJSINSPECTOR;
  100364. /**
  100365. * Observable triggered when a property is changed through the inspector.
  100366. */
  100367. onPropertyChangedObservable: Observable<{
  100368. object: any;
  100369. property: string;
  100370. value: any;
  100371. initialValue: any;
  100372. }>;
  100373. /**
  100374. * Instantiates a new debug layer.
  100375. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100376. * what is happening in your scene
  100377. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100378. * @param scene Defines the scene to inspect
  100379. */
  100380. constructor(scene: Scene);
  100381. /** Creates the inspector window. */
  100382. private _createInspector;
  100383. /**
  100384. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100385. * @param entity defines the entity to select
  100386. * @param lineContainerTitle defines the specific block to highlight
  100387. */
  100388. select(entity: any, lineContainerTitle?: string): void;
  100389. /** Get the inspector from bundle or global */
  100390. private _getGlobalInspector;
  100391. /**
  100392. * Get if the inspector is visible or not.
  100393. * @returns true if visible otherwise, false
  100394. */
  100395. isVisible(): boolean;
  100396. /**
  100397. * Hide the inspector and close its window.
  100398. */
  100399. hide(): void;
  100400. /**
  100401. * Launch the debugLayer.
  100402. * @param config Define the configuration of the inspector
  100403. * @return a promise fulfilled when the debug layer is visible
  100404. */
  100405. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100406. }
  100407. }
  100408. declare module BABYLON {
  100409. /**
  100410. * Class containing static functions to help procedurally build meshes
  100411. */
  100412. export class BoxBuilder {
  100413. /**
  100414. * Creates a box mesh
  100415. * * The parameter `size` sets the size (float) of each box side (default 1)
  100416. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100417. * * 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)
  100418. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100422. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100423. * @param name defines the name of the mesh
  100424. * @param options defines the options used to create the mesh
  100425. * @param scene defines the hosting scene
  100426. * @returns the box mesh
  100427. */
  100428. static CreateBox(name: string, options: {
  100429. size?: number;
  100430. width?: number;
  100431. height?: number;
  100432. depth?: number;
  100433. faceUV?: Vector4[];
  100434. faceColors?: Color4[];
  100435. sideOrientation?: number;
  100436. frontUVs?: Vector4;
  100437. backUVs?: Vector4;
  100438. wrap?: boolean;
  100439. topBaseAt?: number;
  100440. bottomBaseAt?: number;
  100441. updatable?: boolean;
  100442. }, scene?: Nullable<Scene>): Mesh;
  100443. }
  100444. }
  100445. declare module BABYLON {
  100446. /**
  100447. * Class containing static functions to help procedurally build meshes
  100448. */
  100449. export class SphereBuilder {
  100450. /**
  100451. * Creates a sphere mesh
  100452. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100453. * * 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`)
  100454. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100455. * * 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
  100456. * * 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)
  100457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100460. * @param name defines the name of the mesh
  100461. * @param options defines the options used to create the mesh
  100462. * @param scene defines the hosting scene
  100463. * @returns the sphere mesh
  100464. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100465. */
  100466. static CreateSphere(name: string, options: {
  100467. segments?: number;
  100468. diameter?: number;
  100469. diameterX?: number;
  100470. diameterY?: number;
  100471. diameterZ?: number;
  100472. arc?: number;
  100473. slice?: number;
  100474. sideOrientation?: number;
  100475. frontUVs?: Vector4;
  100476. backUVs?: Vector4;
  100477. updatable?: boolean;
  100478. }, scene: any): Mesh;
  100479. }
  100480. }
  100481. declare module BABYLON.Debug {
  100482. /**
  100483. * Used to show the physics impostor around the specific mesh
  100484. */
  100485. export class PhysicsViewer {
  100486. /** @hidden */
  100487. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100488. /** @hidden */
  100489. protected _meshes: Array<Nullable<AbstractMesh>>;
  100490. /** @hidden */
  100491. protected _scene: Nullable<Scene>;
  100492. /** @hidden */
  100493. protected _numMeshes: number;
  100494. /** @hidden */
  100495. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  100496. private _renderFunction;
  100497. private _utilityLayer;
  100498. private _debugBoxMesh;
  100499. private _debugSphereMesh;
  100500. private _debugCylinderMesh;
  100501. private _debugMaterial;
  100502. private _debugMeshMeshes;
  100503. /**
  100504. * Creates a new PhysicsViewer
  100505. * @param scene defines the hosting scene
  100506. */
  100507. constructor(scene: Scene);
  100508. /** @hidden */
  100509. protected _updateDebugMeshes(): void;
  100510. /**
  100511. * Renders a specified physic impostor
  100512. * @param impostor defines the impostor to render
  100513. * @param targetMesh defines the mesh represented by the impostor
  100514. * @returns the new debug mesh used to render the impostor
  100515. */
  100516. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  100517. /**
  100518. * Hides a specified physic impostor
  100519. * @param impostor defines the impostor to hide
  100520. */
  100521. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  100522. private _getDebugMaterial;
  100523. private _getDebugBoxMesh;
  100524. private _getDebugSphereMesh;
  100525. private _getDebugCylinderMesh;
  100526. private _getDebugMeshMesh;
  100527. private _getDebugMesh;
  100528. /** Releases all resources */
  100529. dispose(): void;
  100530. }
  100531. }
  100532. declare module BABYLON {
  100533. /**
  100534. * Class containing static functions to help procedurally build meshes
  100535. */
  100536. export class LinesBuilder {
  100537. /**
  100538. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  100539. * * 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
  100540. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  100541. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  100542. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  100543. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  100544. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  100545. * * 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
  100546. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  100547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  100549. * @param name defines the name of the new line system
  100550. * @param options defines the options used to create the line system
  100551. * @param scene defines the hosting scene
  100552. * @returns a new line system mesh
  100553. */
  100554. static CreateLineSystem(name: string, options: {
  100555. lines: Vector3[][];
  100556. updatable?: boolean;
  100557. instance?: Nullable<LinesMesh>;
  100558. colors?: Nullable<Color4[][]>;
  100559. useVertexAlpha?: boolean;
  100560. }, scene: Nullable<Scene>): LinesMesh;
  100561. /**
  100562. * Creates a line mesh
  100563. * 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
  100564. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100565. * * The parameter `points` is an array successive Vector3
  100566. * * 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
  100567. * * The optional parameter `colors` is an array of successive Color4, one per line point
  100568. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  100569. * * When updating an instance, remember that only point positions can change, not the number of points
  100570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  100572. * @param name defines the name of the new line system
  100573. * @param options defines the options used to create the line system
  100574. * @param scene defines the hosting scene
  100575. * @returns a new line mesh
  100576. */
  100577. static CreateLines(name: string, options: {
  100578. points: Vector3[];
  100579. updatable?: boolean;
  100580. instance?: Nullable<LinesMesh>;
  100581. colors?: Color4[];
  100582. useVertexAlpha?: boolean;
  100583. }, scene?: Nullable<Scene>): LinesMesh;
  100584. /**
  100585. * Creates a dashed line mesh
  100586. * * 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
  100587. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100588. * * The parameter `points` is an array successive Vector3
  100589. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100590. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100591. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100592. * * 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
  100593. * * When updating an instance, remember that only point positions can change, not the number of points
  100594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100595. * @param name defines the name of the mesh
  100596. * @param options defines the options used to create the mesh
  100597. * @param scene defines the hosting scene
  100598. * @returns the dashed line mesh
  100599. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100600. */
  100601. static CreateDashedLines(name: string, options: {
  100602. points: Vector3[];
  100603. dashSize?: number;
  100604. gapSize?: number;
  100605. dashNb?: number;
  100606. updatable?: boolean;
  100607. instance?: LinesMesh;
  100608. }, scene?: Nullable<Scene>): LinesMesh;
  100609. }
  100610. }
  100611. declare module BABYLON {
  100612. /**
  100613. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100614. * in order to better appreciate the issue one might have.
  100615. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100616. */
  100617. export class RayHelper {
  100618. /**
  100619. * Defines the ray we are currently tryin to visualize.
  100620. */
  100621. ray: Nullable<Ray>;
  100622. private _renderPoints;
  100623. private _renderLine;
  100624. private _renderFunction;
  100625. private _scene;
  100626. private _updateToMeshFunction;
  100627. private _attachedToMesh;
  100628. private _meshSpaceDirection;
  100629. private _meshSpaceOrigin;
  100630. /**
  100631. * Helper function to create a colored helper in a scene in one line.
  100632. * @param ray Defines the ray we are currently tryin to visualize
  100633. * @param scene Defines the scene the ray is used in
  100634. * @param color Defines the color we want to see the ray in
  100635. * @returns The newly created ray helper.
  100636. */
  100637. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100638. /**
  100639. * Instantiate a new ray helper.
  100640. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100641. * in order to better appreciate the issue one might have.
  100642. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100643. * @param ray Defines the ray we are currently tryin to visualize
  100644. */
  100645. constructor(ray: Ray);
  100646. /**
  100647. * Shows the ray we are willing to debug.
  100648. * @param scene Defines the scene the ray needs to be rendered in
  100649. * @param color Defines the color the ray needs to be rendered in
  100650. */
  100651. show(scene: Scene, color?: Color3): void;
  100652. /**
  100653. * Hides the ray we are debugging.
  100654. */
  100655. hide(): void;
  100656. private _render;
  100657. /**
  100658. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100659. * @param mesh Defines the mesh we want the helper attached to
  100660. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100661. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100662. * @param length Defines the length of the ray
  100663. */
  100664. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100665. /**
  100666. * Detach the ray helper from the mesh it has previously been attached to.
  100667. */
  100668. detachFromMesh(): void;
  100669. private _updateToMesh;
  100670. /**
  100671. * Dispose the helper and release its associated resources.
  100672. */
  100673. dispose(): void;
  100674. }
  100675. }
  100676. declare module BABYLON.Debug {
  100677. /**
  100678. * Class used to render a debug view of a given skeleton
  100679. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100680. */
  100681. export class SkeletonViewer {
  100682. /** defines the skeleton to render */
  100683. skeleton: Skeleton;
  100684. /** defines the mesh attached to the skeleton */
  100685. mesh: AbstractMesh;
  100686. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100687. autoUpdateBonesMatrices: boolean;
  100688. /** defines the rendering group id to use with the viewer */
  100689. renderingGroupId: number;
  100690. /** Gets or sets the color used to render the skeleton */
  100691. color: Color3;
  100692. private _scene;
  100693. private _debugLines;
  100694. private _debugMesh;
  100695. private _isEnabled;
  100696. private _renderFunction;
  100697. private _utilityLayer;
  100698. /**
  100699. * Returns the mesh used to render the bones
  100700. */
  100701. readonly debugMesh: Nullable<LinesMesh>;
  100702. /**
  100703. * Creates a new SkeletonViewer
  100704. * @param skeleton defines the skeleton to render
  100705. * @param mesh defines the mesh attached to the skeleton
  100706. * @param scene defines the hosting scene
  100707. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100708. * @param renderingGroupId defines the rendering group id to use with the viewer
  100709. */
  100710. constructor(
  100711. /** defines the skeleton to render */
  100712. skeleton: Skeleton,
  100713. /** defines the mesh attached to the skeleton */
  100714. mesh: AbstractMesh, scene: Scene,
  100715. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100716. autoUpdateBonesMatrices?: boolean,
  100717. /** defines the rendering group id to use with the viewer */
  100718. renderingGroupId?: number);
  100719. /** Gets or sets a boolean indicating if the viewer is enabled */
  100720. isEnabled: boolean;
  100721. private _getBonePosition;
  100722. private _getLinesForBonesWithLength;
  100723. private _getLinesForBonesNoLength;
  100724. /** Update the viewer to sync with current skeleton state */
  100725. update(): void;
  100726. /** Release associated resources */
  100727. dispose(): void;
  100728. }
  100729. }
  100730. declare module BABYLON {
  100731. /**
  100732. * Options to create the null engine
  100733. */
  100734. export class NullEngineOptions {
  100735. /**
  100736. * Render width (Default: 512)
  100737. */
  100738. renderWidth: number;
  100739. /**
  100740. * Render height (Default: 256)
  100741. */
  100742. renderHeight: number;
  100743. /**
  100744. * Texture size (Default: 512)
  100745. */
  100746. textureSize: number;
  100747. /**
  100748. * If delta time between frames should be constant
  100749. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100750. */
  100751. deterministicLockstep: boolean;
  100752. /**
  100753. * Maximum about of steps between frames (Default: 4)
  100754. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100755. */
  100756. lockstepMaxSteps: number;
  100757. }
  100758. /**
  100759. * The null engine class provides support for headless version of babylon.js.
  100760. * This can be used in server side scenario or for testing purposes
  100761. */
  100762. export class NullEngine extends Engine {
  100763. private _options;
  100764. /**
  100765. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100766. */
  100767. isDeterministicLockStep(): boolean;
  100768. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100769. getLockstepMaxSteps(): number;
  100770. /**
  100771. * Sets hardware scaling, used to save performance if needed
  100772. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100773. */
  100774. getHardwareScalingLevel(): number;
  100775. constructor(options?: NullEngineOptions);
  100776. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100777. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  100778. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100779. getRenderWidth(useScreen?: boolean): number;
  100780. getRenderHeight(useScreen?: boolean): number;
  100781. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100782. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100783. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  100784. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  100785. bindSamplers(effect: Effect): void;
  100786. enableEffect(effect: Effect): void;
  100787. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100788. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100789. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100790. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100791. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100792. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100793. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100794. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100795. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100796. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100797. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100798. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100799. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100800. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100801. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100802. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100803. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100804. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100805. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100806. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100807. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100808. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100809. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100810. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100811. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100812. bindBuffers(vertexBuffers: {
  100813. [key: string]: VertexBuffer;
  100814. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  100815. wipeCaches(bruteForce?: boolean): void;
  100816. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100817. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100818. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100819. /** @hidden */
  100820. _createTexture(): WebGLTexture;
  100821. /** @hidden */
  100822. _releaseTexture(texture: InternalTexture): void;
  100823. 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;
  100824. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100825. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100826. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100827. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100828. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100829. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100830. areAllEffectsReady(): boolean;
  100831. /**
  100832. * @hidden
  100833. * Get the current error code of the webGL context
  100834. * @returns the error code
  100835. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100836. */
  100837. getError(): number;
  100838. /** @hidden */
  100839. _getUnpackAlignement(): number;
  100840. /** @hidden */
  100841. _unpackFlipY(value: boolean): void;
  100842. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100843. /**
  100844. * Updates a dynamic vertex buffer.
  100845. * @param vertexBuffer the vertex buffer to update
  100846. * @param data the data used to update the vertex buffer
  100847. * @param byteOffset the byte offset of the data (optional)
  100848. * @param byteLength the byte length of the data (optional)
  100849. */
  100850. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  100851. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  100852. /** @hidden */
  100853. _bindTexture(channel: number, texture: InternalTexture): void;
  100854. /** @hidden */
  100855. _releaseBuffer(buffer: WebGLBuffer): boolean;
  100856. releaseEffects(): void;
  100857. displayLoadingUI(): void;
  100858. hideLoadingUI(): void;
  100859. /** @hidden */
  100860. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100861. /** @hidden */
  100862. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100863. /** @hidden */
  100864. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100865. /** @hidden */
  100866. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  100867. }
  100868. }
  100869. declare module BABYLON {
  100870. /** @hidden */
  100871. export class _OcclusionDataStorage {
  100872. /** @hidden */
  100873. occlusionInternalRetryCounter: number;
  100874. /** @hidden */
  100875. isOcclusionQueryInProgress: boolean;
  100876. /** @hidden */
  100877. isOccluded: boolean;
  100878. /** @hidden */
  100879. occlusionRetryCount: number;
  100880. /** @hidden */
  100881. occlusionType: number;
  100882. /** @hidden */
  100883. occlusionQueryAlgorithmType: number;
  100884. }
  100885. interface Engine {
  100886. /**
  100887. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  100888. * @return the new query
  100889. */
  100890. createQuery(): WebGLQuery;
  100891. /**
  100892. * Delete and release a webGL query
  100893. * @param query defines the query to delete
  100894. * @return the current engine
  100895. */
  100896. deleteQuery(query: WebGLQuery): Engine;
  100897. /**
  100898. * Check if a given query has resolved and got its value
  100899. * @param query defines the query to check
  100900. * @returns true if the query got its value
  100901. */
  100902. isQueryResultAvailable(query: WebGLQuery): boolean;
  100903. /**
  100904. * Gets the value of a given query
  100905. * @param query defines the query to check
  100906. * @returns the value of the query
  100907. */
  100908. getQueryResult(query: WebGLQuery): number;
  100909. /**
  100910. * Initiates an occlusion query
  100911. * @param algorithmType defines the algorithm to use
  100912. * @param query defines the query to use
  100913. * @returns the current engine
  100914. * @see http://doc.babylonjs.com/features/occlusionquery
  100915. */
  100916. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  100917. /**
  100918. * Ends an occlusion query
  100919. * @see http://doc.babylonjs.com/features/occlusionquery
  100920. * @param algorithmType defines the algorithm to use
  100921. * @returns the current engine
  100922. */
  100923. endOcclusionQuery(algorithmType: number): Engine;
  100924. /**
  100925. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  100926. * Please note that only one query can be issued at a time
  100927. * @returns a time token used to track the time span
  100928. */
  100929. startTimeQuery(): Nullable<_TimeToken>;
  100930. /**
  100931. * Ends a time query
  100932. * @param token defines the token used to measure the time span
  100933. * @returns the time spent (in ns)
  100934. */
  100935. endTimeQuery(token: _TimeToken): int;
  100936. /** @hidden */
  100937. _currentNonTimestampToken: Nullable<_TimeToken>;
  100938. /** @hidden */
  100939. _createTimeQuery(): WebGLQuery;
  100940. /** @hidden */
  100941. _deleteTimeQuery(query: WebGLQuery): void;
  100942. /** @hidden */
  100943. _getGlAlgorithmType(algorithmType: number): number;
  100944. /** @hidden */
  100945. _getTimeQueryResult(query: WebGLQuery): any;
  100946. /** @hidden */
  100947. _getTimeQueryAvailability(query: WebGLQuery): any;
  100948. }
  100949. interface AbstractMesh {
  100950. /**
  100951. * Backing filed
  100952. * @hidden
  100953. */
  100954. __occlusionDataStorage: _OcclusionDataStorage;
  100955. /**
  100956. * Access property
  100957. * @hidden
  100958. */
  100959. _occlusionDataStorage: _OcclusionDataStorage;
  100960. /**
  100961. * 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.
  100962. * The default value is -1 which means don't break the query and wait till the result
  100963. * @see http://doc.babylonjs.com/features/occlusionquery
  100964. */
  100965. occlusionRetryCount: number;
  100966. /**
  100967. * 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:
  100968. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  100969. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  100970. * * 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.
  100971. * @see http://doc.babylonjs.com/features/occlusionquery
  100972. */
  100973. occlusionType: number;
  100974. /**
  100975. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  100976. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  100977. * * 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.
  100978. * @see http://doc.babylonjs.com/features/occlusionquery
  100979. */
  100980. occlusionQueryAlgorithmType: number;
  100981. /**
  100982. * 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
  100983. * @see http://doc.babylonjs.com/features/occlusionquery
  100984. */
  100985. isOccluded: boolean;
  100986. /**
  100987. * Flag to check the progress status of the query
  100988. * @see http://doc.babylonjs.com/features/occlusionquery
  100989. */
  100990. isOcclusionQueryInProgress: boolean;
  100991. }
  100992. }
  100993. declare module BABYLON {
  100994. /** @hidden */
  100995. export var _forceTransformFeedbackToBundle: boolean;
  100996. interface Engine {
  100997. /**
  100998. * Creates a webGL transform feedback object
  100999. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101000. * @returns the webGL transform feedback object
  101001. */
  101002. createTransformFeedback(): WebGLTransformFeedback;
  101003. /**
  101004. * Delete a webGL transform feedback object
  101005. * @param value defines the webGL transform feedback object to delete
  101006. */
  101007. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101008. /**
  101009. * Bind a webGL transform feedback object to the webgl context
  101010. * @param value defines the webGL transform feedback object to bind
  101011. */
  101012. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101013. /**
  101014. * Begins a transform feedback operation
  101015. * @param usePoints defines if points or triangles must be used
  101016. */
  101017. beginTransformFeedback(usePoints: boolean): void;
  101018. /**
  101019. * Ends a transform feedback operation
  101020. */
  101021. endTransformFeedback(): void;
  101022. /**
  101023. * Specify the varyings to use with transform feedback
  101024. * @param program defines the associated webGL program
  101025. * @param value defines the list of strings representing the varying names
  101026. */
  101027. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101028. /**
  101029. * Bind a webGL buffer for a transform feedback operation
  101030. * @param value defines the webGL buffer to bind
  101031. */
  101032. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  101033. }
  101034. }
  101035. declare module BABYLON {
  101036. /**
  101037. * Creation options of the multi render target texture.
  101038. */
  101039. export interface IMultiRenderTargetOptions {
  101040. /**
  101041. * Define if the texture needs to create mip maps after render.
  101042. */
  101043. generateMipMaps?: boolean;
  101044. /**
  101045. * Define the types of all the draw buffers we want to create
  101046. */
  101047. types?: number[];
  101048. /**
  101049. * Define the sampling modes of all the draw buffers we want to create
  101050. */
  101051. samplingModes?: number[];
  101052. /**
  101053. * Define if a depth buffer is required
  101054. */
  101055. generateDepthBuffer?: boolean;
  101056. /**
  101057. * Define if a stencil buffer is required
  101058. */
  101059. generateStencilBuffer?: boolean;
  101060. /**
  101061. * Define if a depth texture is required instead of a depth buffer
  101062. */
  101063. generateDepthTexture?: boolean;
  101064. /**
  101065. * Define the number of desired draw buffers
  101066. */
  101067. textureCount?: number;
  101068. /**
  101069. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101070. */
  101071. doNotChangeAspectRatio?: boolean;
  101072. /**
  101073. * Define the default type of the buffers we are creating
  101074. */
  101075. defaultType?: number;
  101076. }
  101077. /**
  101078. * A multi render target, like a render target provides the ability to render to a texture.
  101079. * Unlike the render target, it can render to several draw buffers in one draw.
  101080. * This is specially interesting in deferred rendering or for any effects requiring more than
  101081. * just one color from a single pass.
  101082. */
  101083. export class MultiRenderTarget extends RenderTargetTexture {
  101084. private _internalTextures;
  101085. private _textures;
  101086. private _multiRenderTargetOptions;
  101087. /**
  101088. * Get if draw buffers are currently supported by the used hardware and browser.
  101089. */
  101090. readonly isSupported: boolean;
  101091. /**
  101092. * Get the list of textures generated by the multi render target.
  101093. */
  101094. readonly textures: Texture[];
  101095. /**
  101096. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101097. */
  101098. readonly depthTexture: Texture;
  101099. /**
  101100. * Set the wrapping mode on U of all the textures we are rendering to.
  101101. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101102. */
  101103. wrapU: number;
  101104. /**
  101105. * Set the wrapping mode on V of all the textures we are rendering to.
  101106. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101107. */
  101108. wrapV: number;
  101109. /**
  101110. * Instantiate a new multi render target texture.
  101111. * A multi render target, like a render target provides the ability to render to a texture.
  101112. * Unlike the render target, it can render to several draw buffers in one draw.
  101113. * This is specially interesting in deferred rendering or for any effects requiring more than
  101114. * just one color from a single pass.
  101115. * @param name Define the name of the texture
  101116. * @param size Define the size of the buffers to render to
  101117. * @param count Define the number of target we are rendering into
  101118. * @param scene Define the scene the texture belongs to
  101119. * @param options Define the options used to create the multi render target
  101120. */
  101121. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101122. /** @hidden */
  101123. _rebuild(): void;
  101124. private _createInternalTextures;
  101125. private _createTextures;
  101126. /**
  101127. * Define the number of samples used if MSAA is enabled.
  101128. */
  101129. samples: number;
  101130. /**
  101131. * Resize all the textures in the multi render target.
  101132. * Be carrefull as it will recreate all the data in the new texture.
  101133. * @param size Define the new size
  101134. */
  101135. resize(size: any): void;
  101136. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101137. /**
  101138. * Dispose the render targets and their associated resources
  101139. */
  101140. dispose(): void;
  101141. /**
  101142. * Release all the underlying texture used as draw buffers.
  101143. */
  101144. releaseInternalTextures(): void;
  101145. }
  101146. }
  101147. declare module BABYLON {
  101148. interface Engine {
  101149. /**
  101150. * Unbind a list of render target textures from the webGL context
  101151. * This is used only when drawBuffer extension or webGL2 are active
  101152. * @param textures defines the render target textures to unbind
  101153. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101154. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101155. */
  101156. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101157. /**
  101158. * Create a multi render target texture
  101159. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101160. * @param size defines the size of the texture
  101161. * @param options defines the creation options
  101162. * @returns the cube texture as an InternalTexture
  101163. */
  101164. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101165. /**
  101166. * Update the sample count for a given multiple render target texture
  101167. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101168. * @param textures defines the textures to update
  101169. * @param samples defines the sample count to set
  101170. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101171. */
  101172. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101173. }
  101174. }
  101175. declare module BABYLON {
  101176. /**
  101177. * Gather the list of clipboard event types as constants.
  101178. */
  101179. export class ClipboardEventTypes {
  101180. /**
  101181. * The clipboard event is fired when a copy command is active (pressed).
  101182. */
  101183. static readonly COPY: number;
  101184. /**
  101185. * The clipboard event is fired when a cut command is active (pressed).
  101186. */
  101187. static readonly CUT: number;
  101188. /**
  101189. * The clipboard event is fired when a paste command is active (pressed).
  101190. */
  101191. static readonly PASTE: number;
  101192. }
  101193. /**
  101194. * This class is used to store clipboard related info for the onClipboardObservable event.
  101195. */
  101196. export class ClipboardInfo {
  101197. /**
  101198. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101199. */
  101200. type: number;
  101201. /**
  101202. * Defines the related dom event
  101203. */
  101204. event: ClipboardEvent;
  101205. /**
  101206. *Creates an instance of ClipboardInfo.
  101207. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101208. * @param event Defines the related dom event
  101209. */
  101210. constructor(
  101211. /**
  101212. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101213. */
  101214. type: number,
  101215. /**
  101216. * Defines the related dom event
  101217. */
  101218. event: ClipboardEvent);
  101219. /**
  101220. * Get the clipboard event's type from the keycode.
  101221. * @param keyCode Defines the keyCode for the current keyboard event.
  101222. * @return {number}
  101223. */
  101224. static GetTypeFromCharacter(keyCode: number): number;
  101225. }
  101226. }
  101227. declare module BABYLON {
  101228. /**
  101229. * Class used to represent data loading progression
  101230. */
  101231. export class SceneLoaderProgressEvent {
  101232. /** defines if data length to load can be evaluated */
  101233. readonly lengthComputable: boolean;
  101234. /** defines the loaded data length */
  101235. readonly loaded: number;
  101236. /** defines the data length to load */
  101237. readonly total: number;
  101238. /**
  101239. * Create a new progress event
  101240. * @param lengthComputable defines if data length to load can be evaluated
  101241. * @param loaded defines the loaded data length
  101242. * @param total defines the data length to load
  101243. */
  101244. constructor(
  101245. /** defines if data length to load can be evaluated */
  101246. lengthComputable: boolean,
  101247. /** defines the loaded data length */
  101248. loaded: number,
  101249. /** defines the data length to load */
  101250. total: number);
  101251. /**
  101252. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101253. * @param event defines the source event
  101254. * @returns a new SceneLoaderProgressEvent
  101255. */
  101256. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101257. }
  101258. /**
  101259. * Interface used by SceneLoader plugins to define supported file extensions
  101260. */
  101261. export interface ISceneLoaderPluginExtensions {
  101262. /**
  101263. * Defines the list of supported extensions
  101264. */
  101265. [extension: string]: {
  101266. isBinary: boolean;
  101267. };
  101268. }
  101269. /**
  101270. * Interface used by SceneLoader plugin factory
  101271. */
  101272. export interface ISceneLoaderPluginFactory {
  101273. /**
  101274. * Defines the name of the factory
  101275. */
  101276. name: string;
  101277. /**
  101278. * Function called to create a new plugin
  101279. * @return the new plugin
  101280. */
  101281. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101282. /**
  101283. * Boolean indicating if the plugin can direct load specific data
  101284. */
  101285. canDirectLoad?: (data: string) => boolean;
  101286. }
  101287. /**
  101288. * Interface used to define a SceneLoader plugin
  101289. */
  101290. export interface ISceneLoaderPlugin {
  101291. /**
  101292. * The friendly name of this plugin.
  101293. */
  101294. name: string;
  101295. /**
  101296. * The file extensions supported by this plugin.
  101297. */
  101298. extensions: string | ISceneLoaderPluginExtensions;
  101299. /**
  101300. * Import meshes into a scene.
  101301. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101302. * @param scene The scene to import into
  101303. * @param data The data to import
  101304. * @param rootUrl The root url for scene and resources
  101305. * @param meshes The meshes array to import into
  101306. * @param particleSystems The particle systems array to import into
  101307. * @param skeletons The skeletons array to import into
  101308. * @param onError The callback when import fails
  101309. * @returns True if successful or false otherwise
  101310. */
  101311. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101312. /**
  101313. * Load into a scene.
  101314. * @param scene The scene to load into
  101315. * @param data The data to import
  101316. * @param rootUrl The root url for scene and resources
  101317. * @param onError The callback when import fails
  101318. * @returns true if successful or false otherwise
  101319. */
  101320. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101321. /**
  101322. * The callback that returns true if the data can be directly loaded.
  101323. */
  101324. canDirectLoad?: (data: string) => boolean;
  101325. /**
  101326. * The callback that allows custom handling of the root url based on the response url.
  101327. */
  101328. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101329. /**
  101330. * Load into an asset container.
  101331. * @param scene The scene to load into
  101332. * @param data The data to import
  101333. * @param rootUrl The root url for scene and resources
  101334. * @param onError The callback when import fails
  101335. * @returns The loaded asset container
  101336. */
  101337. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101338. }
  101339. /**
  101340. * Interface used to define an async SceneLoader plugin
  101341. */
  101342. export interface ISceneLoaderPluginAsync {
  101343. /**
  101344. * The friendly name of this plugin.
  101345. */
  101346. name: string;
  101347. /**
  101348. * The file extensions supported by this plugin.
  101349. */
  101350. extensions: string | ISceneLoaderPluginExtensions;
  101351. /**
  101352. * Import meshes into a scene.
  101353. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101354. * @param scene The scene to import into
  101355. * @param data The data to import
  101356. * @param rootUrl The root url for scene and resources
  101357. * @param onProgress The callback when the load progresses
  101358. * @param fileName Defines the name of the file to load
  101359. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101360. */
  101361. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101362. meshes: AbstractMesh[];
  101363. particleSystems: IParticleSystem[];
  101364. skeletons: Skeleton[];
  101365. animationGroups: AnimationGroup[];
  101366. }>;
  101367. /**
  101368. * Load into a scene.
  101369. * @param scene The scene to load into
  101370. * @param data The data to import
  101371. * @param rootUrl The root url for scene and resources
  101372. * @param onProgress The callback when the load progresses
  101373. * @param fileName Defines the name of the file to load
  101374. * @returns Nothing
  101375. */
  101376. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101377. /**
  101378. * The callback that returns true if the data can be directly loaded.
  101379. */
  101380. canDirectLoad?: (data: string) => boolean;
  101381. /**
  101382. * The callback that allows custom handling of the root url based on the response url.
  101383. */
  101384. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101385. /**
  101386. * Load into an asset container.
  101387. * @param scene The scene to load into
  101388. * @param data The data to import
  101389. * @param rootUrl The root url for scene and resources
  101390. * @param onProgress The callback when the load progresses
  101391. * @param fileName Defines the name of the file to load
  101392. * @returns The loaded asset container
  101393. */
  101394. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101395. }
  101396. /**
  101397. * Class used to load scene from various file formats using registered plugins
  101398. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101399. */
  101400. export class SceneLoader {
  101401. /**
  101402. * No logging while loading
  101403. */
  101404. static readonly NO_LOGGING: number;
  101405. /**
  101406. * Minimal logging while loading
  101407. */
  101408. static readonly MINIMAL_LOGGING: number;
  101409. /**
  101410. * Summary logging while loading
  101411. */
  101412. static readonly SUMMARY_LOGGING: number;
  101413. /**
  101414. * Detailled logging while loading
  101415. */
  101416. static readonly DETAILED_LOGGING: number;
  101417. /**
  101418. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101419. */
  101420. static ForceFullSceneLoadingForIncremental: boolean;
  101421. /**
  101422. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101423. */
  101424. static ShowLoadingScreen: boolean;
  101425. /**
  101426. * Defines the current logging level (while loading the scene)
  101427. * @ignorenaming
  101428. */
  101429. static loggingLevel: number;
  101430. /**
  101431. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101432. */
  101433. static CleanBoneMatrixWeights: boolean;
  101434. /**
  101435. * Event raised when a plugin is used to load a scene
  101436. */
  101437. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101438. private static _registeredPlugins;
  101439. private static _getDefaultPlugin;
  101440. private static _getPluginForExtension;
  101441. private static _getPluginForDirectLoad;
  101442. private static _getPluginForFilename;
  101443. private static _getDirectLoad;
  101444. private static _loadData;
  101445. private static _getFileInfo;
  101446. /**
  101447. * Gets a plugin that can load the given extension
  101448. * @param extension defines the extension to load
  101449. * @returns a plugin or null if none works
  101450. */
  101451. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101452. /**
  101453. * Gets a boolean indicating that the given extension can be loaded
  101454. * @param extension defines the extension to load
  101455. * @returns true if the extension is supported
  101456. */
  101457. static IsPluginForExtensionAvailable(extension: string): boolean;
  101458. /**
  101459. * Adds a new plugin to the list of registered plugins
  101460. * @param plugin defines the plugin to add
  101461. */
  101462. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101463. /**
  101464. * Import meshes into a scene
  101465. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101466. * @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)
  101467. * @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)
  101468. * @param scene the instance of BABYLON.Scene to append to
  101469. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101470. * @param onProgress a callback with a progress event for each file being loaded
  101471. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101472. * @param pluginExtension the extension used to determine the plugin
  101473. * @returns The loaded plugin
  101474. */
  101475. 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>;
  101476. /**
  101477. * Import meshes into a scene
  101478. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101479. * @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)
  101480. * @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)
  101481. * @param scene the instance of BABYLON.Scene to append to
  101482. * @param onProgress a callback with a progress event for each file being loaded
  101483. * @param pluginExtension the extension used to determine the plugin
  101484. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101485. */
  101486. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101487. meshes: AbstractMesh[];
  101488. particleSystems: IParticleSystem[];
  101489. skeletons: Skeleton[];
  101490. animationGroups: AnimationGroup[];
  101491. }>;
  101492. /**
  101493. * Load a scene
  101494. * @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)
  101495. * @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)
  101496. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101497. * @param onSuccess a callback with the scene when import succeeds
  101498. * @param onProgress a callback with a progress event for each file being loaded
  101499. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101500. * @param pluginExtension the extension used to determine the plugin
  101501. * @returns The loaded plugin
  101502. */
  101503. 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>;
  101504. /**
  101505. * Load a scene
  101506. * @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)
  101507. * @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)
  101508. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101509. * @param onProgress a callback with a progress event for each file being loaded
  101510. * @param pluginExtension the extension used to determine the plugin
  101511. * @returns The loaded scene
  101512. */
  101513. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101514. /**
  101515. * Append a scene
  101516. * @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)
  101517. * @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)
  101518. * @param scene is the instance of BABYLON.Scene to append to
  101519. * @param onSuccess a callback with the scene when import succeeds
  101520. * @param onProgress a callback with a progress event for each file being loaded
  101521. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101522. * @param pluginExtension the extension used to determine the plugin
  101523. * @returns The loaded plugin
  101524. */
  101525. 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>;
  101526. /**
  101527. * Append a scene
  101528. * @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)
  101529. * @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)
  101530. * @param scene is the instance of BABYLON.Scene to append to
  101531. * @param onProgress a callback with a progress event for each file being loaded
  101532. * @param pluginExtension the extension used to determine the plugin
  101533. * @returns The given scene
  101534. */
  101535. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101536. /**
  101537. * Load a scene into an asset container
  101538. * @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)
  101539. * @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)
  101540. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  101541. * @param onSuccess a callback with the scene when import succeeds
  101542. * @param onProgress a callback with a progress event for each file being loaded
  101543. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101544. * @param pluginExtension the extension used to determine the plugin
  101545. * @returns The loaded plugin
  101546. */
  101547. 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>;
  101548. /**
  101549. * Load a scene into an asset container
  101550. * @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)
  101551. * @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)
  101552. * @param scene is the instance of Scene to append to
  101553. * @param onProgress a callback with a progress event for each file being loaded
  101554. * @param pluginExtension the extension used to determine the plugin
  101555. * @returns The loaded asset container
  101556. */
  101557. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  101558. }
  101559. }
  101560. declare module BABYLON {
  101561. /**
  101562. * Google Daydream controller
  101563. */
  101564. export class DaydreamController extends WebVRController {
  101565. /**
  101566. * Base Url for the controller model.
  101567. */
  101568. static MODEL_BASE_URL: string;
  101569. /**
  101570. * File name for the controller model.
  101571. */
  101572. static MODEL_FILENAME: string;
  101573. /**
  101574. * Gamepad Id prefix used to identify Daydream Controller.
  101575. */
  101576. static readonly GAMEPAD_ID_PREFIX: string;
  101577. /**
  101578. * Creates a new DaydreamController from a gamepad
  101579. * @param vrGamepad the gamepad that the controller should be created from
  101580. */
  101581. constructor(vrGamepad: any);
  101582. /**
  101583. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101584. * @param scene scene in which to add meshes
  101585. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101586. */
  101587. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101588. /**
  101589. * Called once for each button that changed state since the last frame
  101590. * @param buttonIdx Which button index changed
  101591. * @param state New state of the button
  101592. * @param changes Which properties on the state changed since last frame
  101593. */
  101594. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101595. }
  101596. }
  101597. declare module BABYLON {
  101598. /**
  101599. * Gear VR Controller
  101600. */
  101601. export class GearVRController extends WebVRController {
  101602. /**
  101603. * Base Url for the controller model.
  101604. */
  101605. static MODEL_BASE_URL: string;
  101606. /**
  101607. * File name for the controller model.
  101608. */
  101609. static MODEL_FILENAME: string;
  101610. /**
  101611. * Gamepad Id prefix used to identify this controller.
  101612. */
  101613. static readonly GAMEPAD_ID_PREFIX: string;
  101614. private readonly _buttonIndexToObservableNameMap;
  101615. /**
  101616. * Creates a new GearVRController 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. * Called once for each button that changed state since the last frame
  101628. * @param buttonIdx Which button index changed
  101629. * @param state New state of the button
  101630. * @param changes Which properties on the state changed since last frame
  101631. */
  101632. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101633. }
  101634. }
  101635. declare module BABYLON {
  101636. /**
  101637. * Generic Controller
  101638. */
  101639. export class GenericController extends WebVRController {
  101640. /**
  101641. * Base Url for the controller model.
  101642. */
  101643. static readonly MODEL_BASE_URL: string;
  101644. /**
  101645. * File name for the controller model.
  101646. */
  101647. static readonly MODEL_FILENAME: string;
  101648. /**
  101649. * Creates a new GenericController from a gamepad
  101650. * @param vrGamepad the gamepad that the controller should be created from
  101651. */
  101652. constructor(vrGamepad: any);
  101653. /**
  101654. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101655. * @param scene scene in which to add meshes
  101656. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101657. */
  101658. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101659. /**
  101660. * Called once for each button that changed state since the last frame
  101661. * @param buttonIdx Which button index changed
  101662. * @param state New state of the button
  101663. * @param changes Which properties on the state changed since last frame
  101664. */
  101665. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101666. }
  101667. }
  101668. declare module BABYLON {
  101669. /**
  101670. * Oculus Touch Controller
  101671. */
  101672. export class OculusTouchController extends WebVRController {
  101673. /**
  101674. * Base Url for the controller model.
  101675. */
  101676. static MODEL_BASE_URL: string;
  101677. /**
  101678. * File name for the left controller model.
  101679. */
  101680. static MODEL_LEFT_FILENAME: string;
  101681. /**
  101682. * File name for the right controller model.
  101683. */
  101684. static MODEL_RIGHT_FILENAME: string;
  101685. /**
  101686. * Fired when the secondary trigger on this controller is modified
  101687. */
  101688. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101689. /**
  101690. * Fired when the thumb rest on this controller is modified
  101691. */
  101692. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  101693. /**
  101694. * Creates a new OculusTouchController from a gamepad
  101695. * @param vrGamepad the gamepad that the controller should be created from
  101696. */
  101697. constructor(vrGamepad: any);
  101698. /**
  101699. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101700. * @param scene scene in which to add meshes
  101701. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101702. */
  101703. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101704. /**
  101705. * Fired when the A button on this controller is modified
  101706. */
  101707. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101708. /**
  101709. * Fired when the B button on this controller is modified
  101710. */
  101711. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101712. /**
  101713. * Fired when the X button on this controller is modified
  101714. */
  101715. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101716. /**
  101717. * Fired when the Y button on this controller is modified
  101718. */
  101719. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101720. /**
  101721. * Called once for each button that changed state since the last frame
  101722. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101723. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101724. * 2) secondary trigger (same)
  101725. * 3) A (right) X (left), touch, pressed = value
  101726. * 4) B / Y
  101727. * 5) thumb rest
  101728. * @param buttonIdx Which button index changed
  101729. * @param state New state of the button
  101730. * @param changes Which properties on the state changed since last frame
  101731. */
  101732. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101733. }
  101734. }
  101735. declare module BABYLON {
  101736. /**
  101737. * Vive Controller
  101738. */
  101739. export class ViveController extends WebVRController {
  101740. /**
  101741. * Base Url for the controller model.
  101742. */
  101743. static MODEL_BASE_URL: string;
  101744. /**
  101745. * File name for the controller model.
  101746. */
  101747. static MODEL_FILENAME: string;
  101748. /**
  101749. * Creates a new ViveController from a gamepad
  101750. * @param vrGamepad the gamepad that the controller should be created from
  101751. */
  101752. constructor(vrGamepad: any);
  101753. /**
  101754. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101755. * @param scene scene in which to add meshes
  101756. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101757. */
  101758. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101759. /**
  101760. * Fired when the left button on this controller is modified
  101761. */
  101762. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101763. /**
  101764. * Fired when the right button on this controller is modified
  101765. */
  101766. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101767. /**
  101768. * Fired when the menu button on this controller is modified
  101769. */
  101770. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101771. /**
  101772. * Called once for each button that changed state since the last frame
  101773. * Vive mapping:
  101774. * 0: touchpad
  101775. * 1: trigger
  101776. * 2: left AND right buttons
  101777. * 3: menu button
  101778. * @param buttonIdx Which button index changed
  101779. * @param state New state of the button
  101780. * @param changes Which properties on the state changed since last frame
  101781. */
  101782. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101783. }
  101784. }
  101785. declare module BABYLON {
  101786. /**
  101787. * Defines the WindowsMotionController object that the state of the windows motion controller
  101788. */
  101789. export class WindowsMotionController extends WebVRController {
  101790. /**
  101791. * The base url used to load the left and right controller models
  101792. */
  101793. static MODEL_BASE_URL: string;
  101794. /**
  101795. * The name of the left controller model file
  101796. */
  101797. static MODEL_LEFT_FILENAME: string;
  101798. /**
  101799. * The name of the right controller model file
  101800. */
  101801. static MODEL_RIGHT_FILENAME: string;
  101802. /**
  101803. * The controller name prefix for this controller type
  101804. */
  101805. static readonly GAMEPAD_ID_PREFIX: string;
  101806. /**
  101807. * The controller id pattern for this controller type
  101808. */
  101809. private static readonly GAMEPAD_ID_PATTERN;
  101810. private _loadedMeshInfo;
  101811. private readonly _mapping;
  101812. /**
  101813. * Fired when the trackpad on this controller is clicked
  101814. */
  101815. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101816. /**
  101817. * Fired when the trackpad on this controller is modified
  101818. */
  101819. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101820. /**
  101821. * The current x and y values of this controller's trackpad
  101822. */
  101823. trackpad: StickValues;
  101824. /**
  101825. * Creates a new WindowsMotionController from a gamepad
  101826. * @param vrGamepad the gamepad that the controller should be created from
  101827. */
  101828. constructor(vrGamepad: any);
  101829. /**
  101830. * Fired when the trigger on this controller is modified
  101831. */
  101832. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101833. /**
  101834. * Fired when the menu button on this controller is modified
  101835. */
  101836. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101837. /**
  101838. * Fired when the grip button on this controller is modified
  101839. */
  101840. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101841. /**
  101842. * Fired when the thumbstick button on this controller is modified
  101843. */
  101844. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101845. /**
  101846. * Fired when the touchpad button on this controller is modified
  101847. */
  101848. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101849. /**
  101850. * Fired when the touchpad values on this controller are modified
  101851. */
  101852. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  101853. private _updateTrackpad;
  101854. /**
  101855. * Called once per frame by the engine.
  101856. */
  101857. update(): void;
  101858. /**
  101859. * Called once for each button that changed state since the last frame
  101860. * @param buttonIdx Which button index changed
  101861. * @param state New state of the button
  101862. * @param changes Which properties on the state changed since last frame
  101863. */
  101864. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101865. /**
  101866. * Moves the buttons on the controller mesh based on their current state
  101867. * @param buttonName the name of the button to move
  101868. * @param buttonValue the value of the button which determines the buttons new position
  101869. */
  101870. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  101871. /**
  101872. * Moves the axis on the controller mesh based on its current state
  101873. * @param axis the index of the axis
  101874. * @param axisValue the value of the axis which determines the meshes new position
  101875. * @hidden
  101876. */
  101877. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  101878. /**
  101879. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101880. * @param scene scene in which to add meshes
  101881. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101882. */
  101883. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  101884. /**
  101885. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  101886. * can be transformed by button presses and axes values, based on this._mapping.
  101887. *
  101888. * @param scene scene in which the meshes exist
  101889. * @param meshes list of meshes that make up the controller model to process
  101890. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  101891. */
  101892. private processModel;
  101893. private createMeshInfo;
  101894. /**
  101895. * Gets the ray of the controller in the direction the controller is pointing
  101896. * @param length the length the resulting ray should be
  101897. * @returns a ray in the direction the controller is pointing
  101898. */
  101899. getForwardRay(length?: number): Ray;
  101900. /**
  101901. * Disposes of the controller
  101902. */
  101903. dispose(): void;
  101904. }
  101905. }
  101906. declare module BABYLON {
  101907. /**
  101908. * Single axis scale gizmo
  101909. */
  101910. export class AxisScaleGizmo extends Gizmo {
  101911. private _coloredMaterial;
  101912. /**
  101913. * Drag behavior responsible for the gizmos dragging interactions
  101914. */
  101915. dragBehavior: PointerDragBehavior;
  101916. private _pointerObserver;
  101917. /**
  101918. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101919. */
  101920. snapDistance: number;
  101921. /**
  101922. * Event that fires each time the gizmo snaps to a new location.
  101923. * * snapDistance is the the change in distance
  101924. */
  101925. onSnapObservable: Observable<{
  101926. snapDistance: number;
  101927. }>;
  101928. /**
  101929. * If the scaling operation should be done on all axis (default: false)
  101930. */
  101931. uniformScaling: boolean;
  101932. /**
  101933. * Creates an AxisScaleGizmo
  101934. * @param gizmoLayer The utility layer the gizmo will be added to
  101935. * @param dragAxis The axis which the gizmo will be able to scale on
  101936. * @param color The color of the gizmo
  101937. */
  101938. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101939. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101940. /**
  101941. * Disposes of the gizmo
  101942. */
  101943. dispose(): void;
  101944. /**
  101945. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  101946. * @param mesh The mesh to replace the default mesh of the gizmo
  101947. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  101948. */
  101949. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  101950. }
  101951. }
  101952. declare module BABYLON {
  101953. /**
  101954. * Bounding box gizmo
  101955. */
  101956. export class BoundingBoxGizmo extends Gizmo {
  101957. private _lineBoundingBox;
  101958. private _rotateSpheresParent;
  101959. private _scaleBoxesParent;
  101960. private _boundingDimensions;
  101961. private _renderObserver;
  101962. private _pointerObserver;
  101963. private _scaleDragSpeed;
  101964. private _tmpQuaternion;
  101965. private _tmpVector;
  101966. private _tmpRotationMatrix;
  101967. /**
  101968. * 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)
  101969. */
  101970. ignoreChildren: boolean;
  101971. /**
  101972. * 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)
  101973. */
  101974. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  101975. /**
  101976. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  101977. */
  101978. rotationSphereSize: number;
  101979. /**
  101980. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  101981. */
  101982. scaleBoxSize: number;
  101983. /**
  101984. * 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)
  101985. */
  101986. fixedDragMeshScreenSize: boolean;
  101987. /**
  101988. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  101989. */
  101990. fixedDragMeshScreenSizeDistanceFactor: number;
  101991. /**
  101992. * Fired when a rotation sphere or scale box is dragged
  101993. */
  101994. onDragStartObservable: Observable<{}>;
  101995. /**
  101996. * Fired when a scale box is dragged
  101997. */
  101998. onScaleBoxDragObservable: Observable<{}>;
  101999. /**
  102000. * Fired when a scale box drag is ended
  102001. */
  102002. onScaleBoxDragEndObservable: Observable<{}>;
  102003. /**
  102004. * Fired when a rotation sphere is dragged
  102005. */
  102006. onRotationSphereDragObservable: Observable<{}>;
  102007. /**
  102008. * Fired when a rotation sphere drag is ended
  102009. */
  102010. onRotationSphereDragEndObservable: Observable<{}>;
  102011. /**
  102012. * 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)
  102013. */
  102014. scalePivot: Nullable<Vector3>;
  102015. /**
  102016. * Mesh used as a pivot to rotate the attached mesh
  102017. */
  102018. private _anchorMesh;
  102019. private _existingMeshScale;
  102020. private _dragMesh;
  102021. private pointerDragBehavior;
  102022. private coloredMaterial;
  102023. private hoverColoredMaterial;
  102024. /**
  102025. * Sets the color of the bounding box gizmo
  102026. * @param color the color to set
  102027. */
  102028. setColor(color: Color3): void;
  102029. /**
  102030. * Creates an BoundingBoxGizmo
  102031. * @param gizmoLayer The utility layer the gizmo will be added to
  102032. * @param color The color of the gizmo
  102033. */
  102034. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102035. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102036. private _selectNode;
  102037. /**
  102038. * Updates the bounding box information for the Gizmo
  102039. */
  102040. updateBoundingBox(): void;
  102041. private _updateRotationSpheres;
  102042. private _updateScaleBoxes;
  102043. /**
  102044. * Enables rotation on the specified axis and disables rotation on the others
  102045. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102046. */
  102047. setEnabledRotationAxis(axis: string): void;
  102048. /**
  102049. * Enables/disables scaling
  102050. * @param enable if scaling should be enabled
  102051. */
  102052. setEnabledScaling(enable: boolean): void;
  102053. private _updateDummy;
  102054. /**
  102055. * Enables a pointer drag behavior on the bounding box of the gizmo
  102056. */
  102057. enableDragBehavior(): void;
  102058. /**
  102059. * Disposes of the gizmo
  102060. */
  102061. dispose(): void;
  102062. /**
  102063. * 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)
  102064. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102065. * @returns the bounding box mesh with the passed in mesh as a child
  102066. */
  102067. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102068. /**
  102069. * CustomMeshes are not supported by this gizmo
  102070. * @param mesh The mesh to replace the default mesh of the gizmo
  102071. */
  102072. setCustomMesh(mesh: Mesh): void;
  102073. }
  102074. }
  102075. declare module BABYLON {
  102076. /**
  102077. * Single plane rotation gizmo
  102078. */
  102079. export class PlaneRotationGizmo extends Gizmo {
  102080. /**
  102081. * Drag behavior responsible for the gizmos dragging interactions
  102082. */
  102083. dragBehavior: PointerDragBehavior;
  102084. private _pointerObserver;
  102085. /**
  102086. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102087. */
  102088. snapDistance: number;
  102089. /**
  102090. * Event that fires each time the gizmo snaps to a new location.
  102091. * * snapDistance is the the change in distance
  102092. */
  102093. onSnapObservable: Observable<{
  102094. snapDistance: number;
  102095. }>;
  102096. /**
  102097. * Creates a PlaneRotationGizmo
  102098. * @param gizmoLayer The utility layer the gizmo will be added to
  102099. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102100. * @param color The color of the gizmo
  102101. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102102. */
  102103. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102104. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102105. /**
  102106. * Disposes of the gizmo
  102107. */
  102108. dispose(): void;
  102109. }
  102110. }
  102111. declare module BABYLON {
  102112. /**
  102113. * Gizmo that enables rotating a mesh along 3 axis
  102114. */
  102115. export class RotationGizmo extends Gizmo {
  102116. /**
  102117. * Internal gizmo used for interactions on the x axis
  102118. */
  102119. xGizmo: PlaneRotationGizmo;
  102120. /**
  102121. * Internal gizmo used for interactions on the y axis
  102122. */
  102123. yGizmo: PlaneRotationGizmo;
  102124. /**
  102125. * Internal gizmo used for interactions on the z axis
  102126. */
  102127. zGizmo: PlaneRotationGizmo;
  102128. /** Fires an event when any of it's sub gizmos are dragged */
  102129. onDragStartObservable: Observable<{}>;
  102130. /** Fires an event when any of it's sub gizmos are released from dragging */
  102131. onDragEndObservable: Observable<{}>;
  102132. attachedMesh: Nullable<AbstractMesh>;
  102133. /**
  102134. * Creates a RotationGizmo
  102135. * @param gizmoLayer The utility layer the gizmo will be added to
  102136. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102137. */
  102138. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102139. updateGizmoRotationToMatchAttachedMesh: boolean;
  102140. /**
  102141. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102142. */
  102143. snapDistance: number;
  102144. /**
  102145. * Ratio for the scale of the gizmo (Default: 1)
  102146. */
  102147. scaleRatio: number;
  102148. /**
  102149. * Disposes of the gizmo
  102150. */
  102151. dispose(): void;
  102152. /**
  102153. * CustomMeshes are not supported by this gizmo
  102154. * @param mesh The mesh to replace the default mesh of the gizmo
  102155. */
  102156. setCustomMesh(mesh: Mesh): void;
  102157. }
  102158. }
  102159. declare module BABYLON {
  102160. /**
  102161. * Gizmo that enables dragging a mesh along 3 axis
  102162. */
  102163. export class PositionGizmo extends Gizmo {
  102164. /**
  102165. * Internal gizmo used for interactions on the x axis
  102166. */
  102167. xGizmo: AxisDragGizmo;
  102168. /**
  102169. * Internal gizmo used for interactions on the y axis
  102170. */
  102171. yGizmo: AxisDragGizmo;
  102172. /**
  102173. * Internal gizmo used for interactions on the z axis
  102174. */
  102175. zGizmo: AxisDragGizmo;
  102176. /** Fires an event when any of it's sub gizmos are dragged */
  102177. onDragStartObservable: Observable<{}>;
  102178. /** Fires an event when any of it's sub gizmos are released from dragging */
  102179. onDragEndObservable: Observable<{}>;
  102180. attachedMesh: Nullable<AbstractMesh>;
  102181. /**
  102182. * Creates a PositionGizmo
  102183. * @param gizmoLayer The utility layer the gizmo will be added to
  102184. */
  102185. constructor(gizmoLayer?: UtilityLayerRenderer);
  102186. updateGizmoRotationToMatchAttachedMesh: boolean;
  102187. /**
  102188. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102189. */
  102190. snapDistance: number;
  102191. /**
  102192. * Ratio for the scale of the gizmo (Default: 1)
  102193. */
  102194. scaleRatio: number;
  102195. /**
  102196. * Disposes of the gizmo
  102197. */
  102198. dispose(): void;
  102199. /**
  102200. * CustomMeshes are not supported by this gizmo
  102201. * @param mesh The mesh to replace the default mesh of the gizmo
  102202. */
  102203. setCustomMesh(mesh: Mesh): void;
  102204. }
  102205. }
  102206. declare module BABYLON {
  102207. /**
  102208. * Class containing static functions to help procedurally build meshes
  102209. */
  102210. export class PolyhedronBuilder {
  102211. /**
  102212. * Creates a polyhedron mesh
  102213. * * 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
  102214. * * The parameter `size` (positive float, default 1) sets the polygon size
  102215. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102216. * * 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`
  102217. * * 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
  102218. * * 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)`)
  102219. * * 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
  102220. * * 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
  102221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102224. * @param name defines the name of the mesh
  102225. * @param options defines the options used to create the mesh
  102226. * @param scene defines the hosting scene
  102227. * @returns the polyhedron mesh
  102228. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102229. */
  102230. static CreatePolyhedron(name: string, options: {
  102231. type?: number;
  102232. size?: number;
  102233. sizeX?: number;
  102234. sizeY?: number;
  102235. sizeZ?: number;
  102236. custom?: any;
  102237. faceUV?: Vector4[];
  102238. faceColors?: Color4[];
  102239. flat?: boolean;
  102240. updatable?: boolean;
  102241. sideOrientation?: number;
  102242. frontUVs?: Vector4;
  102243. backUVs?: Vector4;
  102244. }, scene?: Nullable<Scene>): Mesh;
  102245. }
  102246. }
  102247. declare module BABYLON {
  102248. /**
  102249. * Gizmo that enables scaling a mesh along 3 axis
  102250. */
  102251. export class ScaleGizmo extends Gizmo {
  102252. /**
  102253. * Internal gizmo used for interactions on the x axis
  102254. */
  102255. xGizmo: AxisScaleGizmo;
  102256. /**
  102257. * Internal gizmo used for interactions on the y axis
  102258. */
  102259. yGizmo: AxisScaleGizmo;
  102260. /**
  102261. * Internal gizmo used for interactions on the z axis
  102262. */
  102263. zGizmo: AxisScaleGizmo;
  102264. /**
  102265. * Internal gizmo used to scale all axis equally
  102266. */
  102267. uniformScaleGizmo: AxisScaleGizmo;
  102268. /** Fires an event when any of it's sub gizmos are dragged */
  102269. onDragStartObservable: Observable<{}>;
  102270. /** Fires an event when any of it's sub gizmos are released from dragging */
  102271. onDragEndObservable: Observable<{}>;
  102272. attachedMesh: Nullable<AbstractMesh>;
  102273. /**
  102274. * Creates a ScaleGizmo
  102275. * @param gizmoLayer The utility layer the gizmo will be added to
  102276. */
  102277. constructor(gizmoLayer?: UtilityLayerRenderer);
  102278. updateGizmoRotationToMatchAttachedMesh: boolean;
  102279. /**
  102280. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102281. */
  102282. snapDistance: number;
  102283. /**
  102284. * Ratio for the scale of the gizmo (Default: 1)
  102285. */
  102286. scaleRatio: number;
  102287. /**
  102288. * Disposes of the gizmo
  102289. */
  102290. dispose(): void;
  102291. }
  102292. }
  102293. declare module BABYLON {
  102294. /**
  102295. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102296. */
  102297. export class GizmoManager implements IDisposable {
  102298. private scene;
  102299. /**
  102300. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102301. */
  102302. gizmos: {
  102303. positionGizmo: Nullable<PositionGizmo>;
  102304. rotationGizmo: Nullable<RotationGizmo>;
  102305. scaleGizmo: Nullable<ScaleGizmo>;
  102306. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102307. };
  102308. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102309. clearGizmoOnEmptyPointerEvent: boolean;
  102310. /** Fires an event when the manager is attached to a mesh */
  102311. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102312. private _gizmosEnabled;
  102313. private _pointerObserver;
  102314. private _attachedMesh;
  102315. private _boundingBoxColor;
  102316. private _defaultUtilityLayer;
  102317. private _defaultKeepDepthUtilityLayer;
  102318. /**
  102319. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102320. */
  102321. boundingBoxDragBehavior: SixDofDragBehavior;
  102322. /**
  102323. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102324. */
  102325. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102326. /**
  102327. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102328. */
  102329. usePointerToAttachGizmos: boolean;
  102330. /**
  102331. * Instatiates a gizmo manager
  102332. * @param scene the scene to overlay the gizmos on top of
  102333. */
  102334. constructor(scene: Scene);
  102335. /**
  102336. * Attaches a set of gizmos to the specified mesh
  102337. * @param mesh The mesh the gizmo's should be attached to
  102338. */
  102339. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102340. /**
  102341. * If the position gizmo is enabled
  102342. */
  102343. positionGizmoEnabled: boolean;
  102344. /**
  102345. * If the rotation gizmo is enabled
  102346. */
  102347. rotationGizmoEnabled: boolean;
  102348. /**
  102349. * If the scale gizmo is enabled
  102350. */
  102351. scaleGizmoEnabled: boolean;
  102352. /**
  102353. * If the boundingBox gizmo is enabled
  102354. */
  102355. boundingBoxGizmoEnabled: boolean;
  102356. /**
  102357. * Disposes of the gizmo manager
  102358. */
  102359. dispose(): void;
  102360. }
  102361. }
  102362. declare module BABYLON {
  102363. /**
  102364. * A directional light is defined by a direction (what a surprise!).
  102365. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102366. * 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.
  102367. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102368. */
  102369. export class DirectionalLight extends ShadowLight {
  102370. private _shadowFrustumSize;
  102371. /**
  102372. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102373. */
  102374. /**
  102375. * Specifies a fix frustum size for the shadow generation.
  102376. */
  102377. shadowFrustumSize: number;
  102378. private _shadowOrthoScale;
  102379. /**
  102380. * Gets the shadow projection scale against the optimal computed one.
  102381. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102382. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102383. */
  102384. /**
  102385. * Sets the shadow projection scale against the optimal computed one.
  102386. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102387. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102388. */
  102389. shadowOrthoScale: number;
  102390. /**
  102391. * Automatically compute the projection matrix to best fit (including all the casters)
  102392. * on each frame.
  102393. */
  102394. autoUpdateExtends: boolean;
  102395. private _orthoLeft;
  102396. private _orthoRight;
  102397. private _orthoTop;
  102398. private _orthoBottom;
  102399. /**
  102400. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102401. * The directional light is emitted from everywhere in the given direction.
  102402. * It can cast shadows.
  102403. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102404. * @param name The friendly name of the light
  102405. * @param direction The direction of the light
  102406. * @param scene The scene the light belongs to
  102407. */
  102408. constructor(name: string, direction: Vector3, scene: Scene);
  102409. /**
  102410. * Returns the string "DirectionalLight".
  102411. * @return The class name
  102412. */
  102413. getClassName(): string;
  102414. /**
  102415. * Returns the integer 1.
  102416. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102417. */
  102418. getTypeID(): number;
  102419. /**
  102420. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102421. * Returns the DirectionalLight Shadow projection matrix.
  102422. */
  102423. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102424. /**
  102425. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102426. * Returns the DirectionalLight Shadow projection matrix.
  102427. */
  102428. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102429. /**
  102430. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102431. * Returns the DirectionalLight Shadow projection matrix.
  102432. */
  102433. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102434. protected _buildUniformLayout(): void;
  102435. /**
  102436. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102437. * @param effect The effect to update
  102438. * @param lightIndex The index of the light in the effect to update
  102439. * @returns The directional light
  102440. */
  102441. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102442. /**
  102443. * Gets the minZ used for shadow according to both the scene and the light.
  102444. *
  102445. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102446. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102447. * @param activeCamera The camera we are returning the min for
  102448. * @returns the depth min z
  102449. */
  102450. getDepthMinZ(activeCamera: Camera): number;
  102451. /**
  102452. * Gets the maxZ used for shadow according to both the scene and the light.
  102453. *
  102454. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102455. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102456. * @param activeCamera The camera we are returning the max for
  102457. * @returns the depth max z
  102458. */
  102459. getDepthMaxZ(activeCamera: Camera): number;
  102460. /**
  102461. * Prepares the list of defines specific to the light type.
  102462. * @param defines the list of defines
  102463. * @param lightIndex defines the index of the light for the effect
  102464. */
  102465. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102466. }
  102467. }
  102468. declare module BABYLON {
  102469. /**
  102470. * Class containing static functions to help procedurally build meshes
  102471. */
  102472. export class HemisphereBuilder {
  102473. /**
  102474. * Creates a hemisphere mesh
  102475. * @param name defines the name of the mesh
  102476. * @param options defines the options used to create the mesh
  102477. * @param scene defines the hosting scene
  102478. * @returns the hemisphere mesh
  102479. */
  102480. static CreateHemisphere(name: string, options: {
  102481. segments?: number;
  102482. diameter?: number;
  102483. sideOrientation?: number;
  102484. }, scene: any): Mesh;
  102485. }
  102486. }
  102487. declare module BABYLON {
  102488. /**
  102489. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102490. * These values define a cone of light starting from the position, emitting toward the direction.
  102491. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102492. * and the exponent defines the speed of the decay of the light with distance (reach).
  102493. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102494. */
  102495. export class SpotLight extends ShadowLight {
  102496. private _angle;
  102497. private _innerAngle;
  102498. private _cosHalfAngle;
  102499. private _lightAngleScale;
  102500. private _lightAngleOffset;
  102501. /**
  102502. * Gets the cone angle of the spot light in Radians.
  102503. */
  102504. /**
  102505. * Sets the cone angle of the spot light in Radians.
  102506. */
  102507. angle: number;
  102508. /**
  102509. * Only used in gltf falloff mode, this defines the angle where
  102510. * the directional falloff will start before cutting at angle which could be seen
  102511. * as outer angle.
  102512. */
  102513. /**
  102514. * Only used in gltf falloff mode, this defines the angle where
  102515. * the directional falloff will start before cutting at angle which could be seen
  102516. * as outer angle.
  102517. */
  102518. innerAngle: number;
  102519. private _shadowAngleScale;
  102520. /**
  102521. * Allows scaling the angle of the light for shadow generation only.
  102522. */
  102523. /**
  102524. * Allows scaling the angle of the light for shadow generation only.
  102525. */
  102526. shadowAngleScale: number;
  102527. /**
  102528. * The light decay speed with the distance from the emission spot.
  102529. */
  102530. exponent: number;
  102531. private _projectionTextureMatrix;
  102532. /**
  102533. * Allows reading the projecton texture
  102534. */
  102535. readonly projectionTextureMatrix: Matrix;
  102536. protected _projectionTextureLightNear: number;
  102537. /**
  102538. * Gets the near clip of the Spotlight for texture projection.
  102539. */
  102540. /**
  102541. * Sets the near clip of the Spotlight for texture projection.
  102542. */
  102543. projectionTextureLightNear: number;
  102544. protected _projectionTextureLightFar: number;
  102545. /**
  102546. * Gets the far clip of the Spotlight for texture projection.
  102547. */
  102548. /**
  102549. * Sets the far clip of the Spotlight for texture projection.
  102550. */
  102551. projectionTextureLightFar: number;
  102552. protected _projectionTextureUpDirection: Vector3;
  102553. /**
  102554. * Gets the Up vector of the Spotlight for texture projection.
  102555. */
  102556. /**
  102557. * Sets the Up vector of the Spotlight for texture projection.
  102558. */
  102559. projectionTextureUpDirection: Vector3;
  102560. private _projectionTexture;
  102561. /**
  102562. * Gets the projection texture of the light.
  102563. */
  102564. /**
  102565. * Sets the projection texture of the light.
  102566. */
  102567. projectionTexture: Nullable<BaseTexture>;
  102568. private _projectionTextureViewLightDirty;
  102569. private _projectionTextureProjectionLightDirty;
  102570. private _projectionTextureDirty;
  102571. private _projectionTextureViewTargetVector;
  102572. private _projectionTextureViewLightMatrix;
  102573. private _projectionTextureProjectionLightMatrix;
  102574. private _projectionTextureScalingMatrix;
  102575. /**
  102576. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102577. * It can cast shadows.
  102578. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102579. * @param name The light friendly name
  102580. * @param position The position of the spot light in the scene
  102581. * @param direction The direction of the light in the scene
  102582. * @param angle The cone angle of the light in Radians
  102583. * @param exponent The light decay speed with the distance from the emission spot
  102584. * @param scene The scene the lights belongs to
  102585. */
  102586. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102587. /**
  102588. * Returns the string "SpotLight".
  102589. * @returns the class name
  102590. */
  102591. getClassName(): string;
  102592. /**
  102593. * Returns the integer 2.
  102594. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102595. */
  102596. getTypeID(): number;
  102597. /**
  102598. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102599. */
  102600. protected _setDirection(value: Vector3): void;
  102601. /**
  102602. * Overrides the position setter to recompute the projection texture view light Matrix.
  102603. */
  102604. protected _setPosition(value: Vector3): void;
  102605. /**
  102606. * 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.
  102607. * Returns the SpotLight.
  102608. */
  102609. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102610. protected _computeProjectionTextureViewLightMatrix(): void;
  102611. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102612. /**
  102613. * Main function for light texture projection matrix computing.
  102614. */
  102615. protected _computeProjectionTextureMatrix(): void;
  102616. protected _buildUniformLayout(): void;
  102617. private _computeAngleValues;
  102618. /**
  102619. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102620. * @param effect The effect to update
  102621. * @param lightIndex The index of the light in the effect to update
  102622. * @returns The spot light
  102623. */
  102624. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102625. /**
  102626. * Disposes the light and the associated resources.
  102627. */
  102628. dispose(): void;
  102629. /**
  102630. * Prepares the list of defines specific to the light type.
  102631. * @param defines the list of defines
  102632. * @param lightIndex defines the index of the light for the effect
  102633. */
  102634. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102635. }
  102636. }
  102637. declare module BABYLON {
  102638. /**
  102639. * Gizmo that enables viewing a light
  102640. */
  102641. export class LightGizmo extends Gizmo {
  102642. private _lightMesh;
  102643. private _material;
  102644. /**
  102645. * Creates a LightGizmo
  102646. * @param gizmoLayer The utility layer the gizmo will be added to
  102647. */
  102648. constructor(gizmoLayer?: UtilityLayerRenderer);
  102649. private _light;
  102650. /**
  102651. * The light that the gizmo is attached to
  102652. */
  102653. light: Nullable<Light>;
  102654. /**
  102655. * @hidden
  102656. * Updates the gizmo to match the attached mesh's position/rotation
  102657. */
  102658. protected _update(): void;
  102659. private static _Scale;
  102660. /**
  102661. * Creates the lines for a light mesh
  102662. */
  102663. private static _createLightLines;
  102664. private static _CreateHemisphericLightMesh;
  102665. private static _CreatePointLightMesh;
  102666. private static _CreateSpotLightMesh;
  102667. private static _CreateDirectionalLightMesh;
  102668. }
  102669. }
  102670. declare module BABYLON {
  102671. /** @hidden */
  102672. export var backgroundFragmentDeclaration: {
  102673. name: string;
  102674. shader: string;
  102675. };
  102676. }
  102677. declare module BABYLON {
  102678. /** @hidden */
  102679. export var backgroundUboDeclaration: {
  102680. name: string;
  102681. shader: string;
  102682. };
  102683. }
  102684. declare module BABYLON {
  102685. /** @hidden */
  102686. export var backgroundPixelShader: {
  102687. name: string;
  102688. shader: string;
  102689. };
  102690. }
  102691. declare module BABYLON {
  102692. /** @hidden */
  102693. export var backgroundVertexDeclaration: {
  102694. name: string;
  102695. shader: string;
  102696. };
  102697. }
  102698. declare module BABYLON {
  102699. /** @hidden */
  102700. export var backgroundVertexShader: {
  102701. name: string;
  102702. shader: string;
  102703. };
  102704. }
  102705. declare module BABYLON {
  102706. /**
  102707. * Background material used to create an efficient environement around your scene.
  102708. */
  102709. export class BackgroundMaterial extends PushMaterial {
  102710. /**
  102711. * Standard reflectance value at parallel view angle.
  102712. */
  102713. static StandardReflectance0: number;
  102714. /**
  102715. * Standard reflectance value at grazing angle.
  102716. */
  102717. static StandardReflectance90: number;
  102718. protected _primaryColor: Color3;
  102719. /**
  102720. * Key light Color (multiply against the environement texture)
  102721. */
  102722. primaryColor: Color3;
  102723. protected __perceptualColor: Nullable<Color3>;
  102724. /**
  102725. * Experimental Internal Use Only.
  102726. *
  102727. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102728. * This acts as a helper to set the primary color to a more "human friendly" value.
  102729. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102730. * output color as close as possible from the chosen value.
  102731. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102732. * part of lighting setup.)
  102733. */
  102734. _perceptualColor: Nullable<Color3>;
  102735. protected _primaryColorShadowLevel: float;
  102736. /**
  102737. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102738. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102739. */
  102740. primaryColorShadowLevel: float;
  102741. protected _primaryColorHighlightLevel: float;
  102742. /**
  102743. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102744. * The primary color is used at the level chosen to define what the white area would look.
  102745. */
  102746. primaryColorHighlightLevel: float;
  102747. protected _reflectionTexture: Nullable<BaseTexture>;
  102748. /**
  102749. * Reflection Texture used in the material.
  102750. * Should be author in a specific way for the best result (refer to the documentation).
  102751. */
  102752. reflectionTexture: Nullable<BaseTexture>;
  102753. protected _reflectionBlur: float;
  102754. /**
  102755. * Reflection Texture level of blur.
  102756. *
  102757. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102758. * texture twice.
  102759. */
  102760. reflectionBlur: float;
  102761. protected _diffuseTexture: Nullable<BaseTexture>;
  102762. /**
  102763. * Diffuse Texture used in the material.
  102764. * Should be author in a specific way for the best result (refer to the documentation).
  102765. */
  102766. diffuseTexture: Nullable<BaseTexture>;
  102767. protected _shadowLights: Nullable<IShadowLight[]>;
  102768. /**
  102769. * Specify the list of lights casting shadow on the material.
  102770. * All scene shadow lights will be included if null.
  102771. */
  102772. shadowLights: Nullable<IShadowLight[]>;
  102773. protected _shadowLevel: float;
  102774. /**
  102775. * Helps adjusting the shadow to a softer level if required.
  102776. * 0 means black shadows and 1 means no shadows.
  102777. */
  102778. shadowLevel: float;
  102779. protected _sceneCenter: Vector3;
  102780. /**
  102781. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102782. * It is usually zero but might be interesting to modify according to your setup.
  102783. */
  102784. sceneCenter: Vector3;
  102785. protected _opacityFresnel: boolean;
  102786. /**
  102787. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102788. * This helps ensuring a nice transition when the camera goes under the ground.
  102789. */
  102790. opacityFresnel: boolean;
  102791. protected _reflectionFresnel: boolean;
  102792. /**
  102793. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102794. * This helps adding a mirror texture on the ground.
  102795. */
  102796. reflectionFresnel: boolean;
  102797. protected _reflectionFalloffDistance: number;
  102798. /**
  102799. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102800. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102801. */
  102802. reflectionFalloffDistance: number;
  102803. protected _reflectionAmount: number;
  102804. /**
  102805. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102806. */
  102807. reflectionAmount: number;
  102808. protected _reflectionReflectance0: number;
  102809. /**
  102810. * This specifies the weight of the reflection at grazing angle.
  102811. */
  102812. reflectionReflectance0: number;
  102813. protected _reflectionReflectance90: number;
  102814. /**
  102815. * This specifies the weight of the reflection at a perpendicular point of view.
  102816. */
  102817. reflectionReflectance90: number;
  102818. /**
  102819. * Sets the reflection reflectance fresnel values according to the default standard
  102820. * empirically know to work well :-)
  102821. */
  102822. reflectionStandardFresnelWeight: number;
  102823. protected _useRGBColor: boolean;
  102824. /**
  102825. * Helps to directly use the maps channels instead of their level.
  102826. */
  102827. useRGBColor: boolean;
  102828. protected _enableNoise: boolean;
  102829. /**
  102830. * This helps reducing the banding effect that could occur on the background.
  102831. */
  102832. enableNoise: boolean;
  102833. /**
  102834. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102835. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102836. * Recommended to be keep at 1.0 except for special cases.
  102837. */
  102838. fovMultiplier: number;
  102839. private _fovMultiplier;
  102840. /**
  102841. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102842. */
  102843. useEquirectangularFOV: boolean;
  102844. private _maxSimultaneousLights;
  102845. /**
  102846. * Number of Simultaneous lights allowed on the material.
  102847. */
  102848. maxSimultaneousLights: int;
  102849. /**
  102850. * Default configuration related to image processing available in the Background Material.
  102851. */
  102852. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102853. /**
  102854. * Keep track of the image processing observer to allow dispose and replace.
  102855. */
  102856. private _imageProcessingObserver;
  102857. /**
  102858. * Attaches a new image processing configuration to the PBR Material.
  102859. * @param configuration (if null the scene configuration will be use)
  102860. */
  102861. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102862. /**
  102863. * Gets the image processing configuration used either in this material.
  102864. */
  102865. /**
  102866. * Sets the Default image processing configuration used either in the this material.
  102867. *
  102868. * If sets to null, the scene one is in use.
  102869. */
  102870. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  102871. /**
  102872. * Gets wether the color curves effect is enabled.
  102873. */
  102874. /**
  102875. * Sets wether the color curves effect is enabled.
  102876. */
  102877. cameraColorCurvesEnabled: boolean;
  102878. /**
  102879. * Gets wether the color grading effect is enabled.
  102880. */
  102881. /**
  102882. * Gets wether the color grading effect is enabled.
  102883. */
  102884. cameraColorGradingEnabled: boolean;
  102885. /**
  102886. * Gets wether tonemapping is enabled or not.
  102887. */
  102888. /**
  102889. * Sets wether tonemapping is enabled or not
  102890. */
  102891. cameraToneMappingEnabled: boolean;
  102892. /**
  102893. * The camera exposure used on this material.
  102894. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102895. * This corresponds to a photographic exposure.
  102896. */
  102897. /**
  102898. * The camera exposure used on this material.
  102899. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102900. * This corresponds to a photographic exposure.
  102901. */
  102902. cameraExposure: float;
  102903. /**
  102904. * Gets The camera contrast used on this material.
  102905. */
  102906. /**
  102907. * Sets The camera contrast used on this material.
  102908. */
  102909. cameraContrast: float;
  102910. /**
  102911. * Gets the Color Grading 2D Lookup Texture.
  102912. */
  102913. /**
  102914. * Sets the Color Grading 2D Lookup Texture.
  102915. */
  102916. cameraColorGradingTexture: Nullable<BaseTexture>;
  102917. /**
  102918. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102919. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102920. * 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;
  102921. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102922. */
  102923. /**
  102924. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102925. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102926. * 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;
  102927. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102928. */
  102929. cameraColorCurves: Nullable<ColorCurves>;
  102930. /**
  102931. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  102932. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  102933. */
  102934. switchToBGR: boolean;
  102935. private _renderTargets;
  102936. private _reflectionControls;
  102937. private _white;
  102938. private _primaryShadowColor;
  102939. private _primaryHighlightColor;
  102940. /**
  102941. * Instantiates a Background Material in the given scene
  102942. * @param name The friendly name of the material
  102943. * @param scene The scene to add the material to
  102944. */
  102945. constructor(name: string, scene: Scene);
  102946. /**
  102947. * Gets a boolean indicating that current material needs to register RTT
  102948. */
  102949. readonly hasRenderTargetTextures: boolean;
  102950. /**
  102951. * The entire material has been created in order to prevent overdraw.
  102952. * @returns false
  102953. */
  102954. needAlphaTesting(): boolean;
  102955. /**
  102956. * The entire material has been created in order to prevent overdraw.
  102957. * @returns true if blending is enable
  102958. */
  102959. needAlphaBlending(): boolean;
  102960. /**
  102961. * Checks wether the material is ready to be rendered for a given mesh.
  102962. * @param mesh The mesh to render
  102963. * @param subMesh The submesh to check against
  102964. * @param useInstances Specify wether or not the material is used with instances
  102965. * @returns true if all the dependencies are ready (Textures, Effects...)
  102966. */
  102967. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102968. /**
  102969. * Compute the primary color according to the chosen perceptual color.
  102970. */
  102971. private _computePrimaryColorFromPerceptualColor;
  102972. /**
  102973. * Compute the highlights and shadow colors according to their chosen levels.
  102974. */
  102975. private _computePrimaryColors;
  102976. /**
  102977. * Build the uniform buffer used in the material.
  102978. */
  102979. buildUniformLayout(): void;
  102980. /**
  102981. * Unbind the material.
  102982. */
  102983. unbind(): void;
  102984. /**
  102985. * Bind only the world matrix to the material.
  102986. * @param world The world matrix to bind.
  102987. */
  102988. bindOnlyWorldMatrix(world: Matrix): void;
  102989. /**
  102990. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  102991. * @param world The world matrix to bind.
  102992. * @param subMesh The submesh to bind for.
  102993. */
  102994. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102995. /**
  102996. * Dispose the material.
  102997. * @param forceDisposeEffect Force disposal of the associated effect.
  102998. * @param forceDisposeTextures Force disposal of the associated textures.
  102999. */
  103000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103001. /**
  103002. * Clones the material.
  103003. * @param name The cloned name.
  103004. * @returns The cloned material.
  103005. */
  103006. clone(name: string): BackgroundMaterial;
  103007. /**
  103008. * Serializes the current material to its JSON representation.
  103009. * @returns The JSON representation.
  103010. */
  103011. serialize(): any;
  103012. /**
  103013. * Gets the class name of the material
  103014. * @returns "BackgroundMaterial"
  103015. */
  103016. getClassName(): string;
  103017. /**
  103018. * Parse a JSON input to create back a background material.
  103019. * @param source The JSON data to parse
  103020. * @param scene The scene to create the parsed material in
  103021. * @param rootUrl The root url of the assets the material depends upon
  103022. * @returns the instantiated BackgroundMaterial.
  103023. */
  103024. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103025. }
  103026. }
  103027. declare module BABYLON {
  103028. /**
  103029. * Represents the different options available during the creation of
  103030. * a Environment helper.
  103031. *
  103032. * This can control the default ground, skybox and image processing setup of your scene.
  103033. */
  103034. export interface IEnvironmentHelperOptions {
  103035. /**
  103036. * Specifies wether or not to create a ground.
  103037. * True by default.
  103038. */
  103039. createGround: boolean;
  103040. /**
  103041. * Specifies the ground size.
  103042. * 15 by default.
  103043. */
  103044. groundSize: number;
  103045. /**
  103046. * The texture used on the ground for the main color.
  103047. * Comes from the BabylonJS CDN by default.
  103048. *
  103049. * Remarks: Can be either a texture or a url.
  103050. */
  103051. groundTexture: string | BaseTexture;
  103052. /**
  103053. * The color mixed in the ground texture by default.
  103054. * BabylonJS clearColor by default.
  103055. */
  103056. groundColor: Color3;
  103057. /**
  103058. * Specifies the ground opacity.
  103059. * 1 by default.
  103060. */
  103061. groundOpacity: number;
  103062. /**
  103063. * Enables the ground to receive shadows.
  103064. * True by default.
  103065. */
  103066. enableGroundShadow: boolean;
  103067. /**
  103068. * Helps preventing the shadow to be fully black on the ground.
  103069. * 0.5 by default.
  103070. */
  103071. groundShadowLevel: number;
  103072. /**
  103073. * Creates a mirror texture attach to the ground.
  103074. * false by default.
  103075. */
  103076. enableGroundMirror: boolean;
  103077. /**
  103078. * Specifies the ground mirror size ratio.
  103079. * 0.3 by default as the default kernel is 64.
  103080. */
  103081. groundMirrorSizeRatio: number;
  103082. /**
  103083. * Specifies the ground mirror blur kernel size.
  103084. * 64 by default.
  103085. */
  103086. groundMirrorBlurKernel: number;
  103087. /**
  103088. * Specifies the ground mirror visibility amount.
  103089. * 1 by default
  103090. */
  103091. groundMirrorAmount: number;
  103092. /**
  103093. * Specifies the ground mirror reflectance weight.
  103094. * This uses the standard weight of the background material to setup the fresnel effect
  103095. * of the mirror.
  103096. * 1 by default.
  103097. */
  103098. groundMirrorFresnelWeight: number;
  103099. /**
  103100. * Specifies the ground mirror Falloff distance.
  103101. * This can helps reducing the size of the reflection.
  103102. * 0 by Default.
  103103. */
  103104. groundMirrorFallOffDistance: number;
  103105. /**
  103106. * Specifies the ground mirror texture type.
  103107. * Unsigned Int by Default.
  103108. */
  103109. groundMirrorTextureType: number;
  103110. /**
  103111. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103112. * the shown objects.
  103113. */
  103114. groundYBias: number;
  103115. /**
  103116. * Specifies wether or not to create a skybox.
  103117. * True by default.
  103118. */
  103119. createSkybox: boolean;
  103120. /**
  103121. * Specifies the skybox size.
  103122. * 20 by default.
  103123. */
  103124. skyboxSize: number;
  103125. /**
  103126. * The texture used on the skybox for the main color.
  103127. * Comes from the BabylonJS CDN by default.
  103128. *
  103129. * Remarks: Can be either a texture or a url.
  103130. */
  103131. skyboxTexture: string | BaseTexture;
  103132. /**
  103133. * The color mixed in the skybox texture by default.
  103134. * BabylonJS clearColor by default.
  103135. */
  103136. skyboxColor: Color3;
  103137. /**
  103138. * The background rotation around the Y axis of the scene.
  103139. * This helps aligning the key lights of your scene with the background.
  103140. * 0 by default.
  103141. */
  103142. backgroundYRotation: number;
  103143. /**
  103144. * Compute automatically the size of the elements to best fit with the scene.
  103145. */
  103146. sizeAuto: boolean;
  103147. /**
  103148. * Default position of the rootMesh if autoSize is not true.
  103149. */
  103150. rootPosition: Vector3;
  103151. /**
  103152. * Sets up the image processing in the scene.
  103153. * true by default.
  103154. */
  103155. setupImageProcessing: boolean;
  103156. /**
  103157. * The texture used as your environment texture in the scene.
  103158. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103159. *
  103160. * Remarks: Can be either a texture or a url.
  103161. */
  103162. environmentTexture: string | BaseTexture;
  103163. /**
  103164. * The value of the exposure to apply to the scene.
  103165. * 0.6 by default if setupImageProcessing is true.
  103166. */
  103167. cameraExposure: number;
  103168. /**
  103169. * The value of the contrast to apply to the scene.
  103170. * 1.6 by default if setupImageProcessing is true.
  103171. */
  103172. cameraContrast: number;
  103173. /**
  103174. * Specifies wether or not tonemapping should be enabled in the scene.
  103175. * true by default if setupImageProcessing is true.
  103176. */
  103177. toneMappingEnabled: boolean;
  103178. }
  103179. /**
  103180. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103181. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103182. * It also helps with the default setup of your imageProcessing configuration.
  103183. */
  103184. export class EnvironmentHelper {
  103185. /**
  103186. * Default ground texture URL.
  103187. */
  103188. private static _groundTextureCDNUrl;
  103189. /**
  103190. * Default skybox texture URL.
  103191. */
  103192. private static _skyboxTextureCDNUrl;
  103193. /**
  103194. * Default environment texture URL.
  103195. */
  103196. private static _environmentTextureCDNUrl;
  103197. /**
  103198. * Creates the default options for the helper.
  103199. */
  103200. private static _getDefaultOptions;
  103201. private _rootMesh;
  103202. /**
  103203. * Gets the root mesh created by the helper.
  103204. */
  103205. readonly rootMesh: Mesh;
  103206. private _skybox;
  103207. /**
  103208. * Gets the skybox created by the helper.
  103209. */
  103210. readonly skybox: Nullable<Mesh>;
  103211. private _skyboxTexture;
  103212. /**
  103213. * Gets the skybox texture created by the helper.
  103214. */
  103215. readonly skyboxTexture: Nullable<BaseTexture>;
  103216. private _skyboxMaterial;
  103217. /**
  103218. * Gets the skybox material created by the helper.
  103219. */
  103220. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103221. private _ground;
  103222. /**
  103223. * Gets the ground mesh created by the helper.
  103224. */
  103225. readonly ground: Nullable<Mesh>;
  103226. private _groundTexture;
  103227. /**
  103228. * Gets the ground texture created by the helper.
  103229. */
  103230. readonly groundTexture: Nullable<BaseTexture>;
  103231. private _groundMirror;
  103232. /**
  103233. * Gets the ground mirror created by the helper.
  103234. */
  103235. readonly groundMirror: Nullable<MirrorTexture>;
  103236. /**
  103237. * Gets the ground mirror render list to helps pushing the meshes
  103238. * you wish in the ground reflection.
  103239. */
  103240. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103241. private _groundMaterial;
  103242. /**
  103243. * Gets the ground material created by the helper.
  103244. */
  103245. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103246. /**
  103247. * Stores the creation options.
  103248. */
  103249. private readonly _scene;
  103250. private _options;
  103251. /**
  103252. * This observable will be notified with any error during the creation of the environment,
  103253. * mainly texture creation errors.
  103254. */
  103255. onErrorObservable: Observable<{
  103256. message?: string;
  103257. exception?: any;
  103258. }>;
  103259. /**
  103260. * constructor
  103261. * @param options Defines the options we want to customize the helper
  103262. * @param scene The scene to add the material to
  103263. */
  103264. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103265. /**
  103266. * Updates the background according to the new options
  103267. * @param options
  103268. */
  103269. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103270. /**
  103271. * Sets the primary color of all the available elements.
  103272. * @param color the main color to affect to the ground and the background
  103273. */
  103274. setMainColor(color: Color3): void;
  103275. /**
  103276. * Setup the image processing according to the specified options.
  103277. */
  103278. private _setupImageProcessing;
  103279. /**
  103280. * Setup the environment texture according to the specified options.
  103281. */
  103282. private _setupEnvironmentTexture;
  103283. /**
  103284. * Setup the background according to the specified options.
  103285. */
  103286. private _setupBackground;
  103287. /**
  103288. * Get the scene sizes according to the setup.
  103289. */
  103290. private _getSceneSize;
  103291. /**
  103292. * Setup the ground according to the specified options.
  103293. */
  103294. private _setupGround;
  103295. /**
  103296. * Setup the ground material according to the specified options.
  103297. */
  103298. private _setupGroundMaterial;
  103299. /**
  103300. * Setup the ground diffuse texture according to the specified options.
  103301. */
  103302. private _setupGroundDiffuseTexture;
  103303. /**
  103304. * Setup the ground mirror texture according to the specified options.
  103305. */
  103306. private _setupGroundMirrorTexture;
  103307. /**
  103308. * Setup the ground to receive the mirror texture.
  103309. */
  103310. private _setupMirrorInGroundMaterial;
  103311. /**
  103312. * Setup the skybox according to the specified options.
  103313. */
  103314. private _setupSkybox;
  103315. /**
  103316. * Setup the skybox material according to the specified options.
  103317. */
  103318. private _setupSkyboxMaterial;
  103319. /**
  103320. * Setup the skybox reflection texture according to the specified options.
  103321. */
  103322. private _setupSkyboxReflectionTexture;
  103323. private _errorHandler;
  103324. /**
  103325. * Dispose all the elements created by the Helper.
  103326. */
  103327. dispose(): void;
  103328. }
  103329. }
  103330. declare module BABYLON {
  103331. /**
  103332. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103333. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103334. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103335. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103336. */
  103337. export class PhotoDome extends TransformNode {
  103338. private _useDirectMapping;
  103339. /**
  103340. * The texture being displayed on the sphere
  103341. */
  103342. protected _photoTexture: Texture;
  103343. /**
  103344. * Gets or sets the texture being displayed on the sphere
  103345. */
  103346. photoTexture: Texture;
  103347. /**
  103348. * Observable raised when an error occured while loading the 360 image
  103349. */
  103350. onLoadErrorObservable: Observable<string>;
  103351. /**
  103352. * The skybox material
  103353. */
  103354. protected _material: BackgroundMaterial;
  103355. /**
  103356. * The surface used for the skybox
  103357. */
  103358. protected _mesh: Mesh;
  103359. /**
  103360. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103361. * Also see the options.resolution property.
  103362. */
  103363. fovMultiplier: number;
  103364. /**
  103365. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103366. * @param name Element's name, child elements will append suffixes for their own names.
  103367. * @param urlsOfPhoto defines the url of the photo to display
  103368. * @param options defines an object containing optional or exposed sub element properties
  103369. * @param onError defines a callback called when an error occured while loading the texture
  103370. */
  103371. constructor(name: string, urlOfPhoto: string, options: {
  103372. resolution?: number;
  103373. size?: number;
  103374. useDirectMapping?: boolean;
  103375. faceForward?: boolean;
  103376. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103377. /**
  103378. * Releases resources associated with this node.
  103379. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103380. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103381. */
  103382. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103383. }
  103384. }
  103385. declare module BABYLON {
  103386. /** @hidden */
  103387. export var rgbdDecodePixelShader: {
  103388. name: string;
  103389. shader: string;
  103390. };
  103391. }
  103392. declare module BABYLON {
  103393. /**
  103394. * Class used to host texture specific utilities
  103395. */
  103396. export class BRDFTextureTools {
  103397. /**
  103398. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103399. * @param texture the texture to expand.
  103400. */
  103401. private static _ExpandDefaultBRDFTexture;
  103402. /**
  103403. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103404. * @param scene defines the hosting scene
  103405. * @returns the environment BRDF texture
  103406. */
  103407. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103408. private static _environmentBRDFBase64Texture;
  103409. }
  103410. }
  103411. declare module BABYLON {
  103412. /**
  103413. * @hidden
  103414. */
  103415. export interface IMaterialClearCoatDefines {
  103416. CLEARCOAT: boolean;
  103417. CLEARCOAT_DEFAULTIOR: boolean;
  103418. CLEARCOAT_TEXTURE: boolean;
  103419. CLEARCOAT_TEXTUREDIRECTUV: number;
  103420. CLEARCOAT_BUMP: boolean;
  103421. CLEARCOAT_BUMPDIRECTUV: number;
  103422. CLEARCOAT_TINT: boolean;
  103423. CLEARCOAT_TINT_TEXTURE: boolean;
  103424. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103425. /** @hidden */
  103426. _areTexturesDirty: boolean;
  103427. }
  103428. /**
  103429. * Define the code related to the clear coat parameters of the pbr material.
  103430. */
  103431. export class PBRClearCoatConfiguration {
  103432. /**
  103433. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103434. * The default fits with a polyurethane material.
  103435. */
  103436. private static readonly _DefaultIndiceOfRefraction;
  103437. private _isEnabled;
  103438. /**
  103439. * Defines if the clear coat is enabled in the material.
  103440. */
  103441. isEnabled: boolean;
  103442. /**
  103443. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103444. */
  103445. intensity: number;
  103446. /**
  103447. * Defines the clear coat layer roughness.
  103448. */
  103449. roughness: number;
  103450. private _indiceOfRefraction;
  103451. /**
  103452. * Defines the indice of refraction of the clear coat.
  103453. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103454. * The default fits with a polyurethane material.
  103455. * Changing the default value is more performance intensive.
  103456. */
  103457. indiceOfRefraction: number;
  103458. private _texture;
  103459. /**
  103460. * Stores the clear coat values in a texture.
  103461. */
  103462. texture: Nullable<BaseTexture>;
  103463. private _bumpTexture;
  103464. /**
  103465. * Define the clear coat specific bump texture.
  103466. */
  103467. bumpTexture: Nullable<BaseTexture>;
  103468. private _isTintEnabled;
  103469. /**
  103470. * Defines if the clear coat tint is enabled in the material.
  103471. */
  103472. isTintEnabled: boolean;
  103473. /**
  103474. * Defines the clear coat tint of the material.
  103475. * This is only use if tint is enabled
  103476. */
  103477. tintColor: Color3;
  103478. /**
  103479. * Defines the distance at which the tint color should be found in the
  103480. * clear coat media.
  103481. * This is only use if tint is enabled
  103482. */
  103483. tintColorAtDistance: number;
  103484. /**
  103485. * Defines the clear coat layer thickness.
  103486. * This is only use if tint is enabled
  103487. */
  103488. tintThickness: number;
  103489. private _tintTexture;
  103490. /**
  103491. * Stores the clear tint values in a texture.
  103492. * rgb is tint
  103493. * a is a thickness factor
  103494. */
  103495. tintTexture: Nullable<BaseTexture>;
  103496. /** @hidden */
  103497. private _internalMarkAllSubMeshesAsTexturesDirty;
  103498. /** @hidden */
  103499. _markAllSubMeshesAsTexturesDirty(): void;
  103500. /**
  103501. * Instantiate a new istance of clear coat configuration.
  103502. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103503. */
  103504. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103505. /**
  103506. * Gets wehter the submesh is ready to be used or not.
  103507. * @param defines the list of "defines" to update.
  103508. * @param scene defines the scene the material belongs to.
  103509. * @param engine defines the engine the material belongs to.
  103510. * @param disableBumpMap defines wether the material disables bump or not.
  103511. * @returns - boolean indicating that the submesh is ready or not.
  103512. */
  103513. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  103514. /**
  103515. * Checks to see if a texture is used in the material.
  103516. * @param defines the list of "defines" to update.
  103517. * @param scene defines the scene to the material belongs to.
  103518. */
  103519. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  103520. /**
  103521. * Binds the material data.
  103522. * @param uniformBuffer defines the Uniform buffer to fill in.
  103523. * @param scene defines the scene the material belongs to.
  103524. * @param engine defines the engine the material belongs to.
  103525. * @param disableBumpMap defines wether the material disables bump or not.
  103526. * @param isFrozen defines wether the material is frozen or not.
  103527. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103528. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103529. */
  103530. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: 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 "PBRClearCoatConfiguration"
  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: IMaterialClearCoatDefines, 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 samplers to the current list.
  103572. * @param samplers defines the current sampler list.
  103573. */
  103574. static AddSamplers(samplers: string[]): void;
  103575. /**
  103576. * Add the required uniforms to the current buffer.
  103577. * @param uniformBuffer defines the current uniform buffer.
  103578. */
  103579. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103580. /**
  103581. * Makes a duplicate of the current configuration into another one.
  103582. * @param clearCoatConfiguration define the config where to copy the info
  103583. */
  103584. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  103585. /**
  103586. * Serializes this clear coat configuration.
  103587. * @returns - An object with the serialized config.
  103588. */
  103589. serialize(): any;
  103590. /**
  103591. * Parses a Clear Coat 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 IMaterialAnisotropicDefines {
  103602. ANISOTROPIC: boolean;
  103603. ANISOTROPIC_TEXTURE: boolean;
  103604. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103605. MAINUV1: boolean;
  103606. _areTexturesDirty: boolean;
  103607. _needUVs: boolean;
  103608. }
  103609. /**
  103610. * Define the code related to the anisotropic parameters of the pbr material.
  103611. */
  103612. export class PBRAnisotropicConfiguration {
  103613. private _isEnabled;
  103614. /**
  103615. * Defines if the anisotropy is enabled in the material.
  103616. */
  103617. isEnabled: boolean;
  103618. /**
  103619. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  103620. */
  103621. intensity: number;
  103622. /**
  103623. * Defines if the effect is along the tangents, bitangents or in between.
  103624. * By default, the effect is "strectching" the highlights along the tangents.
  103625. */
  103626. direction: Vector2;
  103627. private _texture;
  103628. /**
  103629. * Stores the anisotropy values in a texture.
  103630. * rg is direction (like normal from -1 to 1)
  103631. * b is a intensity
  103632. */
  103633. texture: Nullable<BaseTexture>;
  103634. /** @hidden */
  103635. private _internalMarkAllSubMeshesAsTexturesDirty;
  103636. /** @hidden */
  103637. _markAllSubMeshesAsTexturesDirty(): void;
  103638. /**
  103639. * Instantiate a new istance of anisotropy configuration.
  103640. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103641. */
  103642. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103643. /**
  103644. * Specifies that the submesh is ready to be used.
  103645. * @param defines the list of "defines" to update.
  103646. * @param scene defines the scene the material belongs to.
  103647. * @returns - boolean indicating that the submesh is ready or not.
  103648. */
  103649. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  103650. /**
  103651. * Checks to see if a texture is used in the material.
  103652. * @param defines the list of "defines" to update.
  103653. * @param mesh the mesh we are preparing the defines for.
  103654. * @param scene defines the scene the material belongs to.
  103655. */
  103656. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  103657. /**
  103658. * Binds the material data.
  103659. * @param uniformBuffer defines the Uniform buffer to fill in.
  103660. * @param scene defines the scene the material belongs to.
  103661. * @param isFrozen defines wether the material is frozen or not.
  103662. */
  103663. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103664. /**
  103665. * Checks to see if a texture is used in the material.
  103666. * @param texture - Base texture to use.
  103667. * @returns - Boolean specifying if a texture is used in the material.
  103668. */
  103669. hasTexture(texture: BaseTexture): boolean;
  103670. /**
  103671. * Returns an array of the actively used textures.
  103672. * @param activeTextures Array of BaseTextures
  103673. */
  103674. getActiveTextures(activeTextures: BaseTexture[]): void;
  103675. /**
  103676. * Returns the animatable textures.
  103677. * @param animatables Array of animatable textures.
  103678. */
  103679. getAnimatables(animatables: IAnimatable[]): void;
  103680. /**
  103681. * Disposes the resources of the material.
  103682. * @param forceDisposeTextures - Forces the disposal of all textures.
  103683. */
  103684. dispose(forceDisposeTextures?: boolean): void;
  103685. /**
  103686. * Get the current class name of the texture useful for serialization or dynamic coding.
  103687. * @returns "PBRAnisotropicConfiguration"
  103688. */
  103689. getClassName(): string;
  103690. /**
  103691. * Add fallbacks to the effect fallbacks list.
  103692. * @param defines defines the Base texture to use.
  103693. * @param fallbacks defines the current fallback list.
  103694. * @param currentRank defines the current fallback rank.
  103695. * @returns the new fallback rank.
  103696. */
  103697. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103698. /**
  103699. * Add the required uniforms to the current list.
  103700. * @param uniforms defines the current uniform list.
  103701. */
  103702. static AddUniforms(uniforms: string[]): void;
  103703. /**
  103704. * Add the required uniforms to the current buffer.
  103705. * @param uniformBuffer defines the current uniform buffer.
  103706. */
  103707. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103708. /**
  103709. * Add the required samplers to the current list.
  103710. * @param samplers defines the current sampler list.
  103711. */
  103712. static AddSamplers(samplers: string[]): void;
  103713. /**
  103714. * Makes a duplicate of the current configuration into another one.
  103715. * @param anisotropicConfiguration define the config where to copy the info
  103716. */
  103717. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  103718. /**
  103719. * Serializes this anisotropy configuration.
  103720. * @returns - An object with the serialized config.
  103721. */
  103722. serialize(): any;
  103723. /**
  103724. * Parses a anisotropy Configuration from a serialized object.
  103725. * @param source - Serialized object.
  103726. */
  103727. parse(source: any): void;
  103728. }
  103729. }
  103730. declare module BABYLON {
  103731. /**
  103732. * @hidden
  103733. */
  103734. export interface IMaterialBRDFDefines {
  103735. BRDF_V_HEIGHT_CORRELATED: boolean;
  103736. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103737. /** @hidden */
  103738. _areMiscDirty: boolean;
  103739. }
  103740. /**
  103741. * Define the code related to the BRDF parameters of the pbr material.
  103742. */
  103743. export class PBRBRDFConfiguration {
  103744. /**
  103745. * Default value used for the energy conservation.
  103746. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103747. */
  103748. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103749. /**
  103750. * Default value used for the Smith Visibility Height Correlated mode.
  103751. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103752. */
  103753. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103754. private _useEnergyConservation;
  103755. /**
  103756. * Defines if the material uses energy conservation.
  103757. */
  103758. useEnergyConservation: boolean;
  103759. private _useSmithVisibilityHeightCorrelated;
  103760. /**
  103761. * LEGACY Mode set to false
  103762. * Defines if the material uses height smith correlated visibility term.
  103763. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103764. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103765. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103766. * Not relying on height correlated will also disable energy conservation.
  103767. */
  103768. useSmithVisibilityHeightCorrelated: boolean;
  103769. /** @hidden */
  103770. private _internalMarkAllSubMeshesAsMiscDirty;
  103771. /** @hidden */
  103772. _markAllSubMeshesAsMiscDirty(): void;
  103773. /**
  103774. * Instantiate a new istance of clear coat configuration.
  103775. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103776. */
  103777. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103778. /**
  103779. * Checks to see if a texture is used in the material.
  103780. * @param defines the list of "defines" to update.
  103781. */
  103782. prepareDefines(defines: IMaterialBRDFDefines): void;
  103783. /**
  103784. * Get the current class name of the texture useful for serialization or dynamic coding.
  103785. * @returns "PBRClearCoatConfiguration"
  103786. */
  103787. getClassName(): string;
  103788. /**
  103789. * Makes a duplicate of the current configuration into another one.
  103790. * @param brdfConfiguration define the config where to copy the info
  103791. */
  103792. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103793. /**
  103794. * Serializes this BRDF configuration.
  103795. * @returns - An object with the serialized config.
  103796. */
  103797. serialize(): any;
  103798. /**
  103799. * Parses a BRDF Configuration from a serialized object.
  103800. * @param source - Serialized object.
  103801. */
  103802. parse(source: any): void;
  103803. }
  103804. }
  103805. declare module BABYLON {
  103806. /**
  103807. * @hidden
  103808. */
  103809. export interface IMaterialSheenDefines {
  103810. SHEEN: boolean;
  103811. SHEEN_TEXTURE: boolean;
  103812. SHEEN_TEXTUREDIRECTUV: number;
  103813. SHEEN_LINKWITHALBEDO: boolean;
  103814. /** @hidden */
  103815. _areTexturesDirty: boolean;
  103816. }
  103817. /**
  103818. * Define the code related to the Sheen parameters of the pbr material.
  103819. */
  103820. export class PBRSheenConfiguration {
  103821. private _isEnabled;
  103822. /**
  103823. * Defines if the material uses sheen.
  103824. */
  103825. isEnabled: boolean;
  103826. private _linkSheenWithAlbedo;
  103827. /**
  103828. * Defines if the sheen is linked to the sheen color.
  103829. */
  103830. linkSheenWithAlbedo: boolean;
  103831. /**
  103832. * Defines the sheen intensity.
  103833. */
  103834. intensity: number;
  103835. /**
  103836. * Defines the sheen color.
  103837. */
  103838. color: Color3;
  103839. private _texture;
  103840. /**
  103841. * Stores the sheen tint values in a texture.
  103842. * rgb is tint
  103843. * a is a intensity
  103844. */
  103845. texture: Nullable<BaseTexture>;
  103846. /** @hidden */
  103847. private _internalMarkAllSubMeshesAsTexturesDirty;
  103848. /** @hidden */
  103849. _markAllSubMeshesAsTexturesDirty(): void;
  103850. /**
  103851. * Instantiate a new istance of clear coat configuration.
  103852. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103853. */
  103854. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103855. /**
  103856. * Specifies that the submesh is ready to be used.
  103857. * @param defines the list of "defines" to update.
  103858. * @param scene defines the scene the material belongs to.
  103859. * @returns - boolean indicating that the submesh is ready or not.
  103860. */
  103861. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  103862. /**
  103863. * Checks to see if a texture is used in the material.
  103864. * @param defines the list of "defines" to update.
  103865. * @param scene defines the scene the material belongs to.
  103866. */
  103867. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  103868. /**
  103869. * Binds the material data.
  103870. * @param uniformBuffer defines the Uniform buffer to fill in.
  103871. * @param scene defines the scene the material belongs to.
  103872. * @param isFrozen defines wether the material is frozen or not.
  103873. */
  103874. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103875. /**
  103876. * Checks to see if a texture is used in the material.
  103877. * @param texture - Base texture to use.
  103878. * @returns - Boolean specifying if a texture is used in the material.
  103879. */
  103880. hasTexture(texture: BaseTexture): boolean;
  103881. /**
  103882. * Returns an array of the actively used textures.
  103883. * @param activeTextures Array of BaseTextures
  103884. */
  103885. getActiveTextures(activeTextures: BaseTexture[]): void;
  103886. /**
  103887. * Returns the animatable textures.
  103888. * @param animatables Array of animatable textures.
  103889. */
  103890. getAnimatables(animatables: IAnimatable[]): void;
  103891. /**
  103892. * Disposes the resources of the material.
  103893. * @param forceDisposeTextures - Forces the disposal of all textures.
  103894. */
  103895. dispose(forceDisposeTextures?: boolean): void;
  103896. /**
  103897. * Get the current class name of the texture useful for serialization or dynamic coding.
  103898. * @returns "PBRSheenConfiguration"
  103899. */
  103900. getClassName(): string;
  103901. /**
  103902. * Add fallbacks to the effect fallbacks list.
  103903. * @param defines defines the Base texture to use.
  103904. * @param fallbacks defines the current fallback list.
  103905. * @param currentRank defines the current fallback rank.
  103906. * @returns the new fallback rank.
  103907. */
  103908. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103909. /**
  103910. * Add the required uniforms to the current list.
  103911. * @param uniforms defines the current uniform list.
  103912. */
  103913. static AddUniforms(uniforms: string[]): void;
  103914. /**
  103915. * Add the required uniforms to the current buffer.
  103916. * @param uniformBuffer defines the current uniform buffer.
  103917. */
  103918. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103919. /**
  103920. * Add the required samplers to the current list.
  103921. * @param samplers defines the current sampler list.
  103922. */
  103923. static AddSamplers(samplers: string[]): void;
  103924. /**
  103925. * Makes a duplicate of the current configuration into another one.
  103926. * @param sheenConfiguration define the config where to copy the info
  103927. */
  103928. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  103929. /**
  103930. * Serializes this BRDF configuration.
  103931. * @returns - An object with the serialized config.
  103932. */
  103933. serialize(): any;
  103934. /**
  103935. * Parses a Sheen Configuration from a serialized object.
  103936. * @param source - Serialized object.
  103937. */
  103938. parse(source: any): void;
  103939. }
  103940. }
  103941. declare module BABYLON {
  103942. /**
  103943. * @hidden
  103944. */
  103945. export interface IMaterialSubSurfaceDefines {
  103946. SUBSURFACE: boolean;
  103947. SS_REFRACTION: boolean;
  103948. SS_TRANSLUCENCY: boolean;
  103949. SS_SCATERRING: boolean;
  103950. SS_THICKNESSANDMASK_TEXTURE: boolean;
  103951. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  103952. SS_REFRACTIONMAP_3D: boolean;
  103953. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  103954. SS_LODINREFRACTIONALPHA: boolean;
  103955. SS_GAMMAREFRACTION: boolean;
  103956. SS_RGBDREFRACTION: boolean;
  103957. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  103958. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  103959. /** @hidden */
  103960. _areTexturesDirty: boolean;
  103961. }
  103962. /**
  103963. * Define the code related to the sub surface parameters of the pbr material.
  103964. */
  103965. export class PBRSubSurfaceConfiguration {
  103966. private _isRefractionEnabled;
  103967. /**
  103968. * Defines if the refraction is enabled in the material.
  103969. */
  103970. isRefractionEnabled: boolean;
  103971. private _isTranslucencyEnabled;
  103972. /**
  103973. * Defines if the translucency is enabled in the material.
  103974. */
  103975. isTranslucencyEnabled: boolean;
  103976. private _isScatteringEnabled;
  103977. /**
  103978. * Defines the refraction intensity of the material.
  103979. * The refraction when enabled replaces the Diffuse part of the material.
  103980. * The intensity helps transitionning between diffuse and refraction.
  103981. */
  103982. refractionIntensity: number;
  103983. /**
  103984. * Defines the translucency intensity of the material.
  103985. * When translucency has been enabled, this defines how much of the "translucency"
  103986. * is addded to the diffuse part of the material.
  103987. */
  103988. translucencyIntensity: number;
  103989. /**
  103990. * Defines the scattering intensity of the material.
  103991. * When scattering has been enabled, this defines how much of the "scattered light"
  103992. * is addded to the diffuse part of the material.
  103993. */
  103994. scatteringIntensity: number;
  103995. private _thicknessTexture;
  103996. /**
  103997. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  103998. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  103999. * 0 would mean minimumThickness
  104000. * 1 would mean maximumThickness
  104001. * The other channels might be use as a mask to vary the different effects intensity.
  104002. */
  104003. thicknessTexture: Nullable<BaseTexture>;
  104004. private _refractionTexture;
  104005. /**
  104006. * Defines the texture to use for refraction.
  104007. */
  104008. refractionTexture: Nullable<BaseTexture>;
  104009. private _indexOfRefraction;
  104010. /**
  104011. * Defines the indice of refraction used in the material.
  104012. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104013. */
  104014. indexOfRefraction: number;
  104015. private _invertRefractionY;
  104016. /**
  104017. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104018. */
  104019. invertRefractionY: boolean;
  104020. private _linkRefractionWithTransparency;
  104021. /**
  104022. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104023. * Materials half opaque for instance using refraction could benefit from this control.
  104024. */
  104025. linkRefractionWithTransparency: boolean;
  104026. /**
  104027. * Defines the minimum thickness stored in the thickness map.
  104028. * If no thickness map is defined, this value will be used to simulate thickness.
  104029. */
  104030. minimumThickness: number;
  104031. /**
  104032. * Defines the maximum thickness stored in the thickness map.
  104033. */
  104034. maximumThickness: number;
  104035. /**
  104036. * Defines the volume tint of the material.
  104037. * This is used for both translucency and scattering.
  104038. */
  104039. tintColor: Color3;
  104040. /**
  104041. * Defines the distance at which the tint color should be found in the media.
  104042. * This is used for refraction only.
  104043. */
  104044. tintColorAtDistance: number;
  104045. /**
  104046. * Defines how far each channel transmit through the media.
  104047. * It is defined as a color to simplify it selection.
  104048. */
  104049. diffusionDistance: Color3;
  104050. private _useMaskFromThicknessTexture;
  104051. /**
  104052. * Stores the intensity of the different subsurface effects in the thickness texture.
  104053. * * the green channel is the translucency intensity.
  104054. * * the blue channel is the scattering intensity.
  104055. * * the alpha channel is the refraction intensity.
  104056. */
  104057. useMaskFromThicknessTexture: boolean;
  104058. /** @hidden */
  104059. private _internalMarkAllSubMeshesAsTexturesDirty;
  104060. /** @hidden */
  104061. _markAllSubMeshesAsTexturesDirty(): void;
  104062. /**
  104063. * Instantiate a new istance of sub surface configuration.
  104064. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104065. */
  104066. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104067. /**
  104068. * Gets wehter the submesh is ready to be used or not.
  104069. * @param defines the list of "defines" to update.
  104070. * @param scene defines the scene the material belongs to.
  104071. * @returns - boolean indicating that the submesh is ready or not.
  104072. */
  104073. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104074. /**
  104075. * Checks to see if a texture is used in the material.
  104076. * @param defines the list of "defines" to update.
  104077. * @param scene defines the scene to the material belongs to.
  104078. */
  104079. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104080. /**
  104081. * Binds the material data.
  104082. * @param uniformBuffer defines the Uniform buffer to fill in.
  104083. * @param scene defines the scene the material belongs to.
  104084. * @param engine defines the engine the material belongs to.
  104085. * @param isFrozen defines wether the material is frozen or not.
  104086. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104087. */
  104088. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104089. /**
  104090. * Unbinds the material from the mesh.
  104091. * @param activeEffect defines the effect that should be unbound from.
  104092. * @returns true if unbound, otherwise false
  104093. */
  104094. unbind(activeEffect: Effect): boolean;
  104095. /**
  104096. * Returns the texture used for refraction or null if none is used.
  104097. * @param scene defines the scene the material belongs to.
  104098. * @returns - Refraction texture if present. If no refraction texture and refraction
  104099. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104100. */
  104101. private _getRefractionTexture;
  104102. /**
  104103. * Returns true if alpha blending should be disabled.
  104104. */
  104105. readonly disableAlphaBlending: boolean;
  104106. /**
  104107. * Fills the list of render target textures.
  104108. * @param renderTargets the list of render targets to update
  104109. */
  104110. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104111. /**
  104112. * Checks to see if a texture is used in the material.
  104113. * @param texture - Base texture to use.
  104114. * @returns - Boolean specifying if a texture is used in the material.
  104115. */
  104116. hasTexture(texture: BaseTexture): boolean;
  104117. /**
  104118. * Gets a boolean indicating that current material needs to register RTT
  104119. * @returns true if this uses a render target otherwise false.
  104120. */
  104121. hasRenderTargetTextures(): boolean;
  104122. /**
  104123. * Returns an array of the actively used textures.
  104124. * @param activeTextures Array of BaseTextures
  104125. */
  104126. getActiveTextures(activeTextures: BaseTexture[]): void;
  104127. /**
  104128. * Returns the animatable textures.
  104129. * @param animatables Array of animatable textures.
  104130. */
  104131. getAnimatables(animatables: IAnimatable[]): void;
  104132. /**
  104133. * Disposes the resources of the material.
  104134. * @param forceDisposeTextures - Forces the disposal of all textures.
  104135. */
  104136. dispose(forceDisposeTextures?: boolean): void;
  104137. /**
  104138. * Get the current class name of the texture useful for serialization or dynamic coding.
  104139. * @returns "PBRSubSurfaceConfiguration"
  104140. */
  104141. getClassName(): string;
  104142. /**
  104143. * Add fallbacks to the effect fallbacks list.
  104144. * @param defines defines the Base texture to use.
  104145. * @param fallbacks defines the current fallback list.
  104146. * @param currentRank defines the current fallback rank.
  104147. * @returns the new fallback rank.
  104148. */
  104149. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104150. /**
  104151. * Add the required uniforms to the current list.
  104152. * @param uniforms defines the current uniform list.
  104153. */
  104154. static AddUniforms(uniforms: string[]): void;
  104155. /**
  104156. * Add the required samplers to the current list.
  104157. * @param samplers defines the current sampler list.
  104158. */
  104159. static AddSamplers(samplers: string[]): void;
  104160. /**
  104161. * Add the required uniforms to the current buffer.
  104162. * @param uniformBuffer defines the current uniform buffer.
  104163. */
  104164. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104165. /**
  104166. * Makes a duplicate of the current configuration into another one.
  104167. * @param configuration define the config where to copy the info
  104168. */
  104169. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104170. /**
  104171. * Serializes this Sub Surface configuration.
  104172. * @returns - An object with the serialized config.
  104173. */
  104174. serialize(): any;
  104175. /**
  104176. * Parses a Sub Surface Configuration from a serialized object.
  104177. * @param source - Serialized object.
  104178. */
  104179. parse(source: any): void;
  104180. }
  104181. }
  104182. declare module BABYLON {
  104183. /** @hidden */
  104184. export var pbrFragmentDeclaration: {
  104185. name: string;
  104186. shader: string;
  104187. };
  104188. }
  104189. declare module BABYLON {
  104190. /** @hidden */
  104191. export var pbrUboDeclaration: {
  104192. name: string;
  104193. shader: string;
  104194. };
  104195. }
  104196. declare module BABYLON {
  104197. /** @hidden */
  104198. export var pbrFragmentExtraDeclaration: {
  104199. name: string;
  104200. shader: string;
  104201. };
  104202. }
  104203. declare module BABYLON {
  104204. /** @hidden */
  104205. export var pbrFragmentSamplersDeclaration: {
  104206. name: string;
  104207. shader: string;
  104208. };
  104209. }
  104210. declare module BABYLON {
  104211. /** @hidden */
  104212. export var pbrHelperFunctions: {
  104213. name: string;
  104214. shader: string;
  104215. };
  104216. }
  104217. declare module BABYLON {
  104218. /** @hidden */
  104219. export var harmonicsFunctions: {
  104220. name: string;
  104221. shader: string;
  104222. };
  104223. }
  104224. declare module BABYLON {
  104225. /** @hidden */
  104226. export var pbrDirectLightingSetupFunctions: {
  104227. name: string;
  104228. shader: string;
  104229. };
  104230. }
  104231. declare module BABYLON {
  104232. /** @hidden */
  104233. export var pbrDirectLightingFalloffFunctions: {
  104234. name: string;
  104235. shader: string;
  104236. };
  104237. }
  104238. declare module BABYLON {
  104239. /** @hidden */
  104240. export var pbrBRDFFunctions: {
  104241. name: string;
  104242. shader: string;
  104243. };
  104244. }
  104245. declare module BABYLON {
  104246. /** @hidden */
  104247. export var pbrDirectLightingFunctions: {
  104248. name: string;
  104249. shader: string;
  104250. };
  104251. }
  104252. declare module BABYLON {
  104253. /** @hidden */
  104254. export var pbrIBLFunctions: {
  104255. name: string;
  104256. shader: string;
  104257. };
  104258. }
  104259. declare module BABYLON {
  104260. /** @hidden */
  104261. export var pbrDebug: {
  104262. name: string;
  104263. shader: string;
  104264. };
  104265. }
  104266. declare module BABYLON {
  104267. /** @hidden */
  104268. export var pbrPixelShader: {
  104269. name: string;
  104270. shader: string;
  104271. };
  104272. }
  104273. declare module BABYLON {
  104274. /** @hidden */
  104275. export var pbrVertexDeclaration: {
  104276. name: string;
  104277. shader: string;
  104278. };
  104279. }
  104280. declare module BABYLON {
  104281. /** @hidden */
  104282. export var pbrVertexShader: {
  104283. name: string;
  104284. shader: string;
  104285. };
  104286. }
  104287. declare module BABYLON {
  104288. /**
  104289. * Manages the defines for the PBR Material.
  104290. * @hidden
  104291. */
  104292. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104293. PBR: boolean;
  104294. MAINUV1: boolean;
  104295. MAINUV2: boolean;
  104296. UV1: boolean;
  104297. UV2: boolean;
  104298. ALBEDO: boolean;
  104299. ALBEDODIRECTUV: number;
  104300. VERTEXCOLOR: boolean;
  104301. AMBIENT: boolean;
  104302. AMBIENTDIRECTUV: number;
  104303. AMBIENTINGRAYSCALE: boolean;
  104304. OPACITY: boolean;
  104305. VERTEXALPHA: boolean;
  104306. OPACITYDIRECTUV: number;
  104307. OPACITYRGB: boolean;
  104308. ALPHATEST: boolean;
  104309. DEPTHPREPASS: boolean;
  104310. ALPHABLEND: boolean;
  104311. ALPHAFROMALBEDO: boolean;
  104312. ALPHATESTVALUE: string;
  104313. SPECULAROVERALPHA: boolean;
  104314. RADIANCEOVERALPHA: boolean;
  104315. ALPHAFRESNEL: boolean;
  104316. LINEARALPHAFRESNEL: boolean;
  104317. PREMULTIPLYALPHA: boolean;
  104318. EMISSIVE: boolean;
  104319. EMISSIVEDIRECTUV: number;
  104320. REFLECTIVITY: boolean;
  104321. REFLECTIVITYDIRECTUV: number;
  104322. SPECULARTERM: boolean;
  104323. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104324. MICROSURFACEAUTOMATIC: boolean;
  104325. LODBASEDMICROSFURACE: boolean;
  104326. MICROSURFACEMAP: boolean;
  104327. MICROSURFACEMAPDIRECTUV: number;
  104328. METALLICWORKFLOW: boolean;
  104329. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104330. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104331. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104332. AOSTOREINMETALMAPRED: boolean;
  104333. ENVIRONMENTBRDF: boolean;
  104334. ENVIRONMENTBRDF_RGBD: boolean;
  104335. NORMAL: boolean;
  104336. TANGENT: boolean;
  104337. BUMP: boolean;
  104338. BUMPDIRECTUV: number;
  104339. OBJECTSPACE_NORMALMAP: boolean;
  104340. PARALLAX: boolean;
  104341. PARALLAXOCCLUSION: boolean;
  104342. NORMALXYSCALE: boolean;
  104343. LIGHTMAP: boolean;
  104344. LIGHTMAPDIRECTUV: number;
  104345. USELIGHTMAPASSHADOWMAP: boolean;
  104346. GAMMALIGHTMAP: boolean;
  104347. REFLECTION: boolean;
  104348. REFLECTIONMAP_3D: boolean;
  104349. REFLECTIONMAP_SPHERICAL: boolean;
  104350. REFLECTIONMAP_PLANAR: boolean;
  104351. REFLECTIONMAP_CUBIC: boolean;
  104352. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104353. REFLECTIONMAP_PROJECTION: boolean;
  104354. REFLECTIONMAP_SKYBOX: boolean;
  104355. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104356. REFLECTIONMAP_EXPLICIT: boolean;
  104357. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104358. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104359. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104360. INVERTCUBICMAP: boolean;
  104361. USESPHERICALFROMREFLECTIONMAP: boolean;
  104362. USESPHERICALINVERTEX: boolean;
  104363. REFLECTIONMAP_OPPOSITEZ: boolean;
  104364. LODINREFLECTIONALPHA: boolean;
  104365. GAMMAREFLECTION: boolean;
  104366. RGBDREFLECTION: boolean;
  104367. RADIANCEOCCLUSION: boolean;
  104368. HORIZONOCCLUSION: boolean;
  104369. INSTANCES: boolean;
  104370. NUM_BONE_INFLUENCERS: number;
  104371. BonesPerMesh: number;
  104372. BONETEXTURE: boolean;
  104373. NONUNIFORMSCALING: boolean;
  104374. MORPHTARGETS: boolean;
  104375. MORPHTARGETS_NORMAL: boolean;
  104376. MORPHTARGETS_TANGENT: boolean;
  104377. NUM_MORPH_INFLUENCERS: number;
  104378. IMAGEPROCESSING: boolean;
  104379. VIGNETTE: boolean;
  104380. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104381. VIGNETTEBLENDMODEOPAQUE: boolean;
  104382. TONEMAPPING: boolean;
  104383. TONEMAPPING_ACES: boolean;
  104384. CONTRAST: boolean;
  104385. COLORCURVES: boolean;
  104386. COLORGRADING: boolean;
  104387. COLORGRADING3D: boolean;
  104388. SAMPLER3DGREENDEPTH: boolean;
  104389. SAMPLER3DBGRMAP: boolean;
  104390. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104391. EXPOSURE: boolean;
  104392. MULTIVIEW: boolean;
  104393. USEPHYSICALLIGHTFALLOFF: boolean;
  104394. USEGLTFLIGHTFALLOFF: boolean;
  104395. TWOSIDEDLIGHTING: boolean;
  104396. SHADOWFLOAT: boolean;
  104397. CLIPPLANE: boolean;
  104398. CLIPPLANE2: boolean;
  104399. CLIPPLANE3: boolean;
  104400. CLIPPLANE4: boolean;
  104401. POINTSIZE: boolean;
  104402. FOG: boolean;
  104403. LOGARITHMICDEPTH: boolean;
  104404. FORCENORMALFORWARD: boolean;
  104405. SPECULARAA: boolean;
  104406. CLEARCOAT: boolean;
  104407. CLEARCOAT_DEFAULTIOR: boolean;
  104408. CLEARCOAT_TEXTURE: boolean;
  104409. CLEARCOAT_TEXTUREDIRECTUV: number;
  104410. CLEARCOAT_BUMP: boolean;
  104411. CLEARCOAT_BUMPDIRECTUV: number;
  104412. CLEARCOAT_TINT: boolean;
  104413. CLEARCOAT_TINT_TEXTURE: boolean;
  104414. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104415. ANISOTROPIC: boolean;
  104416. ANISOTROPIC_TEXTURE: boolean;
  104417. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104418. BRDF_V_HEIGHT_CORRELATED: boolean;
  104419. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104420. SHEEN: boolean;
  104421. SHEEN_TEXTURE: boolean;
  104422. SHEEN_TEXTUREDIRECTUV: number;
  104423. SHEEN_LINKWITHALBEDO: boolean;
  104424. SUBSURFACE: boolean;
  104425. SS_REFRACTION: boolean;
  104426. SS_TRANSLUCENCY: boolean;
  104427. SS_SCATERRING: boolean;
  104428. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104429. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104430. SS_REFRACTIONMAP_3D: boolean;
  104431. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104432. SS_LODINREFRACTIONALPHA: boolean;
  104433. SS_GAMMAREFRACTION: boolean;
  104434. SS_RGBDREFRACTION: boolean;
  104435. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104436. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104437. UNLIT: boolean;
  104438. DEBUGMODE: number;
  104439. /**
  104440. * Initializes the PBR Material defines.
  104441. */
  104442. constructor();
  104443. /**
  104444. * Resets the PBR Material defines.
  104445. */
  104446. reset(): void;
  104447. }
  104448. /**
  104449. * The Physically based material base class of BJS.
  104450. *
  104451. * This offers the main features of a standard PBR material.
  104452. * For more information, please refer to the documentation :
  104453. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104454. */
  104455. export abstract class PBRBaseMaterial extends PushMaterial {
  104456. /**
  104457. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104458. */
  104459. static readonly PBRMATERIAL_OPAQUE: number;
  104460. /**
  104461. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104462. */
  104463. static readonly PBRMATERIAL_ALPHATEST: number;
  104464. /**
  104465. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104466. */
  104467. static readonly PBRMATERIAL_ALPHABLEND: number;
  104468. /**
  104469. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104470. * They are also discarded below the alpha cutoff threshold to improve performances.
  104471. */
  104472. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104473. /**
  104474. * Defines the default value of how much AO map is occluding the analytical lights
  104475. * (point spot...).
  104476. */
  104477. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104478. /**
  104479. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  104480. */
  104481. static readonly LIGHTFALLOFF_PHYSICAL: number;
  104482. /**
  104483. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  104484. * to enhance interoperability with other engines.
  104485. */
  104486. static readonly LIGHTFALLOFF_GLTF: number;
  104487. /**
  104488. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  104489. * to enhance interoperability with other materials.
  104490. */
  104491. static readonly LIGHTFALLOFF_STANDARD: number;
  104492. /**
  104493. * Intensity of the direct lights e.g. the four lights available in your scene.
  104494. * This impacts both the direct diffuse and specular highlights.
  104495. */
  104496. protected _directIntensity: number;
  104497. /**
  104498. * Intensity of the emissive part of the material.
  104499. * This helps controlling the emissive effect without modifying the emissive color.
  104500. */
  104501. protected _emissiveIntensity: number;
  104502. /**
  104503. * Intensity of the environment e.g. how much the environment will light the object
  104504. * either through harmonics for rough material or through the refelction for shiny ones.
  104505. */
  104506. protected _environmentIntensity: number;
  104507. /**
  104508. * This is a special control allowing the reduction of the specular highlights coming from the
  104509. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104510. */
  104511. protected _specularIntensity: number;
  104512. /**
  104513. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  104514. */
  104515. private _lightingInfos;
  104516. /**
  104517. * Debug Control allowing disabling the bump map on this material.
  104518. */
  104519. protected _disableBumpMap: boolean;
  104520. /**
  104521. * AKA Diffuse Texture in standard nomenclature.
  104522. */
  104523. protected _albedoTexture: Nullable<BaseTexture>;
  104524. /**
  104525. * AKA Occlusion Texture in other nomenclature.
  104526. */
  104527. protected _ambientTexture: Nullable<BaseTexture>;
  104528. /**
  104529. * AKA Occlusion Texture Intensity in other nomenclature.
  104530. */
  104531. protected _ambientTextureStrength: number;
  104532. /**
  104533. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104534. * 1 means it completely occludes it
  104535. * 0 mean it has no impact
  104536. */
  104537. protected _ambientTextureImpactOnAnalyticalLights: number;
  104538. /**
  104539. * Stores the alpha values in a texture.
  104540. */
  104541. protected _opacityTexture: Nullable<BaseTexture>;
  104542. /**
  104543. * Stores the reflection values in a texture.
  104544. */
  104545. protected _reflectionTexture: Nullable<BaseTexture>;
  104546. /**
  104547. * Stores the emissive values in a texture.
  104548. */
  104549. protected _emissiveTexture: Nullable<BaseTexture>;
  104550. /**
  104551. * AKA Specular texture in other nomenclature.
  104552. */
  104553. protected _reflectivityTexture: Nullable<BaseTexture>;
  104554. /**
  104555. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104556. */
  104557. protected _metallicTexture: Nullable<BaseTexture>;
  104558. /**
  104559. * Specifies the metallic scalar of the metallic/roughness workflow.
  104560. * Can also be used to scale the metalness values of the metallic texture.
  104561. */
  104562. protected _metallic: Nullable<number>;
  104563. /**
  104564. * Specifies the roughness scalar of the metallic/roughness workflow.
  104565. * Can also be used to scale the roughness values of the metallic texture.
  104566. */
  104567. protected _roughness: Nullable<number>;
  104568. /**
  104569. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104570. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104571. */
  104572. protected _microSurfaceTexture: Nullable<BaseTexture>;
  104573. /**
  104574. * Stores surface normal data used to displace a mesh in a texture.
  104575. */
  104576. protected _bumpTexture: Nullable<BaseTexture>;
  104577. /**
  104578. * Stores the pre-calculated light information of a mesh in a texture.
  104579. */
  104580. protected _lightmapTexture: Nullable<BaseTexture>;
  104581. /**
  104582. * The color of a material in ambient lighting.
  104583. */
  104584. protected _ambientColor: Color3;
  104585. /**
  104586. * AKA Diffuse Color in other nomenclature.
  104587. */
  104588. protected _albedoColor: Color3;
  104589. /**
  104590. * AKA Specular Color in other nomenclature.
  104591. */
  104592. protected _reflectivityColor: Color3;
  104593. /**
  104594. * The color applied when light is reflected from a material.
  104595. */
  104596. protected _reflectionColor: Color3;
  104597. /**
  104598. * The color applied when light is emitted from a material.
  104599. */
  104600. protected _emissiveColor: Color3;
  104601. /**
  104602. * AKA Glossiness in other nomenclature.
  104603. */
  104604. protected _microSurface: number;
  104605. /**
  104606. * Specifies that the material will use the light map as a show map.
  104607. */
  104608. protected _useLightmapAsShadowmap: boolean;
  104609. /**
  104610. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104611. * makes the reflect vector face the model (under horizon).
  104612. */
  104613. protected _useHorizonOcclusion: boolean;
  104614. /**
  104615. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104616. * too much the area relying on ambient texture to define their ambient occlusion.
  104617. */
  104618. protected _useRadianceOcclusion: boolean;
  104619. /**
  104620. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104621. */
  104622. protected _useAlphaFromAlbedoTexture: boolean;
  104623. /**
  104624. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  104625. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104626. */
  104627. protected _useSpecularOverAlpha: boolean;
  104628. /**
  104629. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104630. */
  104631. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104632. /**
  104633. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104634. */
  104635. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  104636. /**
  104637. * Specifies if the metallic texture contains the roughness information in its green channel.
  104638. */
  104639. protected _useRoughnessFromMetallicTextureGreen: boolean;
  104640. /**
  104641. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104642. */
  104643. protected _useMetallnessFromMetallicTextureBlue: boolean;
  104644. /**
  104645. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104646. */
  104647. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  104648. /**
  104649. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104650. */
  104651. protected _useAmbientInGrayScale: boolean;
  104652. /**
  104653. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104654. * The material will try to infer what glossiness each pixel should be.
  104655. */
  104656. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  104657. /**
  104658. * Defines the falloff type used in this material.
  104659. * It by default is Physical.
  104660. */
  104661. protected _lightFalloff: number;
  104662. /**
  104663. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104664. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104665. */
  104666. protected _useRadianceOverAlpha: boolean;
  104667. /**
  104668. * Allows using an object space normal map (instead of tangent space).
  104669. */
  104670. protected _useObjectSpaceNormalMap: boolean;
  104671. /**
  104672. * Allows using the bump map in parallax mode.
  104673. */
  104674. protected _useParallax: boolean;
  104675. /**
  104676. * Allows using the bump map in parallax occlusion mode.
  104677. */
  104678. protected _useParallaxOcclusion: boolean;
  104679. /**
  104680. * Controls the scale bias of the parallax mode.
  104681. */
  104682. protected _parallaxScaleBias: number;
  104683. /**
  104684. * If sets to true, disables all the lights affecting the material.
  104685. */
  104686. protected _disableLighting: boolean;
  104687. /**
  104688. * Number of Simultaneous lights allowed on the material.
  104689. */
  104690. protected _maxSimultaneousLights: number;
  104691. /**
  104692. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104693. */
  104694. protected _invertNormalMapX: boolean;
  104695. /**
  104696. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104697. */
  104698. protected _invertNormalMapY: boolean;
  104699. /**
  104700. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104701. */
  104702. protected _twoSidedLighting: boolean;
  104703. /**
  104704. * Defines the alpha limits in alpha test mode.
  104705. */
  104706. protected _alphaCutOff: number;
  104707. /**
  104708. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104709. */
  104710. protected _forceAlphaTest: boolean;
  104711. /**
  104712. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104713. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104714. */
  104715. protected _useAlphaFresnel: boolean;
  104716. /**
  104717. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104718. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104719. */
  104720. protected _useLinearAlphaFresnel: boolean;
  104721. /**
  104722. * The transparency mode of the material.
  104723. */
  104724. protected _transparencyMode: Nullable<number>;
  104725. /**
  104726. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  104727. * from cos thetav and roughness:
  104728. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  104729. */
  104730. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  104731. /**
  104732. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104733. */
  104734. protected _forceIrradianceInFragment: boolean;
  104735. /**
  104736. * Force normal to face away from face.
  104737. */
  104738. protected _forceNormalForward: boolean;
  104739. /**
  104740. * Enables specular anti aliasing in the PBR shader.
  104741. * It will both interacts on the Geometry for analytical and IBL lighting.
  104742. * It also prefilter the roughness map based on the bump values.
  104743. */
  104744. protected _enableSpecularAntiAliasing: boolean;
  104745. /**
  104746. * Default configuration related to image processing available in the PBR Material.
  104747. */
  104748. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104749. /**
  104750. * Keep track of the image processing observer to allow dispose and replace.
  104751. */
  104752. private _imageProcessingObserver;
  104753. /**
  104754. * Attaches a new image processing configuration to the PBR Material.
  104755. * @param configuration
  104756. */
  104757. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104758. /**
  104759. * Stores the available render targets.
  104760. */
  104761. private _renderTargets;
  104762. /**
  104763. * Sets the global ambient color for the material used in lighting calculations.
  104764. */
  104765. private _globalAmbientColor;
  104766. /**
  104767. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  104768. */
  104769. private _useLogarithmicDepth;
  104770. /**
  104771. * If set to true, no lighting calculations will be applied.
  104772. */
  104773. private _unlit;
  104774. private _debugMode;
  104775. /**
  104776. * @hidden
  104777. * This is reserved for the inspector.
  104778. * Defines the material debug mode.
  104779. * It helps seeing only some components of the material while troubleshooting.
  104780. */
  104781. debugMode: number;
  104782. /**
  104783. * @hidden
  104784. * This is reserved for the inspector.
  104785. * Specify from where on screen the debug mode should start.
  104786. * The value goes from -1 (full screen) to 1 (not visible)
  104787. * It helps with side by side comparison against the final render
  104788. * This defaults to -1
  104789. */
  104790. private debugLimit;
  104791. /**
  104792. * @hidden
  104793. * This is reserved for the inspector.
  104794. * As the default viewing range might not be enough (if the ambient is really small for instance)
  104795. * You can use the factor to better multiply the final value.
  104796. */
  104797. private debugFactor;
  104798. /**
  104799. * Defines the clear coat layer parameters for the material.
  104800. */
  104801. readonly clearCoat: PBRClearCoatConfiguration;
  104802. /**
  104803. * Defines the anisotropic parameters for the material.
  104804. */
  104805. readonly anisotropy: PBRAnisotropicConfiguration;
  104806. /**
  104807. * Defines the BRDF parameters for the material.
  104808. */
  104809. readonly brdf: PBRBRDFConfiguration;
  104810. /**
  104811. * Defines the Sheen parameters for the material.
  104812. */
  104813. readonly sheen: PBRSheenConfiguration;
  104814. /**
  104815. * Defines the SubSurface parameters for the material.
  104816. */
  104817. readonly subSurface: PBRSubSurfaceConfiguration;
  104818. /**
  104819. * Custom callback helping to override the default shader used in the material.
  104820. */
  104821. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  104822. /**
  104823. * Instantiates a new PBRMaterial instance.
  104824. *
  104825. * @param name The material name
  104826. * @param scene The scene the material will be use in.
  104827. */
  104828. constructor(name: string, scene: Scene);
  104829. /**
  104830. * Gets a boolean indicating that current material needs to register RTT
  104831. */
  104832. readonly hasRenderTargetTextures: boolean;
  104833. /**
  104834. * Gets the name of the material class.
  104835. */
  104836. getClassName(): string;
  104837. /**
  104838. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104839. */
  104840. /**
  104841. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104842. */
  104843. useLogarithmicDepth: boolean;
  104844. /**
  104845. * Gets the current transparency mode.
  104846. */
  104847. /**
  104848. * Sets the transparency mode of the material.
  104849. *
  104850. * | Value | Type | Description |
  104851. * | ----- | ----------------------------------- | ----------- |
  104852. * | 0 | OPAQUE | |
  104853. * | 1 | ALPHATEST | |
  104854. * | 2 | ALPHABLEND | |
  104855. * | 3 | ALPHATESTANDBLEND | |
  104856. *
  104857. */
  104858. transparencyMode: Nullable<number>;
  104859. /**
  104860. * Returns true if alpha blending should be disabled.
  104861. */
  104862. private readonly _disableAlphaBlending;
  104863. /**
  104864. * Specifies whether or not this material should be rendered in alpha blend mode.
  104865. */
  104866. needAlphaBlending(): boolean;
  104867. /**
  104868. * Specifies if the mesh will require alpha blending.
  104869. * @param mesh - BJS mesh.
  104870. */
  104871. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104872. /**
  104873. * Specifies whether or not this material should be rendered in alpha test mode.
  104874. */
  104875. needAlphaTesting(): boolean;
  104876. /**
  104877. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  104878. */
  104879. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  104880. /**
  104881. * Gets the texture used for the alpha test.
  104882. */
  104883. getAlphaTestTexture(): Nullable<BaseTexture>;
  104884. /**
  104885. * Specifies that the submesh is ready to be used.
  104886. * @param mesh - BJS mesh.
  104887. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  104888. * @param useInstances - Specifies that instances should be used.
  104889. * @returns - boolean indicating that the submesh is ready or not.
  104890. */
  104891. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104892. /**
  104893. * Specifies if the material uses metallic roughness workflow.
  104894. * @returns boolean specifiying if the material uses metallic roughness workflow.
  104895. */
  104896. isMetallicWorkflow(): boolean;
  104897. private _prepareEffect;
  104898. private _prepareDefines;
  104899. /**
  104900. * Force shader compilation
  104901. */
  104902. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  104903. clipPlane: boolean;
  104904. }>): void;
  104905. /**
  104906. * Initializes the uniform buffer layout for the shader.
  104907. */
  104908. buildUniformLayout(): void;
  104909. /**
  104910. * Unbinds the material from the mesh
  104911. */
  104912. unbind(): void;
  104913. /**
  104914. * Binds the submesh data.
  104915. * @param world - The world matrix.
  104916. * @param mesh - The BJS mesh.
  104917. * @param subMesh - A submesh of the BJS mesh.
  104918. */
  104919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104920. /**
  104921. * Returns the animatable textures.
  104922. * @returns - Array of animatable textures.
  104923. */
  104924. getAnimatables(): IAnimatable[];
  104925. /**
  104926. * Returns the texture used for reflections.
  104927. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  104928. */
  104929. private _getReflectionTexture;
  104930. /**
  104931. * Returns an array of the actively used textures.
  104932. * @returns - Array of BaseTextures
  104933. */
  104934. getActiveTextures(): BaseTexture[];
  104935. /**
  104936. * Checks to see if a texture is used in the material.
  104937. * @param texture - Base texture to use.
  104938. * @returns - Boolean specifying if a texture is used in the material.
  104939. */
  104940. hasTexture(texture: BaseTexture): boolean;
  104941. /**
  104942. * Disposes the resources of the material.
  104943. * @param forceDisposeEffect - Forces the disposal of effects.
  104944. * @param forceDisposeTextures - Forces the disposal of all textures.
  104945. */
  104946. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104947. }
  104948. }
  104949. declare module BABYLON {
  104950. /**
  104951. * The Physically based material of BJS.
  104952. *
  104953. * This offers the main features of a standard PBR material.
  104954. * For more information, please refer to the documentation :
  104955. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104956. */
  104957. export class PBRMaterial extends PBRBaseMaterial {
  104958. /**
  104959. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104960. */
  104961. static readonly PBRMATERIAL_OPAQUE: number;
  104962. /**
  104963. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104964. */
  104965. static readonly PBRMATERIAL_ALPHATEST: number;
  104966. /**
  104967. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104968. */
  104969. static readonly PBRMATERIAL_ALPHABLEND: number;
  104970. /**
  104971. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104972. * They are also discarded below the alpha cutoff threshold to improve performances.
  104973. */
  104974. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104975. /**
  104976. * Defines the default value of how much AO map is occluding the analytical lights
  104977. * (point spot...).
  104978. */
  104979. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104980. /**
  104981. * Intensity of the direct lights e.g. the four lights available in your scene.
  104982. * This impacts both the direct diffuse and specular highlights.
  104983. */
  104984. directIntensity: number;
  104985. /**
  104986. * Intensity of the emissive part of the material.
  104987. * This helps controlling the emissive effect without modifying the emissive color.
  104988. */
  104989. emissiveIntensity: number;
  104990. /**
  104991. * Intensity of the environment e.g. how much the environment will light the object
  104992. * either through harmonics for rough material or through the refelction for shiny ones.
  104993. */
  104994. environmentIntensity: number;
  104995. /**
  104996. * This is a special control allowing the reduction of the specular highlights coming from the
  104997. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104998. */
  104999. specularIntensity: number;
  105000. /**
  105001. * Debug Control allowing disabling the bump map on this material.
  105002. */
  105003. disableBumpMap: boolean;
  105004. /**
  105005. * AKA Diffuse Texture in standard nomenclature.
  105006. */
  105007. albedoTexture: BaseTexture;
  105008. /**
  105009. * AKA Occlusion Texture in other nomenclature.
  105010. */
  105011. ambientTexture: BaseTexture;
  105012. /**
  105013. * AKA Occlusion Texture Intensity in other nomenclature.
  105014. */
  105015. ambientTextureStrength: number;
  105016. /**
  105017. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105018. * 1 means it completely occludes it
  105019. * 0 mean it has no impact
  105020. */
  105021. ambientTextureImpactOnAnalyticalLights: number;
  105022. /**
  105023. * Stores the alpha values in a texture.
  105024. */
  105025. opacityTexture: BaseTexture;
  105026. /**
  105027. * Stores the reflection values in a texture.
  105028. */
  105029. reflectionTexture: Nullable<BaseTexture>;
  105030. /**
  105031. * Stores the emissive values in a texture.
  105032. */
  105033. emissiveTexture: BaseTexture;
  105034. /**
  105035. * AKA Specular texture in other nomenclature.
  105036. */
  105037. reflectivityTexture: BaseTexture;
  105038. /**
  105039. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105040. */
  105041. metallicTexture: BaseTexture;
  105042. /**
  105043. * Specifies the metallic scalar of the metallic/roughness workflow.
  105044. * Can also be used to scale the metalness values of the metallic texture.
  105045. */
  105046. metallic: Nullable<number>;
  105047. /**
  105048. * Specifies the roughness scalar of the metallic/roughness workflow.
  105049. * Can also be used to scale the roughness values of the metallic texture.
  105050. */
  105051. roughness: Nullable<number>;
  105052. /**
  105053. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105054. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105055. */
  105056. microSurfaceTexture: BaseTexture;
  105057. /**
  105058. * Stores surface normal data used to displace a mesh in a texture.
  105059. */
  105060. bumpTexture: BaseTexture;
  105061. /**
  105062. * Stores the pre-calculated light information of a mesh in a texture.
  105063. */
  105064. lightmapTexture: BaseTexture;
  105065. /**
  105066. * Stores the refracted light information in a texture.
  105067. */
  105068. refractionTexture: Nullable<BaseTexture>;
  105069. /**
  105070. * The color of a material in ambient lighting.
  105071. */
  105072. ambientColor: Color3;
  105073. /**
  105074. * AKA Diffuse Color in other nomenclature.
  105075. */
  105076. albedoColor: Color3;
  105077. /**
  105078. * AKA Specular Color in other nomenclature.
  105079. */
  105080. reflectivityColor: Color3;
  105081. /**
  105082. * The color reflected from the material.
  105083. */
  105084. reflectionColor: Color3;
  105085. /**
  105086. * The color emitted from the material.
  105087. */
  105088. emissiveColor: Color3;
  105089. /**
  105090. * AKA Glossiness in other nomenclature.
  105091. */
  105092. microSurface: number;
  105093. /**
  105094. * source material index of refraction (IOR)' / 'destination material IOR.
  105095. */
  105096. indexOfRefraction: number;
  105097. /**
  105098. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105099. */
  105100. invertRefractionY: boolean;
  105101. /**
  105102. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105103. * Materials half opaque for instance using refraction could benefit from this control.
  105104. */
  105105. linkRefractionWithTransparency: boolean;
  105106. /**
  105107. * If true, the light map contains occlusion information instead of lighting info.
  105108. */
  105109. useLightmapAsShadowmap: boolean;
  105110. /**
  105111. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105112. */
  105113. useAlphaFromAlbedoTexture: boolean;
  105114. /**
  105115. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105116. */
  105117. forceAlphaTest: boolean;
  105118. /**
  105119. * Defines the alpha limits in alpha test mode.
  105120. */
  105121. alphaCutOff: number;
  105122. /**
  105123. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105124. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105125. */
  105126. useSpecularOverAlpha: boolean;
  105127. /**
  105128. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105129. */
  105130. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105131. /**
  105132. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105133. */
  105134. useRoughnessFromMetallicTextureAlpha: boolean;
  105135. /**
  105136. * Specifies if the metallic texture contains the roughness information in its green channel.
  105137. */
  105138. useRoughnessFromMetallicTextureGreen: boolean;
  105139. /**
  105140. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105141. */
  105142. useMetallnessFromMetallicTextureBlue: boolean;
  105143. /**
  105144. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105145. */
  105146. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105147. /**
  105148. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105149. */
  105150. useAmbientInGrayScale: boolean;
  105151. /**
  105152. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105153. * The material will try to infer what glossiness each pixel should be.
  105154. */
  105155. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105156. /**
  105157. * BJS is using an harcoded light falloff based on a manually sets up range.
  105158. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105159. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105160. */
  105161. /**
  105162. * BJS is using an harcoded light falloff based on a manually sets up range.
  105163. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105164. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105165. */
  105166. usePhysicalLightFalloff: boolean;
  105167. /**
  105168. * In order to support the falloff compatibility with gltf, a special mode has been added
  105169. * to reproduce the gltf light falloff.
  105170. */
  105171. /**
  105172. * In order to support the falloff compatibility with gltf, a special mode has been added
  105173. * to reproduce the gltf light falloff.
  105174. */
  105175. useGLTFLightFalloff: boolean;
  105176. /**
  105177. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105178. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105179. */
  105180. useRadianceOverAlpha: boolean;
  105181. /**
  105182. * Allows using an object space normal map (instead of tangent space).
  105183. */
  105184. useObjectSpaceNormalMap: boolean;
  105185. /**
  105186. * Allows using the bump map in parallax mode.
  105187. */
  105188. useParallax: boolean;
  105189. /**
  105190. * Allows using the bump map in parallax occlusion mode.
  105191. */
  105192. useParallaxOcclusion: boolean;
  105193. /**
  105194. * Controls the scale bias of the parallax mode.
  105195. */
  105196. parallaxScaleBias: number;
  105197. /**
  105198. * If sets to true, disables all the lights affecting the material.
  105199. */
  105200. disableLighting: boolean;
  105201. /**
  105202. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105203. */
  105204. forceIrradianceInFragment: boolean;
  105205. /**
  105206. * Number of Simultaneous lights allowed on the material.
  105207. */
  105208. maxSimultaneousLights: number;
  105209. /**
  105210. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105211. */
  105212. invertNormalMapX: boolean;
  105213. /**
  105214. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105215. */
  105216. invertNormalMapY: boolean;
  105217. /**
  105218. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105219. */
  105220. twoSidedLighting: boolean;
  105221. /**
  105222. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105223. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105224. */
  105225. useAlphaFresnel: boolean;
  105226. /**
  105227. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105228. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105229. */
  105230. useLinearAlphaFresnel: boolean;
  105231. /**
  105232. * Let user defines the brdf lookup texture used for IBL.
  105233. * A default 8bit version is embedded but you could point at :
  105234. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105235. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105236. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105237. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105238. */
  105239. environmentBRDFTexture: Nullable<BaseTexture>;
  105240. /**
  105241. * Force normal to face away from face.
  105242. */
  105243. forceNormalForward: boolean;
  105244. /**
  105245. * Enables specular anti aliasing in the PBR shader.
  105246. * It will both interacts on the Geometry for analytical and IBL lighting.
  105247. * It also prefilter the roughness map based on the bump values.
  105248. */
  105249. enableSpecularAntiAliasing: boolean;
  105250. /**
  105251. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105252. * makes the reflect vector face the model (under horizon).
  105253. */
  105254. useHorizonOcclusion: boolean;
  105255. /**
  105256. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105257. * too much the area relying on ambient texture to define their ambient occlusion.
  105258. */
  105259. useRadianceOcclusion: boolean;
  105260. /**
  105261. * If set to true, no lighting calculations will be applied.
  105262. */
  105263. unlit: boolean;
  105264. /**
  105265. * Gets the image processing configuration used either in this material.
  105266. */
  105267. /**
  105268. * Sets the Default image processing configuration used either in the this material.
  105269. *
  105270. * If sets to null, the scene one is in use.
  105271. */
  105272. imageProcessingConfiguration: ImageProcessingConfiguration;
  105273. /**
  105274. * Gets wether the color curves effect is enabled.
  105275. */
  105276. /**
  105277. * Sets wether the color curves effect is enabled.
  105278. */
  105279. cameraColorCurvesEnabled: boolean;
  105280. /**
  105281. * Gets wether the color grading effect is enabled.
  105282. */
  105283. /**
  105284. * Gets wether the color grading effect is enabled.
  105285. */
  105286. cameraColorGradingEnabled: boolean;
  105287. /**
  105288. * Gets wether tonemapping is enabled or not.
  105289. */
  105290. /**
  105291. * Sets wether tonemapping is enabled or not
  105292. */
  105293. cameraToneMappingEnabled: boolean;
  105294. /**
  105295. * The camera exposure used on this material.
  105296. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105297. * This corresponds to a photographic exposure.
  105298. */
  105299. /**
  105300. * The camera exposure used on this material.
  105301. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105302. * This corresponds to a photographic exposure.
  105303. */
  105304. cameraExposure: number;
  105305. /**
  105306. * Gets The camera contrast used on this material.
  105307. */
  105308. /**
  105309. * Sets The camera contrast used on this material.
  105310. */
  105311. cameraContrast: number;
  105312. /**
  105313. * Gets the Color Grading 2D Lookup Texture.
  105314. */
  105315. /**
  105316. * Sets the Color Grading 2D Lookup Texture.
  105317. */
  105318. cameraColorGradingTexture: Nullable<BaseTexture>;
  105319. /**
  105320. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105321. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105322. * 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;
  105323. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105324. */
  105325. /**
  105326. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105327. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105328. * 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;
  105329. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105330. */
  105331. cameraColorCurves: Nullable<ColorCurves>;
  105332. /**
  105333. * Instantiates a new PBRMaterial instance.
  105334. *
  105335. * @param name The material name
  105336. * @param scene The scene the material will be use in.
  105337. */
  105338. constructor(name: string, scene: Scene);
  105339. /**
  105340. * Returns the name of this material class.
  105341. */
  105342. getClassName(): string;
  105343. /**
  105344. * Makes a duplicate of the current material.
  105345. * @param name - name to use for the new material.
  105346. */
  105347. clone(name: string): PBRMaterial;
  105348. /**
  105349. * Serializes this PBR Material.
  105350. * @returns - An object with the serialized material.
  105351. */
  105352. serialize(): any;
  105353. /**
  105354. * Parses a PBR Material from a serialized object.
  105355. * @param source - Serialized object.
  105356. * @param scene - BJS scene instance.
  105357. * @param rootUrl - url for the scene object
  105358. * @returns - PBRMaterial
  105359. */
  105360. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105361. }
  105362. }
  105363. declare module BABYLON {
  105364. /**
  105365. * Direct draw surface info
  105366. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105367. */
  105368. export interface DDSInfo {
  105369. /**
  105370. * Width of the texture
  105371. */
  105372. width: number;
  105373. /**
  105374. * Width of the texture
  105375. */
  105376. height: number;
  105377. /**
  105378. * Number of Mipmaps for the texture
  105379. * @see https://en.wikipedia.org/wiki/Mipmap
  105380. */
  105381. mipmapCount: number;
  105382. /**
  105383. * If the textures format is a known fourCC format
  105384. * @see https://www.fourcc.org/
  105385. */
  105386. isFourCC: boolean;
  105387. /**
  105388. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105389. */
  105390. isRGB: boolean;
  105391. /**
  105392. * If the texture is a lumincance format
  105393. */
  105394. isLuminance: boolean;
  105395. /**
  105396. * If this is a cube texture
  105397. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105398. */
  105399. isCube: boolean;
  105400. /**
  105401. * If the texture is a compressed format eg. FOURCC_DXT1
  105402. */
  105403. isCompressed: boolean;
  105404. /**
  105405. * The dxgiFormat of the texture
  105406. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105407. */
  105408. dxgiFormat: number;
  105409. /**
  105410. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105411. */
  105412. textureType: number;
  105413. /**
  105414. * Sphericle polynomial created for the dds texture
  105415. */
  105416. sphericalPolynomial?: SphericalPolynomial;
  105417. }
  105418. /**
  105419. * Class used to provide DDS decompression tools
  105420. */
  105421. export class DDSTools {
  105422. /**
  105423. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105424. */
  105425. static StoreLODInAlphaChannel: boolean;
  105426. /**
  105427. * Gets DDS information from an array buffer
  105428. * @param arrayBuffer defines the array buffer to read data from
  105429. * @returns the DDS information
  105430. */
  105431. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105432. private static _FloatView;
  105433. private static _Int32View;
  105434. private static _ToHalfFloat;
  105435. private static _FromHalfFloat;
  105436. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105437. private static _GetHalfFloatRGBAArrayBuffer;
  105438. private static _GetFloatRGBAArrayBuffer;
  105439. private static _GetFloatAsUIntRGBAArrayBuffer;
  105440. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105441. private static _GetRGBAArrayBuffer;
  105442. private static _ExtractLongWordOrder;
  105443. private static _GetRGBArrayBuffer;
  105444. private static _GetLuminanceArrayBuffer;
  105445. /**
  105446. * Uploads DDS Levels to a Babylon Texture
  105447. * @hidden
  105448. */
  105449. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105450. }
  105451. interface Engine {
  105452. /**
  105453. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105454. * @param rootUrl defines the url where the file to load is located
  105455. * @param scene defines the current scene
  105456. * @param lodScale defines scale to apply to the mip map selection
  105457. * @param lodOffset defines offset to apply to the mip map selection
  105458. * @param onLoad defines an optional callback raised when the texture is loaded
  105459. * @param onError defines an optional callback raised if there is an issue to load the texture
  105460. * @param format defines the format of the data
  105461. * @param forcedExtension defines the extension to use to pick the right loader
  105462. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105463. * @returns the cube texture as an InternalTexture
  105464. */
  105465. 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;
  105466. }
  105467. }
  105468. declare module BABYLON {
  105469. /**
  105470. * Implementation of the DDS Texture Loader.
  105471. * @hidden
  105472. */
  105473. export class _DDSTextureLoader implements IInternalTextureLoader {
  105474. /**
  105475. * Defines wether the loader supports cascade loading the different faces.
  105476. */
  105477. readonly supportCascades: boolean;
  105478. /**
  105479. * This returns if the loader support the current file information.
  105480. * @param extension defines the file extension of the file being loaded
  105481. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105482. * @param fallback defines the fallback internal texture if any
  105483. * @param isBase64 defines whether the texture is encoded as a base64
  105484. * @param isBuffer defines whether the texture data are stored as a buffer
  105485. * @returns true if the loader can load the specified file
  105486. */
  105487. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105488. /**
  105489. * Transform the url before loading if required.
  105490. * @param rootUrl the url of the texture
  105491. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105492. * @returns the transformed texture
  105493. */
  105494. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105495. /**
  105496. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105497. * @param rootUrl the url of the texture
  105498. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105499. * @returns the fallback texture
  105500. */
  105501. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105502. /**
  105503. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105504. * @param data contains the texture data
  105505. * @param texture defines the BabylonJS internal texture
  105506. * @param createPolynomials will be true if polynomials have been requested
  105507. * @param onLoad defines the callback to trigger once the texture is ready
  105508. * @param onError defines the callback to trigger in case of error
  105509. */
  105510. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105511. /**
  105512. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105513. * @param data contains the texture data
  105514. * @param texture defines the BabylonJS internal texture
  105515. * @param callback defines the method to call once ready to upload
  105516. */
  105517. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105518. }
  105519. }
  105520. declare module BABYLON {
  105521. /** @hidden */
  105522. export var rgbdEncodePixelShader: {
  105523. name: string;
  105524. shader: string;
  105525. };
  105526. }
  105527. declare module BABYLON {
  105528. /**
  105529. * Raw texture data and descriptor sufficient for WebGL texture upload
  105530. */
  105531. export interface EnvironmentTextureInfo {
  105532. /**
  105533. * Version of the environment map
  105534. */
  105535. version: number;
  105536. /**
  105537. * Width of image
  105538. */
  105539. width: number;
  105540. /**
  105541. * Irradiance information stored in the file.
  105542. */
  105543. irradiance: any;
  105544. /**
  105545. * Specular information stored in the file.
  105546. */
  105547. specular: any;
  105548. }
  105549. /**
  105550. * Sets of helpers addressing the serialization and deserialization of environment texture
  105551. * stored in a BabylonJS env file.
  105552. * Those files are usually stored as .env files.
  105553. */
  105554. export class EnvironmentTextureTools {
  105555. /**
  105556. * Magic number identifying the env file.
  105557. */
  105558. private static _MagicBytes;
  105559. /**
  105560. * Gets the environment info from an env file.
  105561. * @param data The array buffer containing the .env bytes.
  105562. * @returns the environment file info (the json header) if successfully parsed.
  105563. */
  105564. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  105565. /**
  105566. * Creates an environment texture from a loaded cube texture.
  105567. * @param texture defines the cube texture to convert in env file
  105568. * @return a promise containing the environment data if succesfull.
  105569. */
  105570. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  105571. /**
  105572. * Creates a JSON representation of the spherical data.
  105573. * @param texture defines the texture containing the polynomials
  105574. * @return the JSON representation of the spherical info
  105575. */
  105576. private static _CreateEnvTextureIrradiance;
  105577. /**
  105578. * Uploads the texture info contained in the env file to the GPU.
  105579. * @param texture defines the internal texture to upload to
  105580. * @param arrayBuffer defines the buffer cotaining the data to load
  105581. * @param info defines the texture info retrieved through the GetEnvInfo method
  105582. * @returns a promise
  105583. */
  105584. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  105585. /**
  105586. * Uploads the levels of image data to the GPU.
  105587. * @param texture defines the internal texture to upload to
  105588. * @param imageData defines the array buffer views of image data [mipmap][face]
  105589. * @returns a promise
  105590. */
  105591. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  105592. /**
  105593. * Uploads spherical polynomials information to the texture.
  105594. * @param texture defines the texture we are trying to upload the information to
  105595. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  105596. */
  105597. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  105598. /** @hidden */
  105599. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105600. }
  105601. }
  105602. declare module BABYLON {
  105603. /**
  105604. * Implementation of the ENV Texture Loader.
  105605. * @hidden
  105606. */
  105607. export class _ENVTextureLoader implements IInternalTextureLoader {
  105608. /**
  105609. * Defines wether the loader supports cascade loading the different faces.
  105610. */
  105611. readonly supportCascades: boolean;
  105612. /**
  105613. * This returns if the loader support the current file information.
  105614. * @param extension defines the file extension of the file being loaded
  105615. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105616. * @param fallback defines the fallback internal texture if any
  105617. * @param isBase64 defines whether the texture is encoded as a base64
  105618. * @param isBuffer defines whether the texture data are stored as a buffer
  105619. * @returns true if the loader can load the specified file
  105620. */
  105621. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105622. /**
  105623. * Transform the url before loading if required.
  105624. * @param rootUrl the url of the texture
  105625. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105626. * @returns the transformed texture
  105627. */
  105628. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105629. /**
  105630. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105631. * @param rootUrl the url of the texture
  105632. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105633. * @returns the fallback texture
  105634. */
  105635. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105636. /**
  105637. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105638. * @param data contains the texture data
  105639. * @param texture defines the BabylonJS internal texture
  105640. * @param createPolynomials will be true if polynomials have been requested
  105641. * @param onLoad defines the callback to trigger once the texture is ready
  105642. * @param onError defines the callback to trigger in case of error
  105643. */
  105644. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105645. /**
  105646. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105647. * @param data contains the texture data
  105648. * @param texture defines the BabylonJS internal texture
  105649. * @param callback defines the method to call once ready to upload
  105650. */
  105651. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105652. }
  105653. }
  105654. declare module BABYLON {
  105655. /**
  105656. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  105657. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  105658. */
  105659. export class KhronosTextureContainer {
  105660. /** contents of the KTX container file */
  105661. arrayBuffer: any;
  105662. private static HEADER_LEN;
  105663. private static COMPRESSED_2D;
  105664. private static COMPRESSED_3D;
  105665. private static TEX_2D;
  105666. private static TEX_3D;
  105667. /**
  105668. * Gets the openGL type
  105669. */
  105670. glType: number;
  105671. /**
  105672. * Gets the openGL type size
  105673. */
  105674. glTypeSize: number;
  105675. /**
  105676. * Gets the openGL format
  105677. */
  105678. glFormat: number;
  105679. /**
  105680. * Gets the openGL internal format
  105681. */
  105682. glInternalFormat: number;
  105683. /**
  105684. * Gets the base internal format
  105685. */
  105686. glBaseInternalFormat: number;
  105687. /**
  105688. * Gets image width in pixel
  105689. */
  105690. pixelWidth: number;
  105691. /**
  105692. * Gets image height in pixel
  105693. */
  105694. pixelHeight: number;
  105695. /**
  105696. * Gets image depth in pixels
  105697. */
  105698. pixelDepth: number;
  105699. /**
  105700. * Gets the number of array elements
  105701. */
  105702. numberOfArrayElements: number;
  105703. /**
  105704. * Gets the number of faces
  105705. */
  105706. numberOfFaces: number;
  105707. /**
  105708. * Gets the number of mipmap levels
  105709. */
  105710. numberOfMipmapLevels: number;
  105711. /**
  105712. * Gets the bytes of key value data
  105713. */
  105714. bytesOfKeyValueData: number;
  105715. /**
  105716. * Gets the load type
  105717. */
  105718. loadType: number;
  105719. /**
  105720. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  105721. */
  105722. isInvalid: boolean;
  105723. /**
  105724. * Creates a new KhronosTextureContainer
  105725. * @param arrayBuffer contents of the KTX container file
  105726. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  105727. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  105728. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  105729. */
  105730. constructor(
  105731. /** contents of the KTX container file */
  105732. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  105733. /**
  105734. * Uploads KTX content to a Babylon Texture.
  105735. * It is assumed that the texture has already been created & is currently bound
  105736. * @hidden
  105737. */
  105738. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  105739. private _upload2DCompressedLevels;
  105740. }
  105741. }
  105742. declare module BABYLON {
  105743. /**
  105744. * Implementation of the KTX Texture Loader.
  105745. * @hidden
  105746. */
  105747. export class _KTXTextureLoader implements IInternalTextureLoader {
  105748. /**
  105749. * Defines wether the loader supports cascade loading the different faces.
  105750. */
  105751. readonly supportCascades: boolean;
  105752. /**
  105753. * This returns if the loader support the current file information.
  105754. * @param extension defines the file extension of the file being loaded
  105755. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105756. * @param fallback defines the fallback internal texture if any
  105757. * @param isBase64 defines whether the texture is encoded as a base64
  105758. * @param isBuffer defines whether the texture data are stored as a buffer
  105759. * @returns true if the loader can load the specified file
  105760. */
  105761. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105762. /**
  105763. * Transform the url before loading if required.
  105764. * @param rootUrl the url of the texture
  105765. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105766. * @returns the transformed texture
  105767. */
  105768. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105769. /**
  105770. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105771. * @param rootUrl the url of the texture
  105772. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105773. * @returns the fallback texture
  105774. */
  105775. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105776. /**
  105777. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105778. * @param data contains the texture data
  105779. * @param texture defines the BabylonJS internal texture
  105780. * @param createPolynomials will be true if polynomials have been requested
  105781. * @param onLoad defines the callback to trigger once the texture is ready
  105782. * @param onError defines the callback to trigger in case of error
  105783. */
  105784. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105785. /**
  105786. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105787. * @param data contains the texture data
  105788. * @param texture defines the BabylonJS internal texture
  105789. * @param callback defines the method to call once ready to upload
  105790. */
  105791. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  105792. }
  105793. }
  105794. declare module BABYLON {
  105795. /** @hidden */
  105796. export var _forceSceneHelpersToBundle: boolean;
  105797. interface Scene {
  105798. /**
  105799. * Creates a default light for the scene.
  105800. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  105801. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  105802. */
  105803. createDefaultLight(replace?: boolean): void;
  105804. /**
  105805. * Creates a default camera for the scene.
  105806. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  105807. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105808. * @param replace has default false, when true replaces the active camera in the scene
  105809. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  105810. */
  105811. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105812. /**
  105813. * Creates a default camera and a default light.
  105814. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  105815. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105816. * @param replace has the default false, when true replaces the active camera/light in the scene
  105817. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  105818. */
  105819. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105820. /**
  105821. * Creates a new sky box
  105822. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  105823. * @param environmentTexture defines the texture to use as environment texture
  105824. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  105825. * @param scale defines the overall scale of the skybox
  105826. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  105827. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  105828. * @returns a new mesh holding the sky box
  105829. */
  105830. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  105831. /**
  105832. * Creates a new environment
  105833. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  105834. * @param options defines the options you can use to configure the environment
  105835. * @returns the new EnvironmentHelper
  105836. */
  105837. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  105838. /**
  105839. * Creates a new VREXperienceHelper
  105840. * @see http://doc.babylonjs.com/how_to/webvr_helper
  105841. * @param webVROptions defines the options used to create the new VREXperienceHelper
  105842. * @returns a new VREXperienceHelper
  105843. */
  105844. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  105845. /**
  105846. * Creates a new XREXperienceHelper
  105847. * @see http://doc.babylonjs.com/how_to/webxr
  105848. * @returns a promise for a new XREXperienceHelper
  105849. */
  105850. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  105851. }
  105852. }
  105853. declare module BABYLON {
  105854. /**
  105855. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  105856. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  105857. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  105858. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  105859. */
  105860. export class VideoDome extends TransformNode {
  105861. /**
  105862. * Define the video source as a Monoscopic panoramic 360 video.
  105863. */
  105864. static readonly MODE_MONOSCOPIC: number;
  105865. /**
  105866. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105867. */
  105868. static readonly MODE_TOPBOTTOM: number;
  105869. /**
  105870. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105871. */
  105872. static readonly MODE_SIDEBYSIDE: number;
  105873. private _useDirectMapping;
  105874. /**
  105875. * The video texture being displayed on the sphere
  105876. */
  105877. protected _videoTexture: VideoTexture;
  105878. /**
  105879. * Gets the video texture being displayed on the sphere
  105880. */
  105881. readonly videoTexture: VideoTexture;
  105882. /**
  105883. * The skybox material
  105884. */
  105885. protected _material: BackgroundMaterial;
  105886. /**
  105887. * The surface used for the skybox
  105888. */
  105889. protected _mesh: Mesh;
  105890. /**
  105891. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  105892. * Also see the options.resolution property.
  105893. */
  105894. fovMultiplier: number;
  105895. private _videoMode;
  105896. /**
  105897. * Gets or set the current video mode for the video. It can be:
  105898. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  105899. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105900. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105901. */
  105902. videoMode: number;
  105903. /**
  105904. * Oberserver used in Stereoscopic VR Mode.
  105905. */
  105906. private _onBeforeCameraRenderObserver;
  105907. /**
  105908. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  105909. * @param name Element's name, child elements will append suffixes for their own names.
  105910. * @param urlsOrVideo defines the url(s) or the video element to use
  105911. * @param options An object containing optional or exposed sub element properties
  105912. */
  105913. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  105914. resolution?: number;
  105915. clickToPlay?: boolean;
  105916. autoPlay?: boolean;
  105917. loop?: boolean;
  105918. size?: number;
  105919. poster?: string;
  105920. faceForward?: boolean;
  105921. useDirectMapping?: boolean;
  105922. }, scene: Scene);
  105923. private _changeVideoMode;
  105924. /**
  105925. * Releases resources associated with this node.
  105926. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105927. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105928. */
  105929. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105930. }
  105931. }
  105932. declare module BABYLON {
  105933. /**
  105934. * This class can be used to get instrumentation data from a Babylon engine
  105935. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105936. */
  105937. export class EngineInstrumentation implements IDisposable {
  105938. /**
  105939. * Define the instrumented engine.
  105940. */
  105941. engine: Engine;
  105942. private _captureGPUFrameTime;
  105943. private _gpuFrameTimeToken;
  105944. private _gpuFrameTime;
  105945. private _captureShaderCompilationTime;
  105946. private _shaderCompilationTime;
  105947. private _onBeginFrameObserver;
  105948. private _onEndFrameObserver;
  105949. private _onBeforeShaderCompilationObserver;
  105950. private _onAfterShaderCompilationObserver;
  105951. /**
  105952. * Gets the perf counter used for GPU frame time
  105953. */
  105954. readonly gpuFrameTimeCounter: PerfCounter;
  105955. /**
  105956. * Gets the GPU frame time capture status
  105957. */
  105958. /**
  105959. * Enable or disable the GPU frame time capture
  105960. */
  105961. captureGPUFrameTime: boolean;
  105962. /**
  105963. * Gets the perf counter used for shader compilation time
  105964. */
  105965. readonly shaderCompilationTimeCounter: PerfCounter;
  105966. /**
  105967. * Gets the shader compilation time capture status
  105968. */
  105969. /**
  105970. * Enable or disable the shader compilation time capture
  105971. */
  105972. captureShaderCompilationTime: boolean;
  105973. /**
  105974. * Instantiates a new engine instrumentation.
  105975. * This class can be used to get instrumentation data from a Babylon engine
  105976. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105977. * @param engine Defines the engine to instrument
  105978. */
  105979. constructor(
  105980. /**
  105981. * Define the instrumented engine.
  105982. */
  105983. engine: Engine);
  105984. /**
  105985. * Dispose and release associated resources.
  105986. */
  105987. dispose(): void;
  105988. }
  105989. }
  105990. declare module BABYLON {
  105991. /**
  105992. * This class can be used to get instrumentation data from a Babylon engine
  105993. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105994. */
  105995. export class SceneInstrumentation implements IDisposable {
  105996. /**
  105997. * Defines the scene to instrument
  105998. */
  105999. scene: Scene;
  106000. private _captureActiveMeshesEvaluationTime;
  106001. private _activeMeshesEvaluationTime;
  106002. private _captureRenderTargetsRenderTime;
  106003. private _renderTargetsRenderTime;
  106004. private _captureFrameTime;
  106005. private _frameTime;
  106006. private _captureRenderTime;
  106007. private _renderTime;
  106008. private _captureInterFrameTime;
  106009. private _interFrameTime;
  106010. private _captureParticlesRenderTime;
  106011. private _particlesRenderTime;
  106012. private _captureSpritesRenderTime;
  106013. private _spritesRenderTime;
  106014. private _capturePhysicsTime;
  106015. private _physicsTime;
  106016. private _captureAnimationsTime;
  106017. private _animationsTime;
  106018. private _captureCameraRenderTime;
  106019. private _cameraRenderTime;
  106020. private _onBeforeActiveMeshesEvaluationObserver;
  106021. private _onAfterActiveMeshesEvaluationObserver;
  106022. private _onBeforeRenderTargetsRenderObserver;
  106023. private _onAfterRenderTargetsRenderObserver;
  106024. private _onAfterRenderObserver;
  106025. private _onBeforeDrawPhaseObserver;
  106026. private _onAfterDrawPhaseObserver;
  106027. private _onBeforeAnimationsObserver;
  106028. private _onBeforeParticlesRenderingObserver;
  106029. private _onAfterParticlesRenderingObserver;
  106030. private _onBeforeSpritesRenderingObserver;
  106031. private _onAfterSpritesRenderingObserver;
  106032. private _onBeforePhysicsObserver;
  106033. private _onAfterPhysicsObserver;
  106034. private _onAfterAnimationsObserver;
  106035. private _onBeforeCameraRenderObserver;
  106036. private _onAfterCameraRenderObserver;
  106037. /**
  106038. * Gets the perf counter used for active meshes evaluation time
  106039. */
  106040. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106041. /**
  106042. * Gets the active meshes evaluation time capture status
  106043. */
  106044. /**
  106045. * Enable or disable the active meshes evaluation time capture
  106046. */
  106047. captureActiveMeshesEvaluationTime: boolean;
  106048. /**
  106049. * Gets the perf counter used for render targets render time
  106050. */
  106051. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106052. /**
  106053. * Gets the render targets render time capture status
  106054. */
  106055. /**
  106056. * Enable or disable the render targets render time capture
  106057. */
  106058. captureRenderTargetsRenderTime: boolean;
  106059. /**
  106060. * Gets the perf counter used for particles render time
  106061. */
  106062. readonly particlesRenderTimeCounter: PerfCounter;
  106063. /**
  106064. * Gets the particles render time capture status
  106065. */
  106066. /**
  106067. * Enable or disable the particles render time capture
  106068. */
  106069. captureParticlesRenderTime: boolean;
  106070. /**
  106071. * Gets the perf counter used for sprites render time
  106072. */
  106073. readonly spritesRenderTimeCounter: PerfCounter;
  106074. /**
  106075. * Gets the sprites render time capture status
  106076. */
  106077. /**
  106078. * Enable or disable the sprites render time capture
  106079. */
  106080. captureSpritesRenderTime: boolean;
  106081. /**
  106082. * Gets the perf counter used for physics time
  106083. */
  106084. readonly physicsTimeCounter: PerfCounter;
  106085. /**
  106086. * Gets the physics time capture status
  106087. */
  106088. /**
  106089. * Enable or disable the physics time capture
  106090. */
  106091. capturePhysicsTime: boolean;
  106092. /**
  106093. * Gets the perf counter used for animations time
  106094. */
  106095. readonly animationsTimeCounter: PerfCounter;
  106096. /**
  106097. * Gets the animations time capture status
  106098. */
  106099. /**
  106100. * Enable or disable the animations time capture
  106101. */
  106102. captureAnimationsTime: boolean;
  106103. /**
  106104. * Gets the perf counter used for frame time capture
  106105. */
  106106. readonly frameTimeCounter: PerfCounter;
  106107. /**
  106108. * Gets the frame time capture status
  106109. */
  106110. /**
  106111. * Enable or disable the frame time capture
  106112. */
  106113. captureFrameTime: boolean;
  106114. /**
  106115. * Gets the perf counter used for inter-frames time capture
  106116. */
  106117. readonly interFrameTimeCounter: PerfCounter;
  106118. /**
  106119. * Gets the inter-frames time capture status
  106120. */
  106121. /**
  106122. * Enable or disable the inter-frames time capture
  106123. */
  106124. captureInterFrameTime: boolean;
  106125. /**
  106126. * Gets the perf counter used for render time capture
  106127. */
  106128. readonly renderTimeCounter: PerfCounter;
  106129. /**
  106130. * Gets the render time capture status
  106131. */
  106132. /**
  106133. * Enable or disable the render time capture
  106134. */
  106135. captureRenderTime: boolean;
  106136. /**
  106137. * Gets the perf counter used for camera render time capture
  106138. */
  106139. readonly cameraRenderTimeCounter: PerfCounter;
  106140. /**
  106141. * Gets the camera render time capture status
  106142. */
  106143. /**
  106144. * Enable or disable the camera render time capture
  106145. */
  106146. captureCameraRenderTime: boolean;
  106147. /**
  106148. * Gets the perf counter used for draw calls
  106149. */
  106150. readonly drawCallsCounter: PerfCounter;
  106151. /**
  106152. * Instantiates a new scene instrumentation.
  106153. * This class can be used to get instrumentation data from a Babylon engine
  106154. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106155. * @param scene Defines the scene to instrument
  106156. */
  106157. constructor(
  106158. /**
  106159. * Defines the scene to instrument
  106160. */
  106161. scene: Scene);
  106162. /**
  106163. * Dispose and release associated resources.
  106164. */
  106165. dispose(): void;
  106166. }
  106167. }
  106168. declare module BABYLON {
  106169. /** @hidden */
  106170. export var glowMapGenerationPixelShader: {
  106171. name: string;
  106172. shader: string;
  106173. };
  106174. }
  106175. declare module BABYLON {
  106176. /** @hidden */
  106177. export var glowMapGenerationVertexShader: {
  106178. name: string;
  106179. shader: string;
  106180. };
  106181. }
  106182. declare module BABYLON {
  106183. /**
  106184. * Effect layer options. This helps customizing the behaviour
  106185. * of the effect layer.
  106186. */
  106187. export interface IEffectLayerOptions {
  106188. /**
  106189. * Multiplication factor apply to the canvas size to compute the render target size
  106190. * used to generated the objects (the smaller the faster).
  106191. */
  106192. mainTextureRatio: number;
  106193. /**
  106194. * Enforces a fixed size texture to ensure effect stability across devices.
  106195. */
  106196. mainTextureFixedSize?: number;
  106197. /**
  106198. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106199. */
  106200. alphaBlendingMode: number;
  106201. /**
  106202. * The camera attached to the layer.
  106203. */
  106204. camera: Nullable<Camera>;
  106205. /**
  106206. * The rendering group to draw the layer in.
  106207. */
  106208. renderingGroupId: number;
  106209. }
  106210. /**
  106211. * The effect layer Helps adding post process effect blended with the main pass.
  106212. *
  106213. * This can be for instance use to generate glow or higlight effects on the scene.
  106214. *
  106215. * The effect layer class can not be used directly and is intented to inherited from to be
  106216. * customized per effects.
  106217. */
  106218. export abstract class EffectLayer {
  106219. private _vertexBuffers;
  106220. private _indexBuffer;
  106221. private _cachedDefines;
  106222. private _effectLayerMapGenerationEffect;
  106223. private _effectLayerOptions;
  106224. private _mergeEffect;
  106225. protected _scene: Scene;
  106226. protected _engine: Engine;
  106227. protected _maxSize: number;
  106228. protected _mainTextureDesiredSize: ISize;
  106229. protected _mainTexture: RenderTargetTexture;
  106230. protected _shouldRender: boolean;
  106231. protected _postProcesses: PostProcess[];
  106232. protected _textures: BaseTexture[];
  106233. protected _emissiveTextureAndColor: {
  106234. texture: Nullable<BaseTexture>;
  106235. color: Color4;
  106236. };
  106237. /**
  106238. * The name of the layer
  106239. */
  106240. name: string;
  106241. /**
  106242. * The clear color of the texture used to generate the glow map.
  106243. */
  106244. neutralColor: Color4;
  106245. /**
  106246. * Specifies wether the highlight layer is enabled or not.
  106247. */
  106248. isEnabled: boolean;
  106249. /**
  106250. * Gets the camera attached to the layer.
  106251. */
  106252. readonly camera: Nullable<Camera>;
  106253. /**
  106254. * Gets the rendering group id the layer should render in.
  106255. */
  106256. readonly renderingGroupId: number;
  106257. /**
  106258. * An event triggered when the effect layer has been disposed.
  106259. */
  106260. onDisposeObservable: Observable<EffectLayer>;
  106261. /**
  106262. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106263. */
  106264. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106265. /**
  106266. * An event triggered when the generated texture is being merged in the scene.
  106267. */
  106268. onBeforeComposeObservable: Observable<EffectLayer>;
  106269. /**
  106270. * An event triggered when the generated texture has been merged in the scene.
  106271. */
  106272. onAfterComposeObservable: Observable<EffectLayer>;
  106273. /**
  106274. * An event triggered when the efffect layer changes its size.
  106275. */
  106276. onSizeChangedObservable: Observable<EffectLayer>;
  106277. /** @hidden */
  106278. static _SceneComponentInitialization: (scene: Scene) => void;
  106279. /**
  106280. * Instantiates a new effect Layer and references it in the scene.
  106281. * @param name The name of the layer
  106282. * @param scene The scene to use the layer in
  106283. */
  106284. constructor(
  106285. /** The Friendly of the effect in the scene */
  106286. name: string, scene: Scene);
  106287. /**
  106288. * Get the effect name of the layer.
  106289. * @return The effect name
  106290. */
  106291. abstract getEffectName(): string;
  106292. /**
  106293. * Checks for the readiness of the element composing the layer.
  106294. * @param subMesh the mesh to check for
  106295. * @param useInstances specify wether or not to use instances to render the mesh
  106296. * @return true if ready otherwise, false
  106297. */
  106298. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106299. /**
  106300. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106301. * @returns true if the effect requires stencil during the main canvas render pass.
  106302. */
  106303. abstract needStencil(): boolean;
  106304. /**
  106305. * Create the merge effect. This is the shader use to blit the information back
  106306. * to the main canvas at the end of the scene rendering.
  106307. * @returns The effect containing the shader used to merge the effect on the main canvas
  106308. */
  106309. protected abstract _createMergeEffect(): Effect;
  106310. /**
  106311. * Creates the render target textures and post processes used in the effect layer.
  106312. */
  106313. protected abstract _createTextureAndPostProcesses(): void;
  106314. /**
  106315. * Implementation specific of rendering the generating effect on the main canvas.
  106316. * @param effect The effect used to render through
  106317. */
  106318. protected abstract _internalRender(effect: Effect): void;
  106319. /**
  106320. * Sets the required values for both the emissive texture and and the main color.
  106321. */
  106322. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106323. /**
  106324. * Free any resources and references associated to a mesh.
  106325. * Internal use
  106326. * @param mesh The mesh to free.
  106327. */
  106328. abstract _disposeMesh(mesh: Mesh): void;
  106329. /**
  106330. * Serializes this layer (Glow or Highlight for example)
  106331. * @returns a serialized layer object
  106332. */
  106333. abstract serialize?(): any;
  106334. /**
  106335. * Initializes the effect layer with the required options.
  106336. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106337. */
  106338. protected _init(options: Partial<IEffectLayerOptions>): void;
  106339. /**
  106340. * Generates the index buffer of the full screen quad blending to the main canvas.
  106341. */
  106342. private _generateIndexBuffer;
  106343. /**
  106344. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106345. */
  106346. private _genrateVertexBuffer;
  106347. /**
  106348. * Sets the main texture desired size which is the closest power of two
  106349. * of the engine canvas size.
  106350. */
  106351. private _setMainTextureSize;
  106352. /**
  106353. * Creates the main texture for the effect layer.
  106354. */
  106355. protected _createMainTexture(): void;
  106356. /**
  106357. * Adds specific effects defines.
  106358. * @param defines The defines to add specifics to.
  106359. */
  106360. protected _addCustomEffectDefines(defines: string[]): void;
  106361. /**
  106362. * Checks for the readiness of the element composing the layer.
  106363. * @param subMesh the mesh to check for
  106364. * @param useInstances specify wether or not to use instances to render the mesh
  106365. * @param emissiveTexture the associated emissive texture used to generate the glow
  106366. * @return true if ready otherwise, false
  106367. */
  106368. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106369. /**
  106370. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106371. */
  106372. render(): void;
  106373. /**
  106374. * Determine if a given mesh will be used in the current effect.
  106375. * @param mesh mesh to test
  106376. * @returns true if the mesh will be used
  106377. */
  106378. hasMesh(mesh: AbstractMesh): boolean;
  106379. /**
  106380. * Returns true if the layer contains information to display, otherwise false.
  106381. * @returns true if the glow layer should be rendered
  106382. */
  106383. shouldRender(): boolean;
  106384. /**
  106385. * Returns true if the mesh should render, otherwise false.
  106386. * @param mesh The mesh to render
  106387. * @returns true if it should render otherwise false
  106388. */
  106389. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106390. /**
  106391. * Returns true if the mesh can be rendered, otherwise false.
  106392. * @param mesh The mesh to render
  106393. * @param material The material used on the mesh
  106394. * @returns true if it can be rendered otherwise false
  106395. */
  106396. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106397. /**
  106398. * Returns true if the mesh should render, otherwise false.
  106399. * @param mesh The mesh to render
  106400. * @returns true if it should render otherwise false
  106401. */
  106402. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106403. /**
  106404. * Renders the submesh passed in parameter to the generation map.
  106405. */
  106406. protected _renderSubMesh(subMesh: SubMesh): void;
  106407. /**
  106408. * Rebuild the required buffers.
  106409. * @hidden Internal use only.
  106410. */
  106411. _rebuild(): void;
  106412. /**
  106413. * Dispose only the render target textures and post process.
  106414. */
  106415. private _disposeTextureAndPostProcesses;
  106416. /**
  106417. * Dispose the highlight layer and free resources.
  106418. */
  106419. dispose(): void;
  106420. /**
  106421. * Gets the class name of the effect layer
  106422. * @returns the string with the class name of the effect layer
  106423. */
  106424. getClassName(): string;
  106425. /**
  106426. * Creates an effect layer from parsed effect layer data
  106427. * @param parsedEffectLayer defines effect layer data
  106428. * @param scene defines the current scene
  106429. * @param rootUrl defines the root URL containing the effect layer information
  106430. * @returns a parsed effect Layer
  106431. */
  106432. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106433. }
  106434. }
  106435. declare module BABYLON {
  106436. interface AbstractScene {
  106437. /**
  106438. * The list of effect layers (highlights/glow) added to the scene
  106439. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106440. * @see http://doc.babylonjs.com/how_to/glow_layer
  106441. */
  106442. effectLayers: Array<EffectLayer>;
  106443. /**
  106444. * Removes the given effect layer from this scene.
  106445. * @param toRemove defines the effect layer to remove
  106446. * @returns the index of the removed effect layer
  106447. */
  106448. removeEffectLayer(toRemove: EffectLayer): number;
  106449. /**
  106450. * Adds the given effect layer to this scene
  106451. * @param newEffectLayer defines the effect layer to add
  106452. */
  106453. addEffectLayer(newEffectLayer: EffectLayer): void;
  106454. }
  106455. /**
  106456. * Defines the layer scene component responsible to manage any effect layers
  106457. * in a given scene.
  106458. */
  106459. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106460. /**
  106461. * The component name helpfull to identify the component in the list of scene components.
  106462. */
  106463. readonly name: string;
  106464. /**
  106465. * The scene the component belongs to.
  106466. */
  106467. scene: Scene;
  106468. private _engine;
  106469. private _renderEffects;
  106470. private _needStencil;
  106471. private _previousStencilState;
  106472. /**
  106473. * Creates a new instance of the component for the given scene
  106474. * @param scene Defines the scene to register the component in
  106475. */
  106476. constructor(scene: Scene);
  106477. /**
  106478. * Registers the component in a given scene
  106479. */
  106480. register(): void;
  106481. /**
  106482. * Rebuilds the elements related to this component in case of
  106483. * context lost for instance.
  106484. */
  106485. rebuild(): void;
  106486. /**
  106487. * Serializes the component data to the specified json object
  106488. * @param serializationObject The object to serialize to
  106489. */
  106490. serialize(serializationObject: any): void;
  106491. /**
  106492. * Adds all the element from the container to the scene
  106493. * @param container the container holding the elements
  106494. */
  106495. addFromContainer(container: AbstractScene): void;
  106496. /**
  106497. * Removes all the elements in the container from the scene
  106498. * @param container contains the elements to remove
  106499. * @param dispose if the removed element should be disposed (default: false)
  106500. */
  106501. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106502. /**
  106503. * Disposes the component and the associated ressources.
  106504. */
  106505. dispose(): void;
  106506. private _isReadyForMesh;
  106507. private _renderMainTexture;
  106508. private _setStencil;
  106509. private _setStencilBack;
  106510. private _draw;
  106511. private _drawCamera;
  106512. private _drawRenderingGroup;
  106513. }
  106514. }
  106515. declare module BABYLON {
  106516. /** @hidden */
  106517. export var glowMapMergePixelShader: {
  106518. name: string;
  106519. shader: string;
  106520. };
  106521. }
  106522. declare module BABYLON {
  106523. /** @hidden */
  106524. export var glowMapMergeVertexShader: {
  106525. name: string;
  106526. shader: string;
  106527. };
  106528. }
  106529. declare module BABYLON {
  106530. interface AbstractScene {
  106531. /**
  106532. * Return a the first highlight layer of the scene with a given name.
  106533. * @param name The name of the highlight layer to look for.
  106534. * @return The highlight layer if found otherwise null.
  106535. */
  106536. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  106537. }
  106538. /**
  106539. * Glow layer options. This helps customizing the behaviour
  106540. * of the glow layer.
  106541. */
  106542. export interface IGlowLayerOptions {
  106543. /**
  106544. * Multiplication factor apply to the canvas size to compute the render target size
  106545. * used to generated the glowing objects (the smaller the faster).
  106546. */
  106547. mainTextureRatio: number;
  106548. /**
  106549. * Enforces a fixed size texture to ensure resize independant blur.
  106550. */
  106551. mainTextureFixedSize?: number;
  106552. /**
  106553. * How big is the kernel of the blur texture.
  106554. */
  106555. blurKernelSize: number;
  106556. /**
  106557. * The camera attached to the layer.
  106558. */
  106559. camera: Nullable<Camera>;
  106560. /**
  106561. * Enable MSAA by chosing the number of samples.
  106562. */
  106563. mainTextureSamples?: number;
  106564. /**
  106565. * The rendering group to draw the layer in.
  106566. */
  106567. renderingGroupId: number;
  106568. }
  106569. /**
  106570. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  106571. *
  106572. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106573. * glowy meshes to your scene.
  106574. *
  106575. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  106576. */
  106577. export class GlowLayer extends EffectLayer {
  106578. /**
  106579. * Effect Name of the layer.
  106580. */
  106581. static readonly EffectName: string;
  106582. /**
  106583. * The default blur kernel size used for the glow.
  106584. */
  106585. static DefaultBlurKernelSize: number;
  106586. /**
  106587. * The default texture size ratio used for the glow.
  106588. */
  106589. static DefaultTextureRatio: number;
  106590. /**
  106591. * Sets the kernel size of the blur.
  106592. */
  106593. /**
  106594. * Gets the kernel size of the blur.
  106595. */
  106596. blurKernelSize: number;
  106597. /**
  106598. * Sets the glow intensity.
  106599. */
  106600. /**
  106601. * Gets the glow intensity.
  106602. */
  106603. intensity: number;
  106604. private _options;
  106605. private _intensity;
  106606. private _horizontalBlurPostprocess1;
  106607. private _verticalBlurPostprocess1;
  106608. private _horizontalBlurPostprocess2;
  106609. private _verticalBlurPostprocess2;
  106610. private _blurTexture1;
  106611. private _blurTexture2;
  106612. private _postProcesses1;
  106613. private _postProcesses2;
  106614. private _includedOnlyMeshes;
  106615. private _excludedMeshes;
  106616. /**
  106617. * Callback used to let the user override the color selection on a per mesh basis
  106618. */
  106619. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  106620. /**
  106621. * Callback used to let the user override the texture selection on a per mesh basis
  106622. */
  106623. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  106624. /**
  106625. * Instantiates a new glow Layer and references it to the scene.
  106626. * @param name The name of the layer
  106627. * @param scene The scene to use the layer in
  106628. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  106629. */
  106630. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  106631. /**
  106632. * Get the effect name of the layer.
  106633. * @return The effect name
  106634. */
  106635. getEffectName(): string;
  106636. /**
  106637. * Create the merge effect. This is the shader use to blit the information back
  106638. * to the main canvas at the end of the scene rendering.
  106639. */
  106640. protected _createMergeEffect(): Effect;
  106641. /**
  106642. * Creates the render target textures and post processes used in the glow layer.
  106643. */
  106644. protected _createTextureAndPostProcesses(): void;
  106645. /**
  106646. * Checks for the readiness of the element composing the layer.
  106647. * @param subMesh the mesh to check for
  106648. * @param useInstances specify wether or not to use instances to render the mesh
  106649. * @param emissiveTexture the associated emissive texture used to generate the glow
  106650. * @return true if ready otherwise, false
  106651. */
  106652. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106653. /**
  106654. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106655. */
  106656. needStencil(): boolean;
  106657. /**
  106658. * Returns true if the mesh can be rendered, otherwise false.
  106659. * @param mesh The mesh to render
  106660. * @param material The material used on the mesh
  106661. * @returns true if it can be rendered otherwise false
  106662. */
  106663. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106664. /**
  106665. * Implementation specific of rendering the generating effect on the main canvas.
  106666. * @param effect The effect used to render through
  106667. */
  106668. protected _internalRender(effect: Effect): void;
  106669. /**
  106670. * Sets the required values for both the emissive texture and and the main color.
  106671. */
  106672. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106673. /**
  106674. * Returns true if the mesh should render, otherwise false.
  106675. * @param mesh The mesh to render
  106676. * @returns true if it should render otherwise false
  106677. */
  106678. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106679. /**
  106680. * Adds specific effects defines.
  106681. * @param defines The defines to add specifics to.
  106682. */
  106683. protected _addCustomEffectDefines(defines: string[]): void;
  106684. /**
  106685. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  106686. * @param mesh The mesh to exclude from the glow layer
  106687. */
  106688. addExcludedMesh(mesh: Mesh): void;
  106689. /**
  106690. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  106691. * @param mesh The mesh to remove
  106692. */
  106693. removeExcludedMesh(mesh: Mesh): void;
  106694. /**
  106695. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  106696. * @param mesh The mesh to include in the glow layer
  106697. */
  106698. addIncludedOnlyMesh(mesh: Mesh): void;
  106699. /**
  106700. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  106701. * @param mesh The mesh to remove
  106702. */
  106703. removeIncludedOnlyMesh(mesh: Mesh): void;
  106704. /**
  106705. * Determine if a given mesh will be used in the glow layer
  106706. * @param mesh The mesh to test
  106707. * @returns true if the mesh will be highlighted by the current glow layer
  106708. */
  106709. hasMesh(mesh: AbstractMesh): boolean;
  106710. /**
  106711. * Free any resources and references associated to a mesh.
  106712. * Internal use
  106713. * @param mesh The mesh to free.
  106714. * @hidden
  106715. */
  106716. _disposeMesh(mesh: Mesh): void;
  106717. /**
  106718. * Gets the class name of the effect layer
  106719. * @returns the string with the class name of the effect layer
  106720. */
  106721. getClassName(): string;
  106722. /**
  106723. * Serializes this glow layer
  106724. * @returns a serialized glow layer object
  106725. */
  106726. serialize(): any;
  106727. /**
  106728. * Creates a Glow Layer from parsed glow layer data
  106729. * @param parsedGlowLayer defines glow layer data
  106730. * @param scene defines the current scene
  106731. * @param rootUrl defines the root URL containing the glow layer information
  106732. * @returns a parsed Glow Layer
  106733. */
  106734. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  106735. }
  106736. }
  106737. declare module BABYLON {
  106738. /** @hidden */
  106739. export var glowBlurPostProcessPixelShader: {
  106740. name: string;
  106741. shader: string;
  106742. };
  106743. }
  106744. declare module BABYLON {
  106745. interface AbstractScene {
  106746. /**
  106747. * Return a the first highlight layer of the scene with a given name.
  106748. * @param name The name of the highlight layer to look for.
  106749. * @return The highlight layer if found otherwise null.
  106750. */
  106751. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  106752. }
  106753. /**
  106754. * Highlight layer options. This helps customizing the behaviour
  106755. * of the highlight layer.
  106756. */
  106757. export interface IHighlightLayerOptions {
  106758. /**
  106759. * Multiplication factor apply to the canvas size to compute the render target size
  106760. * used to generated the glowing objects (the smaller the faster).
  106761. */
  106762. mainTextureRatio: number;
  106763. /**
  106764. * Enforces a fixed size texture to ensure resize independant blur.
  106765. */
  106766. mainTextureFixedSize?: number;
  106767. /**
  106768. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  106769. * of the picture to blur (the smaller the faster).
  106770. */
  106771. blurTextureSizeRatio: number;
  106772. /**
  106773. * How big in texel of the blur texture is the vertical blur.
  106774. */
  106775. blurVerticalSize: number;
  106776. /**
  106777. * How big in texel of the blur texture is the horizontal blur.
  106778. */
  106779. blurHorizontalSize: number;
  106780. /**
  106781. * Alpha blending mode used to apply the blur. Default is combine.
  106782. */
  106783. alphaBlendingMode: number;
  106784. /**
  106785. * The camera attached to the layer.
  106786. */
  106787. camera: Nullable<Camera>;
  106788. /**
  106789. * Should we display highlight as a solid stroke?
  106790. */
  106791. isStroke?: boolean;
  106792. /**
  106793. * The rendering group to draw the layer in.
  106794. */
  106795. renderingGroupId: number;
  106796. }
  106797. /**
  106798. * The highlight layer Helps adding a glow effect around a mesh.
  106799. *
  106800. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106801. * glowy meshes to your scene.
  106802. *
  106803. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  106804. */
  106805. export class HighlightLayer extends EffectLayer {
  106806. name: string;
  106807. /**
  106808. * Effect Name of the highlight layer.
  106809. */
  106810. static readonly EffectName: string;
  106811. /**
  106812. * The neutral color used during the preparation of the glow effect.
  106813. * This is black by default as the blend operation is a blend operation.
  106814. */
  106815. static NeutralColor: Color4;
  106816. /**
  106817. * Stencil value used for glowing meshes.
  106818. */
  106819. static GlowingMeshStencilReference: number;
  106820. /**
  106821. * Stencil value used for the other meshes in the scene.
  106822. */
  106823. static NormalMeshStencilReference: number;
  106824. /**
  106825. * Specifies whether or not the inner glow is ACTIVE in the layer.
  106826. */
  106827. innerGlow: boolean;
  106828. /**
  106829. * Specifies whether or not the outer glow is ACTIVE in the layer.
  106830. */
  106831. outerGlow: boolean;
  106832. /**
  106833. * Specifies the horizontal size of the blur.
  106834. */
  106835. /**
  106836. * Gets the horizontal size of the blur.
  106837. */
  106838. blurHorizontalSize: number;
  106839. /**
  106840. * Specifies the vertical size of the blur.
  106841. */
  106842. /**
  106843. * Gets the vertical size of the blur.
  106844. */
  106845. blurVerticalSize: number;
  106846. /**
  106847. * An event triggered when the highlight layer is being blurred.
  106848. */
  106849. onBeforeBlurObservable: Observable<HighlightLayer>;
  106850. /**
  106851. * An event triggered when the highlight layer has been blurred.
  106852. */
  106853. onAfterBlurObservable: Observable<HighlightLayer>;
  106854. private _instanceGlowingMeshStencilReference;
  106855. private _options;
  106856. private _downSamplePostprocess;
  106857. private _horizontalBlurPostprocess;
  106858. private _verticalBlurPostprocess;
  106859. private _blurTexture;
  106860. private _meshes;
  106861. private _excludedMeshes;
  106862. /**
  106863. * Instantiates a new highlight Layer and references it to the scene..
  106864. * @param name The name of the layer
  106865. * @param scene The scene to use the layer in
  106866. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  106867. */
  106868. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  106869. /**
  106870. * Get the effect name of the layer.
  106871. * @return The effect name
  106872. */
  106873. getEffectName(): string;
  106874. /**
  106875. * Create the merge effect. This is the shader use to blit the information back
  106876. * to the main canvas at the end of the scene rendering.
  106877. */
  106878. protected _createMergeEffect(): Effect;
  106879. /**
  106880. * Creates the render target textures and post processes used in the highlight layer.
  106881. */
  106882. protected _createTextureAndPostProcesses(): void;
  106883. /**
  106884. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106885. */
  106886. needStencil(): boolean;
  106887. /**
  106888. * Checks for the readiness of the element composing the layer.
  106889. * @param subMesh the mesh to check for
  106890. * @param useInstances specify wether or not to use instances to render the mesh
  106891. * @param emissiveTexture the associated emissive texture used to generate the glow
  106892. * @return true if ready otherwise, false
  106893. */
  106894. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106895. /**
  106896. * Implementation specific of rendering the generating effect on the main canvas.
  106897. * @param effect The effect used to render through
  106898. */
  106899. protected _internalRender(effect: Effect): void;
  106900. /**
  106901. * Returns true if the layer contains information to display, otherwise false.
  106902. */
  106903. shouldRender(): boolean;
  106904. /**
  106905. * Returns true if the mesh should render, otherwise false.
  106906. * @param mesh The mesh to render
  106907. * @returns true if it should render otherwise false
  106908. */
  106909. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106910. /**
  106911. * Sets the required values for both the emissive texture and and the main color.
  106912. */
  106913. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106914. /**
  106915. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  106916. * @param mesh The mesh to exclude from the highlight layer
  106917. */
  106918. addExcludedMesh(mesh: Mesh): void;
  106919. /**
  106920. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  106921. * @param mesh The mesh to highlight
  106922. */
  106923. removeExcludedMesh(mesh: Mesh): void;
  106924. /**
  106925. * Determine if a given mesh will be highlighted by the current HighlightLayer
  106926. * @param mesh mesh to test
  106927. * @returns true if the mesh will be highlighted by the current HighlightLayer
  106928. */
  106929. hasMesh(mesh: AbstractMesh): boolean;
  106930. /**
  106931. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  106932. * @param mesh The mesh to highlight
  106933. * @param color The color of the highlight
  106934. * @param glowEmissiveOnly Extract the glow from the emissive texture
  106935. */
  106936. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  106937. /**
  106938. * Remove a mesh from the highlight layer in order to make it stop glowing.
  106939. * @param mesh The mesh to highlight
  106940. */
  106941. removeMesh(mesh: Mesh): void;
  106942. /**
  106943. * Force the stencil to the normal expected value for none glowing parts
  106944. */
  106945. private _defaultStencilReference;
  106946. /**
  106947. * Free any resources and references associated to a mesh.
  106948. * Internal use
  106949. * @param mesh The mesh to free.
  106950. * @hidden
  106951. */
  106952. _disposeMesh(mesh: Mesh): void;
  106953. /**
  106954. * Dispose the highlight layer and free resources.
  106955. */
  106956. dispose(): void;
  106957. /**
  106958. * Gets the class name of the effect layer
  106959. * @returns the string with the class name of the effect layer
  106960. */
  106961. getClassName(): string;
  106962. /**
  106963. * Serializes this Highlight layer
  106964. * @returns a serialized Highlight layer object
  106965. */
  106966. serialize(): any;
  106967. /**
  106968. * Creates a Highlight layer from parsed Highlight layer data
  106969. * @param parsedHightlightLayer defines the Highlight layer data
  106970. * @param scene defines the current scene
  106971. * @param rootUrl defines the root URL containing the Highlight layer information
  106972. * @returns a parsed Highlight layer
  106973. */
  106974. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  106975. }
  106976. }
  106977. declare module BABYLON {
  106978. /** @hidden */
  106979. export var lensFlarePixelShader: {
  106980. name: string;
  106981. shader: string;
  106982. };
  106983. }
  106984. declare module BABYLON {
  106985. /** @hidden */
  106986. export var lensFlareVertexShader: {
  106987. name: string;
  106988. shader: string;
  106989. };
  106990. }
  106991. declare module BABYLON {
  106992. /**
  106993. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106994. * It is usually composed of several `lensFlare`.
  106995. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106996. */
  106997. export class LensFlareSystem {
  106998. /**
  106999. * Define the name of the lens flare system
  107000. */
  107001. name: string;
  107002. /**
  107003. * List of lens flares used in this system.
  107004. */
  107005. lensFlares: LensFlare[];
  107006. /**
  107007. * Define a limit from the border the lens flare can be visible.
  107008. */
  107009. borderLimit: number;
  107010. /**
  107011. * Define a viewport border we do not want to see the lens flare in.
  107012. */
  107013. viewportBorder: number;
  107014. /**
  107015. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107016. */
  107017. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107018. /**
  107019. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107020. */
  107021. layerMask: number;
  107022. /**
  107023. * Define the id of the lens flare system in the scene.
  107024. * (equal to name by default)
  107025. */
  107026. id: string;
  107027. private _scene;
  107028. private _emitter;
  107029. private _vertexBuffers;
  107030. private _indexBuffer;
  107031. private _effect;
  107032. private _positionX;
  107033. private _positionY;
  107034. private _isEnabled;
  107035. /** @hidden */
  107036. static _SceneComponentInitialization: (scene: Scene) => void;
  107037. /**
  107038. * Instantiates a lens flare system.
  107039. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107040. * It is usually composed of several `lensFlare`.
  107041. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107042. * @param name Define the name of the lens flare system in the scene
  107043. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107044. * @param scene Define the scene the lens flare system belongs to
  107045. */
  107046. constructor(
  107047. /**
  107048. * Define the name of the lens flare system
  107049. */
  107050. name: string, emitter: any, scene: Scene);
  107051. /**
  107052. * Define if the lens flare system is enabled.
  107053. */
  107054. isEnabled: boolean;
  107055. /**
  107056. * Get the scene the effects belongs to.
  107057. * @returns the scene holding the lens flare system
  107058. */
  107059. getScene(): Scene;
  107060. /**
  107061. * Get the emitter of the lens flare system.
  107062. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107063. * @returns the emitter of the lens flare system
  107064. */
  107065. getEmitter(): any;
  107066. /**
  107067. * Set the emitter of the lens flare system.
  107068. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107069. * @param newEmitter Define the new emitter of the system
  107070. */
  107071. setEmitter(newEmitter: any): void;
  107072. /**
  107073. * Get the lens flare system emitter position.
  107074. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107075. * @returns the position
  107076. */
  107077. getEmitterPosition(): Vector3;
  107078. /**
  107079. * @hidden
  107080. */
  107081. computeEffectivePosition(globalViewport: Viewport): boolean;
  107082. /** @hidden */
  107083. _isVisible(): boolean;
  107084. /**
  107085. * @hidden
  107086. */
  107087. render(): boolean;
  107088. /**
  107089. * Dispose and release the lens flare with its associated resources.
  107090. */
  107091. dispose(): void;
  107092. /**
  107093. * Parse a lens flare system from a JSON repressentation
  107094. * @param parsedLensFlareSystem Define the JSON to parse
  107095. * @param scene Define the scene the parsed system should be instantiated in
  107096. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107097. * @returns the parsed system
  107098. */
  107099. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107100. /**
  107101. * Serialize the current Lens Flare System into a JSON representation.
  107102. * @returns the serialized JSON
  107103. */
  107104. serialize(): any;
  107105. }
  107106. }
  107107. declare module BABYLON {
  107108. /**
  107109. * This represents one of the lens effect in a `lensFlareSystem`.
  107110. * It controls one of the indiviual texture used in the effect.
  107111. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107112. */
  107113. export class LensFlare {
  107114. /**
  107115. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107116. */
  107117. size: number;
  107118. /**
  107119. * 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.
  107120. */
  107121. position: number;
  107122. /**
  107123. * Define the lens color.
  107124. */
  107125. color: Color3;
  107126. /**
  107127. * Define the lens texture.
  107128. */
  107129. texture: Nullable<Texture>;
  107130. /**
  107131. * Define the alpha mode to render this particular lens.
  107132. */
  107133. alphaMode: number;
  107134. private _system;
  107135. /**
  107136. * Creates a new Lens Flare.
  107137. * This represents one of the lens effect in a `lensFlareSystem`.
  107138. * It controls one of the indiviual texture used in the effect.
  107139. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107140. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107141. * @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.
  107142. * @param color Define the lens color
  107143. * @param imgUrl Define the lens texture url
  107144. * @param system Define the `lensFlareSystem` this flare is part of
  107145. * @returns The newly created Lens Flare
  107146. */
  107147. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107148. /**
  107149. * Instantiates a new Lens Flare.
  107150. * This represents one of the lens effect in a `lensFlareSystem`.
  107151. * It controls one of the indiviual texture used in the effect.
  107152. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107153. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107154. * @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.
  107155. * @param color Define the lens color
  107156. * @param imgUrl Define the lens texture url
  107157. * @param system Define the `lensFlareSystem` this flare is part of
  107158. */
  107159. constructor(
  107160. /**
  107161. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107162. */
  107163. size: number,
  107164. /**
  107165. * 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.
  107166. */
  107167. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107168. /**
  107169. * Dispose and release the lens flare with its associated resources.
  107170. */
  107171. dispose(): void;
  107172. }
  107173. }
  107174. declare module BABYLON {
  107175. interface AbstractScene {
  107176. /**
  107177. * The list of lens flare system added to the scene
  107178. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107179. */
  107180. lensFlareSystems: Array<LensFlareSystem>;
  107181. /**
  107182. * Removes the given lens flare system from this scene.
  107183. * @param toRemove The lens flare system to remove
  107184. * @returns The index of the removed lens flare system
  107185. */
  107186. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107187. /**
  107188. * Adds the given lens flare system to this scene
  107189. * @param newLensFlareSystem The lens flare system to add
  107190. */
  107191. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107192. /**
  107193. * Gets a lens flare system using its name
  107194. * @param name defines the name to look for
  107195. * @returns the lens flare system or null if not found
  107196. */
  107197. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107198. /**
  107199. * Gets a lens flare system using its id
  107200. * @param id defines the id to look for
  107201. * @returns the lens flare system or null if not found
  107202. */
  107203. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107204. }
  107205. /**
  107206. * Defines the lens flare scene component responsible to manage any lens flares
  107207. * in a given scene.
  107208. */
  107209. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107210. /**
  107211. * The component name helpfull to identify the component in the list of scene components.
  107212. */
  107213. readonly name: string;
  107214. /**
  107215. * The scene the component belongs to.
  107216. */
  107217. scene: Scene;
  107218. /**
  107219. * Creates a new instance of the component for the given scene
  107220. * @param scene Defines the scene to register the component in
  107221. */
  107222. constructor(scene: Scene);
  107223. /**
  107224. * Registers the component in a given scene
  107225. */
  107226. register(): void;
  107227. /**
  107228. * Rebuilds the elements related to this component in case of
  107229. * context lost for instance.
  107230. */
  107231. rebuild(): void;
  107232. /**
  107233. * Adds all the element from the container to the scene
  107234. * @param container the container holding the elements
  107235. */
  107236. addFromContainer(container: AbstractScene): void;
  107237. /**
  107238. * Removes all the elements in the container from the scene
  107239. * @param container contains the elements to remove
  107240. * @param dispose if the removed element should be disposed (default: false)
  107241. */
  107242. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107243. /**
  107244. * Serializes the component data to the specified json object
  107245. * @param serializationObject The object to serialize to
  107246. */
  107247. serialize(serializationObject: any): void;
  107248. /**
  107249. * Disposes the component and the associated ressources.
  107250. */
  107251. dispose(): void;
  107252. private _draw;
  107253. }
  107254. }
  107255. declare module BABYLON {
  107256. /**
  107257. * Defines the shadow generator component responsible to manage any shadow generators
  107258. * in a given scene.
  107259. */
  107260. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107261. /**
  107262. * The component name helpfull to identify the component in the list of scene components.
  107263. */
  107264. readonly name: string;
  107265. /**
  107266. * The scene the component belongs to.
  107267. */
  107268. scene: Scene;
  107269. /**
  107270. * Creates a new instance of the component for the given scene
  107271. * @param scene Defines the scene to register the component in
  107272. */
  107273. constructor(scene: Scene);
  107274. /**
  107275. * Registers the component in a given scene
  107276. */
  107277. register(): void;
  107278. /**
  107279. * Rebuilds the elements related to this component in case of
  107280. * context lost for instance.
  107281. */
  107282. rebuild(): void;
  107283. /**
  107284. * Serializes the component data to the specified json object
  107285. * @param serializationObject The object to serialize to
  107286. */
  107287. serialize(serializationObject: any): void;
  107288. /**
  107289. * Adds all the element from the container to the scene
  107290. * @param container the container holding the elements
  107291. */
  107292. addFromContainer(container: AbstractScene): void;
  107293. /**
  107294. * Removes all the elements in the container from the scene
  107295. * @param container contains the elements to remove
  107296. * @param dispose if the removed element should be disposed (default: false)
  107297. */
  107298. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107299. /**
  107300. * Rebuilds the elements related to this component in case of
  107301. * context lost for instance.
  107302. */
  107303. dispose(): void;
  107304. private _gatherRenderTargets;
  107305. }
  107306. }
  107307. declare module BABYLON {
  107308. /**
  107309. * A point light is a light defined by an unique point in world space.
  107310. * The light is emitted in every direction from this point.
  107311. * A good example of a point light is a standard light bulb.
  107312. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107313. */
  107314. export class PointLight extends ShadowLight {
  107315. private _shadowAngle;
  107316. /**
  107317. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107318. * This specifies what angle the shadow will use to be created.
  107319. *
  107320. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107321. */
  107322. /**
  107323. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107324. * This specifies what angle the shadow will use to be created.
  107325. *
  107326. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107327. */
  107328. shadowAngle: number;
  107329. /**
  107330. * Gets the direction if it has been set.
  107331. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107332. */
  107333. /**
  107334. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107335. */
  107336. direction: Vector3;
  107337. /**
  107338. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107339. * A PointLight emits the light in every direction.
  107340. * It can cast shadows.
  107341. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107342. * ```javascript
  107343. * var pointLight = new PointLight("pl", camera.position, scene);
  107344. * ```
  107345. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107346. * @param name The light friendly name
  107347. * @param position The position of the point light in the scene
  107348. * @param scene The scene the lights belongs to
  107349. */
  107350. constructor(name: string, position: Vector3, scene: Scene);
  107351. /**
  107352. * Returns the string "PointLight"
  107353. * @returns the class name
  107354. */
  107355. getClassName(): string;
  107356. /**
  107357. * Returns the integer 0.
  107358. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107359. */
  107360. getTypeID(): number;
  107361. /**
  107362. * Specifies wether or not the shadowmap should be a cube texture.
  107363. * @returns true if the shadowmap needs to be a cube texture.
  107364. */
  107365. needCube(): boolean;
  107366. /**
  107367. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107368. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107369. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107370. */
  107371. getShadowDirection(faceIndex?: number): Vector3;
  107372. /**
  107373. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107374. * - fov = PI / 2
  107375. * - aspect ratio : 1.0
  107376. * - z-near and far equal to the active camera minZ and maxZ.
  107377. * Returns the PointLight.
  107378. */
  107379. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107380. protected _buildUniformLayout(): void;
  107381. /**
  107382. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107383. * @param effect The effect to update
  107384. * @param lightIndex The index of the light in the effect to update
  107385. * @returns The point light
  107386. */
  107387. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107388. /**
  107389. * Prepares the list of defines specific to the light type.
  107390. * @param defines the list of defines
  107391. * @param lightIndex defines the index of the light for the effect
  107392. */
  107393. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107394. }
  107395. }
  107396. declare module BABYLON {
  107397. /**
  107398. * Header information of HDR texture files.
  107399. */
  107400. export interface HDRInfo {
  107401. /**
  107402. * The height of the texture in pixels.
  107403. */
  107404. height: number;
  107405. /**
  107406. * The width of the texture in pixels.
  107407. */
  107408. width: number;
  107409. /**
  107410. * The index of the beginning of the data in the binary file.
  107411. */
  107412. dataPosition: number;
  107413. }
  107414. /**
  107415. * This groups tools to convert HDR texture to native colors array.
  107416. */
  107417. export class HDRTools {
  107418. private static Ldexp;
  107419. private static Rgbe2float;
  107420. private static readStringLine;
  107421. /**
  107422. * Reads header information from an RGBE texture stored in a native array.
  107423. * More information on this format are available here:
  107424. * https://en.wikipedia.org/wiki/RGBE_image_format
  107425. *
  107426. * @param uint8array The binary file stored in native array.
  107427. * @return The header information.
  107428. */
  107429. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107430. /**
  107431. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107432. * This RGBE texture needs to store the information as a panorama.
  107433. *
  107434. * More information on this format are available here:
  107435. * https://en.wikipedia.org/wiki/RGBE_image_format
  107436. *
  107437. * @param buffer The binary file stored in an array buffer.
  107438. * @param size The expected size of the extracted cubemap.
  107439. * @return The Cube Map information.
  107440. */
  107441. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107442. /**
  107443. * Returns the pixels data extracted from an RGBE texture.
  107444. * This pixels will be stored left to right up to down in the R G B order in one array.
  107445. *
  107446. * More information on this format are available here:
  107447. * https://en.wikipedia.org/wiki/RGBE_image_format
  107448. *
  107449. * @param uint8array The binary file stored in an array buffer.
  107450. * @param hdrInfo The header information of the file.
  107451. * @return The pixels data in RGB right to left up to down order.
  107452. */
  107453. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107454. private static RGBE_ReadPixels_RLE;
  107455. }
  107456. }
  107457. declare module BABYLON {
  107458. /**
  107459. * This represents a texture coming from an HDR input.
  107460. *
  107461. * The only supported format is currently panorama picture stored in RGBE format.
  107462. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107463. */
  107464. export class HDRCubeTexture extends BaseTexture {
  107465. private static _facesMapping;
  107466. private _generateHarmonics;
  107467. private _noMipmap;
  107468. private _textureMatrix;
  107469. private _size;
  107470. private _onLoad;
  107471. private _onError;
  107472. /**
  107473. * The texture URL.
  107474. */
  107475. url: string;
  107476. /**
  107477. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  107478. */
  107479. coordinatesMode: number;
  107480. protected _isBlocking: boolean;
  107481. /**
  107482. * Sets wether or not the texture is blocking during loading.
  107483. */
  107484. /**
  107485. * Gets wether or not the texture is blocking during loading.
  107486. */
  107487. isBlocking: boolean;
  107488. protected _rotationY: number;
  107489. /**
  107490. * Sets texture matrix rotation angle around Y axis in radians.
  107491. */
  107492. /**
  107493. * Gets texture matrix rotation angle around Y axis radians.
  107494. */
  107495. rotationY: number;
  107496. /**
  107497. * Gets or sets the center of the bounding box associated with the cube texture
  107498. * It must define where the camera used to render the texture was set
  107499. */
  107500. boundingBoxPosition: Vector3;
  107501. private _boundingBoxSize;
  107502. /**
  107503. * Gets or sets the size of the bounding box associated with the cube texture
  107504. * When defined, the cubemap will switch to local mode
  107505. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  107506. * @example https://www.babylonjs-playground.com/#RNASML
  107507. */
  107508. boundingBoxSize: Vector3;
  107509. /**
  107510. * Instantiates an HDRTexture from the following parameters.
  107511. *
  107512. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  107513. * @param scene The scene the texture will be used in
  107514. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107515. * @param noMipmap Forces to not generate the mipmap if true
  107516. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  107517. * @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)
  107518. * @param reserved Reserved flag for internal use.
  107519. */
  107520. 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>);
  107521. /**
  107522. * Get the current class name of the texture useful for serialization or dynamic coding.
  107523. * @returns "HDRCubeTexture"
  107524. */
  107525. getClassName(): string;
  107526. /**
  107527. * Occurs when the file is raw .hdr file.
  107528. */
  107529. private loadTexture;
  107530. clone(): HDRCubeTexture;
  107531. delayLoad(): void;
  107532. /**
  107533. * Get the texture reflection matrix used to rotate/transform the reflection.
  107534. * @returns the reflection matrix
  107535. */
  107536. getReflectionTextureMatrix(): Matrix;
  107537. /**
  107538. * Set the texture reflection matrix used to rotate/transform the reflection.
  107539. * @param value Define the reflection matrix to set
  107540. */
  107541. setReflectionTextureMatrix(value: Matrix): void;
  107542. /**
  107543. * Parses a JSON representation of an HDR Texture in order to create the texture
  107544. * @param parsedTexture Define the JSON representation
  107545. * @param scene Define the scene the texture should be created in
  107546. * @param rootUrl Define the root url in case we need to load relative dependencies
  107547. * @returns the newly created texture after parsing
  107548. */
  107549. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  107550. serialize(): any;
  107551. }
  107552. }
  107553. declare module BABYLON {
  107554. /**
  107555. * Class used to control physics engine
  107556. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107557. */
  107558. export class PhysicsEngine implements IPhysicsEngine {
  107559. private _physicsPlugin;
  107560. /**
  107561. * Global value used to control the smallest number supported by the simulation
  107562. */
  107563. static Epsilon: number;
  107564. private _impostors;
  107565. private _joints;
  107566. /**
  107567. * Gets the gravity vector used by the simulation
  107568. */
  107569. gravity: Vector3;
  107570. /**
  107571. * Factory used to create the default physics plugin.
  107572. * @returns The default physics plugin
  107573. */
  107574. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  107575. /**
  107576. * Creates a new Physics Engine
  107577. * @param gravity defines the gravity vector used by the simulation
  107578. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  107579. */
  107580. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  107581. /**
  107582. * Sets the gravity vector used by the simulation
  107583. * @param gravity defines the gravity vector to use
  107584. */
  107585. setGravity(gravity: Vector3): void;
  107586. /**
  107587. * Set the time step of the physics engine.
  107588. * Default is 1/60.
  107589. * To slow it down, enter 1/600 for example.
  107590. * To speed it up, 1/30
  107591. * @param newTimeStep defines the new timestep to apply to this world.
  107592. */
  107593. setTimeStep(newTimeStep?: number): void;
  107594. /**
  107595. * Get the time step of the physics engine.
  107596. * @returns the current time step
  107597. */
  107598. getTimeStep(): number;
  107599. /**
  107600. * Release all resources
  107601. */
  107602. dispose(): void;
  107603. /**
  107604. * Gets the name of the current physics plugin
  107605. * @returns the name of the plugin
  107606. */
  107607. getPhysicsPluginName(): string;
  107608. /**
  107609. * Adding a new impostor for the impostor tracking.
  107610. * This will be done by the impostor itself.
  107611. * @param impostor the impostor to add
  107612. */
  107613. addImpostor(impostor: PhysicsImpostor): void;
  107614. /**
  107615. * Remove an impostor from the engine.
  107616. * This impostor and its mesh will not longer be updated by the physics engine.
  107617. * @param impostor the impostor to remove
  107618. */
  107619. removeImpostor(impostor: PhysicsImpostor): void;
  107620. /**
  107621. * Add a joint to the physics engine
  107622. * @param mainImpostor defines the main impostor to which the joint is added.
  107623. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107624. * @param joint defines the joint that will connect both impostors.
  107625. */
  107626. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107627. /**
  107628. * Removes a joint from the simulation
  107629. * @param mainImpostor defines the impostor used with the joint
  107630. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107631. * @param joint defines the joint to remove
  107632. */
  107633. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107634. /**
  107635. * Called by the scene. No need to call it.
  107636. * @param delta defines the timespam between frames
  107637. */
  107638. _step(delta: number): void;
  107639. /**
  107640. * Gets the current plugin used to run the simulation
  107641. * @returns current plugin
  107642. */
  107643. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107644. /**
  107645. * Gets the list of physic impostors
  107646. * @returns an array of PhysicsImpostor
  107647. */
  107648. getImpostors(): Array<PhysicsImpostor>;
  107649. /**
  107650. * Gets the impostor for a physics enabled object
  107651. * @param object defines the object impersonated by the impostor
  107652. * @returns the PhysicsImpostor or null if not found
  107653. */
  107654. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107655. /**
  107656. * Gets the impostor for a physics body object
  107657. * @param body defines physics body used by the impostor
  107658. * @returns the PhysicsImpostor or null if not found
  107659. */
  107660. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107661. /**
  107662. * Does a raycast in the physics world
  107663. * @param from when should the ray start?
  107664. * @param to when should the ray end?
  107665. * @returns PhysicsRaycastResult
  107666. */
  107667. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107668. }
  107669. }
  107670. declare module BABYLON {
  107671. /** @hidden */
  107672. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  107673. private _useDeltaForWorldStep;
  107674. world: any;
  107675. name: string;
  107676. private _physicsMaterials;
  107677. private _fixedTimeStep;
  107678. private _cannonRaycastResult;
  107679. private _raycastResult;
  107680. private _removeAfterStep;
  107681. BJSCANNON: any;
  107682. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  107683. setGravity(gravity: Vector3): void;
  107684. setTimeStep(timeStep: number): void;
  107685. getTimeStep(): number;
  107686. executeStep(delta: number): void;
  107687. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107688. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107689. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107690. private _processChildMeshes;
  107691. removePhysicsBody(impostor: PhysicsImpostor): void;
  107692. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107693. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107694. private _addMaterial;
  107695. private _checkWithEpsilon;
  107696. private _createShape;
  107697. private _createHeightmap;
  107698. private _minus90X;
  107699. private _plus90X;
  107700. private _tmpPosition;
  107701. private _tmpDeltaPosition;
  107702. private _tmpUnityRotation;
  107703. private _updatePhysicsBodyTransformation;
  107704. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107705. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107706. isSupported(): boolean;
  107707. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107708. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107709. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107710. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107711. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107712. getBodyMass(impostor: PhysicsImpostor): number;
  107713. getBodyFriction(impostor: PhysicsImpostor): number;
  107714. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107715. getBodyRestitution(impostor: PhysicsImpostor): number;
  107716. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107717. sleepBody(impostor: PhysicsImpostor): void;
  107718. wakeUpBody(impostor: PhysicsImpostor): void;
  107719. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  107720. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107721. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107722. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107723. getRadius(impostor: PhysicsImpostor): number;
  107724. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107725. dispose(): void;
  107726. private _extendNamespace;
  107727. /**
  107728. * Does a raycast in the physics world
  107729. * @param from when should the ray start?
  107730. * @param to when should the ray end?
  107731. * @returns PhysicsRaycastResult
  107732. */
  107733. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107734. }
  107735. }
  107736. declare module BABYLON {
  107737. /** @hidden */
  107738. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  107739. world: any;
  107740. name: string;
  107741. BJSOIMO: any;
  107742. private _raycastResult;
  107743. constructor(iterations?: number, oimoInjection?: any);
  107744. setGravity(gravity: Vector3): void;
  107745. setTimeStep(timeStep: number): void;
  107746. getTimeStep(): number;
  107747. private _tmpImpostorsArray;
  107748. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107749. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107750. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107751. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107752. private _tmpPositionVector;
  107753. removePhysicsBody(impostor: PhysicsImpostor): void;
  107754. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107755. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107756. isSupported(): boolean;
  107757. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107758. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107759. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107760. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107761. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107762. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107763. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107764. getBodyMass(impostor: PhysicsImpostor): number;
  107765. getBodyFriction(impostor: PhysicsImpostor): number;
  107766. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107767. getBodyRestitution(impostor: PhysicsImpostor): number;
  107768. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107769. sleepBody(impostor: PhysicsImpostor): void;
  107770. wakeUpBody(impostor: PhysicsImpostor): void;
  107771. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107772. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  107773. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107774. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107775. getRadius(impostor: PhysicsImpostor): number;
  107776. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107777. dispose(): void;
  107778. /**
  107779. * Does a raycast in the physics world
  107780. * @param from when should the ray start?
  107781. * @param to when should the ray end?
  107782. * @returns PhysicsRaycastResult
  107783. */
  107784. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107785. }
  107786. }
  107787. declare module BABYLON {
  107788. /**
  107789. * Class containing static functions to help procedurally build meshes
  107790. */
  107791. export class RibbonBuilder {
  107792. /**
  107793. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107794. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107795. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107796. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107797. * * 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
  107798. * * 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
  107799. * * 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
  107800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107801. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107802. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107803. * * 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
  107804. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107805. * * 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
  107806. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107808. * @param name defines the name of the mesh
  107809. * @param options defines the options used to create the mesh
  107810. * @param scene defines the hosting scene
  107811. * @returns the ribbon mesh
  107812. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107813. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107814. */
  107815. static CreateRibbon(name: string, options: {
  107816. pathArray: Vector3[][];
  107817. closeArray?: boolean;
  107818. closePath?: boolean;
  107819. offset?: number;
  107820. updatable?: boolean;
  107821. sideOrientation?: number;
  107822. frontUVs?: Vector4;
  107823. backUVs?: Vector4;
  107824. instance?: Mesh;
  107825. invertUV?: boolean;
  107826. uvs?: Vector2[];
  107827. colors?: Color4[];
  107828. }, scene?: Nullable<Scene>): Mesh;
  107829. }
  107830. }
  107831. declare module BABYLON {
  107832. /**
  107833. * Class containing static functions to help procedurally build meshes
  107834. */
  107835. export class ShapeBuilder {
  107836. /**
  107837. * 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.
  107838. * * 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.
  107839. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107840. * * 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.
  107841. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107842. * * 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
  107843. * * 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
  107844. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107847. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107849. * @param name defines the name of the mesh
  107850. * @param options defines the options used to create the mesh
  107851. * @param scene defines the hosting scene
  107852. * @returns the extruded shape mesh
  107853. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107855. */
  107856. static ExtrudeShape(name: string, options: {
  107857. shape: Vector3[];
  107858. path: Vector3[];
  107859. scale?: number;
  107860. rotation?: number;
  107861. cap?: number;
  107862. updatable?: boolean;
  107863. sideOrientation?: number;
  107864. frontUVs?: Vector4;
  107865. backUVs?: Vector4;
  107866. instance?: Mesh;
  107867. invertUV?: boolean;
  107868. }, scene?: Nullable<Scene>): Mesh;
  107869. /**
  107870. * Creates an custom extruded shape mesh.
  107871. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107872. * * 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.
  107873. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107874. * * 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
  107875. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107876. * * 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
  107877. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107878. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107879. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107880. * * 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
  107881. * * 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
  107882. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107885. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107887. * @param name defines the name of the mesh
  107888. * @param options defines the options used to create the mesh
  107889. * @param scene defines the hosting scene
  107890. * @returns the custom extruded shape mesh
  107891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107892. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107894. */
  107895. static ExtrudeShapeCustom(name: string, options: {
  107896. shape: Vector3[];
  107897. path: Vector3[];
  107898. scaleFunction?: any;
  107899. rotationFunction?: any;
  107900. ribbonCloseArray?: boolean;
  107901. ribbonClosePath?: boolean;
  107902. cap?: number;
  107903. updatable?: boolean;
  107904. sideOrientation?: number;
  107905. frontUVs?: Vector4;
  107906. backUVs?: Vector4;
  107907. instance?: Mesh;
  107908. invertUV?: boolean;
  107909. }, scene?: Nullable<Scene>): Mesh;
  107910. private static _ExtrudeShapeGeneric;
  107911. }
  107912. }
  107913. declare module BABYLON {
  107914. /**
  107915. * AmmoJS Physics plugin
  107916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107917. * @see https://github.com/kripken/ammo.js/
  107918. */
  107919. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107920. private _useDeltaForWorldStep;
  107921. /**
  107922. * Reference to the Ammo library
  107923. */
  107924. bjsAMMO: any;
  107925. /**
  107926. * Created ammoJS world which physics bodies are added to
  107927. */
  107928. world: any;
  107929. /**
  107930. * Name of the plugin
  107931. */
  107932. name: string;
  107933. private _timeStep;
  107934. private _fixedTimeStep;
  107935. private _maxSteps;
  107936. private _tmpQuaternion;
  107937. private _tmpAmmoTransform;
  107938. private _tmpAmmoQuaternion;
  107939. private _tmpAmmoConcreteContactResultCallback;
  107940. private _collisionConfiguration;
  107941. private _dispatcher;
  107942. private _overlappingPairCache;
  107943. private _solver;
  107944. private _softBodySolver;
  107945. private _tmpAmmoVectorA;
  107946. private _tmpAmmoVectorB;
  107947. private _tmpAmmoVectorC;
  107948. private _tmpAmmoVectorD;
  107949. private _tmpContactCallbackResult;
  107950. private _tmpAmmoVectorRCA;
  107951. private _tmpAmmoVectorRCB;
  107952. private _raycastResult;
  107953. private static readonly DISABLE_COLLISION_FLAG;
  107954. private static readonly KINEMATIC_FLAG;
  107955. private static readonly DISABLE_DEACTIVATION_FLAG;
  107956. /**
  107957. * Initializes the ammoJS plugin
  107958. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107959. * @param ammoInjection can be used to inject your own ammo reference
  107960. */
  107961. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107962. /**
  107963. * Sets the gravity of the physics world (m/(s^2))
  107964. * @param gravity Gravity to set
  107965. */
  107966. setGravity(gravity: Vector3): void;
  107967. /**
  107968. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107969. * @param timeStep timestep to use in seconds
  107970. */
  107971. setTimeStep(timeStep: number): void;
  107972. /**
  107973. * 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)
  107974. * @param fixedTimeStep fixedTimeStep to use in seconds
  107975. */
  107976. setFixedTimeStep(fixedTimeStep: number): void;
  107977. /**
  107978. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107979. * @param maxSteps the maximum number of steps by the physics engine per frame
  107980. */
  107981. setMaxSteps(maxSteps: number): void;
  107982. /**
  107983. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107984. * @returns the current timestep in seconds
  107985. */
  107986. getTimeStep(): number;
  107987. private _isImpostorInContact;
  107988. private _isImpostorPairInContact;
  107989. private _stepSimulation;
  107990. /**
  107991. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107992. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107993. * After the step the babylon meshes are set to the position of the physics imposters
  107994. * @param delta amount of time to step forward
  107995. * @param impostors array of imposters to update before/after the step
  107996. */
  107997. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107998. /**
  107999. * Update babylon mesh to match physics world object
  108000. * @param impostor imposter to match
  108001. */
  108002. private _afterSoftStep;
  108003. /**
  108004. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108005. * @param impostor imposter to match
  108006. */
  108007. private _ropeStep;
  108008. /**
  108009. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108010. * @param impostor imposter to match
  108011. */
  108012. private _softbodyOrClothStep;
  108013. private _tmpVector;
  108014. private _tmpMatrix;
  108015. /**
  108016. * Applies an impulse on the imposter
  108017. * @param impostor imposter to apply impulse to
  108018. * @param force amount of force to be applied to the imposter
  108019. * @param contactPoint the location to apply the impulse on the imposter
  108020. */
  108021. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108022. /**
  108023. * Applies a force on the imposter
  108024. * @param impostor imposter to apply force
  108025. * @param force amount of force to be applied to the imposter
  108026. * @param contactPoint the location to apply the force on the imposter
  108027. */
  108028. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108029. /**
  108030. * Creates a physics body using the plugin
  108031. * @param impostor the imposter to create the physics body on
  108032. */
  108033. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108034. /**
  108035. * Removes the physics body from the imposter and disposes of the body's memory
  108036. * @param impostor imposter to remove the physics body from
  108037. */
  108038. removePhysicsBody(impostor: PhysicsImpostor): void;
  108039. /**
  108040. * Generates a joint
  108041. * @param impostorJoint the imposter joint to create the joint with
  108042. */
  108043. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108044. /**
  108045. * Removes a joint
  108046. * @param impostorJoint the imposter joint to remove the joint from
  108047. */
  108048. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108049. private _addMeshVerts;
  108050. /**
  108051. * Initialise the soft body vertices to match its object's (mesh) vertices
  108052. * Softbody vertices (nodes) are in world space and to match this
  108053. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108054. * @param impostor to create the softbody for
  108055. */
  108056. private _softVertexData;
  108057. /**
  108058. * Create an impostor's soft body
  108059. * @param impostor to create the softbody for
  108060. */
  108061. private _createSoftbody;
  108062. /**
  108063. * Create cloth for an impostor
  108064. * @param impostor to create the softbody for
  108065. */
  108066. private _createCloth;
  108067. /**
  108068. * Create rope for an impostor
  108069. * @param impostor to create the softbody for
  108070. */
  108071. private _createRope;
  108072. private _addHullVerts;
  108073. private _createShape;
  108074. /**
  108075. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108076. * @param impostor imposter containing the physics body and babylon object
  108077. */
  108078. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108079. /**
  108080. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108081. * @param impostor imposter containing the physics body and babylon object
  108082. * @param newPosition new position
  108083. * @param newRotation new rotation
  108084. */
  108085. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108086. /**
  108087. * If this plugin is supported
  108088. * @returns true if its supported
  108089. */
  108090. isSupported(): boolean;
  108091. /**
  108092. * Sets the linear velocity of the physics body
  108093. * @param impostor imposter to set the velocity on
  108094. * @param velocity velocity to set
  108095. */
  108096. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108097. /**
  108098. * Sets the angular velocity of the physics body
  108099. * @param impostor imposter to set the velocity on
  108100. * @param velocity velocity to set
  108101. */
  108102. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108103. /**
  108104. * gets the linear velocity
  108105. * @param impostor imposter to get linear velocity from
  108106. * @returns linear velocity
  108107. */
  108108. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108109. /**
  108110. * gets the angular velocity
  108111. * @param impostor imposter to get angular velocity from
  108112. * @returns angular velocity
  108113. */
  108114. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108115. /**
  108116. * Sets the mass of physics body
  108117. * @param impostor imposter to set the mass on
  108118. * @param mass mass to set
  108119. */
  108120. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108121. /**
  108122. * Gets the mass of the physics body
  108123. * @param impostor imposter to get the mass from
  108124. * @returns mass
  108125. */
  108126. getBodyMass(impostor: PhysicsImpostor): number;
  108127. /**
  108128. * Gets friction of the impostor
  108129. * @param impostor impostor to get friction from
  108130. * @returns friction value
  108131. */
  108132. getBodyFriction(impostor: PhysicsImpostor): number;
  108133. /**
  108134. * Sets friction of the impostor
  108135. * @param impostor impostor to set friction on
  108136. * @param friction friction value
  108137. */
  108138. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108139. /**
  108140. * Gets restitution of the impostor
  108141. * @param impostor impostor to get restitution from
  108142. * @returns restitution value
  108143. */
  108144. getBodyRestitution(impostor: PhysicsImpostor): number;
  108145. /**
  108146. * Sets resitution of the impostor
  108147. * @param impostor impostor to set resitution on
  108148. * @param restitution resitution value
  108149. */
  108150. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108151. /**
  108152. * Gets pressure inside the impostor
  108153. * @param impostor impostor to get pressure from
  108154. * @returns pressure value
  108155. */
  108156. getBodyPressure(impostor: PhysicsImpostor): number;
  108157. /**
  108158. * Sets pressure inside a soft body impostor
  108159. * Cloth and rope must remain 0 pressure
  108160. * @param impostor impostor to set pressure on
  108161. * @param pressure pressure value
  108162. */
  108163. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108164. /**
  108165. * Gets stiffness of the impostor
  108166. * @param impostor impostor to get stiffness from
  108167. * @returns pressure value
  108168. */
  108169. getBodyStiffness(impostor: PhysicsImpostor): number;
  108170. /**
  108171. * Sets stiffness of the impostor
  108172. * @param impostor impostor to set stiffness on
  108173. * @param stiffness stiffness value from 0 to 1
  108174. */
  108175. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108176. /**
  108177. * Gets velocityIterations of the impostor
  108178. * @param impostor impostor to get velocity iterations from
  108179. * @returns velocityIterations value
  108180. */
  108181. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108182. /**
  108183. * Sets velocityIterations of the impostor
  108184. * @param impostor impostor to set velocity iterations on
  108185. * @param velocityIterations velocityIterations value
  108186. */
  108187. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108188. /**
  108189. * Gets positionIterations of the impostor
  108190. * @param impostor impostor to get position iterations from
  108191. * @returns positionIterations value
  108192. */
  108193. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108194. /**
  108195. * Sets positionIterations of the impostor
  108196. * @param impostor impostor to set position on
  108197. * @param positionIterations positionIterations value
  108198. */
  108199. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108200. /**
  108201. * Append an anchor to a cloth object
  108202. * @param impostor is the cloth impostor to add anchor to
  108203. * @param otherImpostor is the rigid impostor to anchor to
  108204. * @param width ratio across width from 0 to 1
  108205. * @param height ratio up height from 0 to 1
  108206. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108207. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108208. */
  108209. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108210. /**
  108211. * Append an hook to a rope object
  108212. * @param impostor is the rope impostor to add hook to
  108213. * @param otherImpostor is the rigid impostor to hook to
  108214. * @param length ratio along the rope from 0 to 1
  108215. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108216. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108217. */
  108218. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108219. /**
  108220. * Sleeps the physics body and stops it from being active
  108221. * @param impostor impostor to sleep
  108222. */
  108223. sleepBody(impostor: PhysicsImpostor): void;
  108224. /**
  108225. * Activates the physics body
  108226. * @param impostor impostor to activate
  108227. */
  108228. wakeUpBody(impostor: PhysicsImpostor): void;
  108229. /**
  108230. * Updates the distance parameters of the joint
  108231. * @param joint joint to update
  108232. * @param maxDistance maximum distance of the joint
  108233. * @param minDistance minimum distance of the joint
  108234. */
  108235. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108236. /**
  108237. * Sets a motor on the joint
  108238. * @param joint joint to set motor on
  108239. * @param speed speed of the motor
  108240. * @param maxForce maximum force of the motor
  108241. * @param motorIndex index of the motor
  108242. */
  108243. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108244. /**
  108245. * Sets the motors limit
  108246. * @param joint joint to set limit on
  108247. * @param upperLimit upper limit
  108248. * @param lowerLimit lower limit
  108249. */
  108250. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108251. /**
  108252. * Syncs the position and rotation of a mesh with the impostor
  108253. * @param mesh mesh to sync
  108254. * @param impostor impostor to update the mesh with
  108255. */
  108256. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108257. /**
  108258. * Gets the radius of the impostor
  108259. * @param impostor impostor to get radius from
  108260. * @returns the radius
  108261. */
  108262. getRadius(impostor: PhysicsImpostor): number;
  108263. /**
  108264. * Gets the box size of the impostor
  108265. * @param impostor impostor to get box size from
  108266. * @param result the resulting box size
  108267. */
  108268. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108269. /**
  108270. * Disposes of the impostor
  108271. */
  108272. dispose(): void;
  108273. /**
  108274. * Does a raycast in the physics world
  108275. * @param from when should the ray start?
  108276. * @param to when should the ray end?
  108277. * @returns PhysicsRaycastResult
  108278. */
  108279. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108280. }
  108281. }
  108282. declare module BABYLON {
  108283. interface AbstractScene {
  108284. /**
  108285. * The list of reflection probes added to the scene
  108286. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108287. */
  108288. reflectionProbes: Array<ReflectionProbe>;
  108289. /**
  108290. * Removes the given reflection probe from this scene.
  108291. * @param toRemove The reflection probe to remove
  108292. * @returns The index of the removed reflection probe
  108293. */
  108294. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108295. /**
  108296. * Adds the given reflection probe to this scene.
  108297. * @param newReflectionProbe The reflection probe to add
  108298. */
  108299. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108300. }
  108301. /**
  108302. * Class used to generate realtime reflection / refraction cube textures
  108303. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108304. */
  108305. export class ReflectionProbe {
  108306. /** defines the name of the probe */
  108307. name: string;
  108308. private _scene;
  108309. private _renderTargetTexture;
  108310. private _projectionMatrix;
  108311. private _viewMatrix;
  108312. private _target;
  108313. private _add;
  108314. private _attachedMesh;
  108315. private _invertYAxis;
  108316. /** Gets or sets probe position (center of the cube map) */
  108317. position: Vector3;
  108318. /**
  108319. * Creates a new reflection probe
  108320. * @param name defines the name of the probe
  108321. * @param size defines the texture resolution (for each face)
  108322. * @param scene defines the hosting scene
  108323. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108324. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108325. */
  108326. constructor(
  108327. /** defines the name of the probe */
  108328. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108329. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108330. samples: number;
  108331. /** Gets or sets the refresh rate to use (on every frame by default) */
  108332. refreshRate: number;
  108333. /**
  108334. * Gets the hosting scene
  108335. * @returns a Scene
  108336. */
  108337. getScene(): Scene;
  108338. /** Gets the internal CubeTexture used to render to */
  108339. readonly cubeTexture: RenderTargetTexture;
  108340. /** Gets the list of meshes to render */
  108341. readonly renderList: Nullable<AbstractMesh[]>;
  108342. /**
  108343. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108344. * @param mesh defines the mesh to attach to
  108345. */
  108346. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108347. /**
  108348. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108349. * @param renderingGroupId The rendering group id corresponding to its index
  108350. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108351. */
  108352. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108353. /**
  108354. * Clean all associated resources
  108355. */
  108356. dispose(): void;
  108357. /**
  108358. * Converts the reflection probe information to a readable string for debug purpose.
  108359. * @param fullDetails Supports for multiple levels of logging within scene loading
  108360. * @returns the human readable reflection probe info
  108361. */
  108362. toString(fullDetails?: boolean): string;
  108363. /**
  108364. * Get the class name of the relfection probe.
  108365. * @returns "ReflectionProbe"
  108366. */
  108367. getClassName(): string;
  108368. /**
  108369. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108370. * @returns The JSON representation of the texture
  108371. */
  108372. serialize(): any;
  108373. /**
  108374. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108375. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108376. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108377. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108378. * @returns The parsed reflection probe if successful
  108379. */
  108380. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108381. }
  108382. }
  108383. declare module BABYLON {
  108384. /** @hidden */
  108385. export var _BabylonLoaderRegistered: boolean;
  108386. }
  108387. declare module BABYLON {
  108388. /**
  108389. * The Physically based simple base material of BJS.
  108390. *
  108391. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108392. * It is used as the base class for both the specGloss and metalRough conventions.
  108393. */
  108394. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108395. /**
  108396. * Number of Simultaneous lights allowed on the material.
  108397. */
  108398. maxSimultaneousLights: number;
  108399. /**
  108400. * If sets to true, disables all the lights affecting the material.
  108401. */
  108402. disableLighting: boolean;
  108403. /**
  108404. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108405. */
  108406. environmentTexture: BaseTexture;
  108407. /**
  108408. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108409. */
  108410. invertNormalMapX: boolean;
  108411. /**
  108412. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108413. */
  108414. invertNormalMapY: boolean;
  108415. /**
  108416. * Normal map used in the model.
  108417. */
  108418. normalTexture: BaseTexture;
  108419. /**
  108420. * Emissivie color used to self-illuminate the model.
  108421. */
  108422. emissiveColor: Color3;
  108423. /**
  108424. * Emissivie texture used to self-illuminate the model.
  108425. */
  108426. emissiveTexture: BaseTexture;
  108427. /**
  108428. * Occlusion Channel Strenght.
  108429. */
  108430. occlusionStrength: number;
  108431. /**
  108432. * Occlusion Texture of the material (adding extra occlusion effects).
  108433. */
  108434. occlusionTexture: BaseTexture;
  108435. /**
  108436. * Defines the alpha limits in alpha test mode.
  108437. */
  108438. alphaCutOff: number;
  108439. /**
  108440. * Gets the current double sided mode.
  108441. */
  108442. /**
  108443. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108444. */
  108445. doubleSided: boolean;
  108446. /**
  108447. * Stores the pre-calculated light information of a mesh in a texture.
  108448. */
  108449. lightmapTexture: BaseTexture;
  108450. /**
  108451. * If true, the light map contains occlusion information instead of lighting info.
  108452. */
  108453. useLightmapAsShadowmap: boolean;
  108454. /**
  108455. * Instantiates a new PBRMaterial instance.
  108456. *
  108457. * @param name The material name
  108458. * @param scene The scene the material will be use in.
  108459. */
  108460. constructor(name: string, scene: Scene);
  108461. getClassName(): string;
  108462. }
  108463. }
  108464. declare module BABYLON {
  108465. /**
  108466. * The PBR material of BJS following the metal roughness convention.
  108467. *
  108468. * This fits to the PBR convention in the GLTF definition:
  108469. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108470. */
  108471. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108472. /**
  108473. * The base color has two different interpretations depending on the value of metalness.
  108474. * When the material is a metal, the base color is the specific measured reflectance value
  108475. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108476. * of the material.
  108477. */
  108478. baseColor: Color3;
  108479. /**
  108480. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  108481. * well as opacity information in the alpha channel.
  108482. */
  108483. baseTexture: BaseTexture;
  108484. /**
  108485. * Specifies the metallic scalar value of the material.
  108486. * Can also be used to scale the metalness values of the metallic texture.
  108487. */
  108488. metallic: number;
  108489. /**
  108490. * Specifies the roughness scalar value of the material.
  108491. * Can also be used to scale the roughness values of the metallic texture.
  108492. */
  108493. roughness: number;
  108494. /**
  108495. * Texture containing both the metallic value in the B channel and the
  108496. * roughness value in the G channel to keep better precision.
  108497. */
  108498. metallicRoughnessTexture: BaseTexture;
  108499. /**
  108500. * Instantiates a new PBRMetalRoughnessMaterial instance.
  108501. *
  108502. * @param name The material name
  108503. * @param scene The scene the material will be use in.
  108504. */
  108505. constructor(name: string, scene: Scene);
  108506. /**
  108507. * Return the currrent class name of the material.
  108508. */
  108509. getClassName(): string;
  108510. /**
  108511. * Makes a duplicate of the current material.
  108512. * @param name - name to use for the new material.
  108513. */
  108514. clone(name: string): PBRMetallicRoughnessMaterial;
  108515. /**
  108516. * Serialize the material to a parsable JSON object.
  108517. */
  108518. serialize(): any;
  108519. /**
  108520. * Parses a JSON object correponding to the serialize function.
  108521. */
  108522. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  108523. }
  108524. }
  108525. declare module BABYLON {
  108526. /**
  108527. * The PBR material of BJS following the specular glossiness convention.
  108528. *
  108529. * This fits to the PBR convention in the GLTF definition:
  108530. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  108531. */
  108532. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  108533. /**
  108534. * Specifies the diffuse color of the material.
  108535. */
  108536. diffuseColor: Color3;
  108537. /**
  108538. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  108539. * channel.
  108540. */
  108541. diffuseTexture: BaseTexture;
  108542. /**
  108543. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  108544. */
  108545. specularColor: Color3;
  108546. /**
  108547. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  108548. */
  108549. glossiness: number;
  108550. /**
  108551. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  108552. */
  108553. specularGlossinessTexture: BaseTexture;
  108554. /**
  108555. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  108556. *
  108557. * @param name The material name
  108558. * @param scene The scene the material will be use in.
  108559. */
  108560. constructor(name: string, scene: Scene);
  108561. /**
  108562. * Return the currrent class name of the material.
  108563. */
  108564. getClassName(): string;
  108565. /**
  108566. * Makes a duplicate of the current material.
  108567. * @param name - name to use for the new material.
  108568. */
  108569. clone(name: string): PBRSpecularGlossinessMaterial;
  108570. /**
  108571. * Serialize the material to a parsable JSON object.
  108572. */
  108573. serialize(): any;
  108574. /**
  108575. * Parses a JSON object correponding to the serialize function.
  108576. */
  108577. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  108578. }
  108579. }
  108580. declare module BABYLON {
  108581. /**
  108582. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  108583. * It can help converting any input color in a desired output one. This can then be used to create effects
  108584. * from sepia, black and white to sixties or futuristic rendering...
  108585. *
  108586. * The only supported format is currently 3dl.
  108587. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  108588. */
  108589. export class ColorGradingTexture extends BaseTexture {
  108590. /**
  108591. * The current texture matrix. (will always be identity in color grading texture)
  108592. */
  108593. private _textureMatrix;
  108594. /**
  108595. * The texture URL.
  108596. */
  108597. url: string;
  108598. /**
  108599. * Empty line regex stored for GC.
  108600. */
  108601. private static _noneEmptyLineRegex;
  108602. private _engine;
  108603. /**
  108604. * Instantiates a ColorGradingTexture from the following parameters.
  108605. *
  108606. * @param url The location of the color gradind data (currently only supporting 3dl)
  108607. * @param scene The scene the texture will be used in
  108608. */
  108609. constructor(url: string, scene: Scene);
  108610. /**
  108611. * Returns the texture matrix used in most of the material.
  108612. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  108613. */
  108614. getTextureMatrix(): Matrix;
  108615. /**
  108616. * Occurs when the file being loaded is a .3dl LUT file.
  108617. */
  108618. private load3dlTexture;
  108619. /**
  108620. * Starts the loading process of the texture.
  108621. */
  108622. private loadTexture;
  108623. /**
  108624. * Clones the color gradind texture.
  108625. */
  108626. clone(): ColorGradingTexture;
  108627. /**
  108628. * Called during delayed load for textures.
  108629. */
  108630. delayLoad(): void;
  108631. /**
  108632. * Parses a color grading texture serialized by Babylon.
  108633. * @param parsedTexture The texture information being parsedTexture
  108634. * @param scene The scene to load the texture in
  108635. * @param rootUrl The root url of the data assets to load
  108636. * @return A color gradind texture
  108637. */
  108638. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  108639. /**
  108640. * Serializes the LUT texture to json format.
  108641. */
  108642. serialize(): any;
  108643. }
  108644. }
  108645. declare module BABYLON {
  108646. /**
  108647. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  108648. */
  108649. export class EquiRectangularCubeTexture extends BaseTexture {
  108650. /** The six faces of the cube. */
  108651. private static _FacesMapping;
  108652. private _noMipmap;
  108653. private _onLoad;
  108654. private _onError;
  108655. /** The size of the cubemap. */
  108656. private _size;
  108657. /** The buffer of the image. */
  108658. private _buffer;
  108659. /** The width of the input image. */
  108660. private _width;
  108661. /** The height of the input image. */
  108662. private _height;
  108663. /** The URL to the image. */
  108664. url: string;
  108665. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  108666. coordinatesMode: number;
  108667. /**
  108668. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  108669. * @param url The location of the image
  108670. * @param scene The scene the texture will be used in
  108671. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108672. * @param noMipmap Forces to not generate the mipmap if true
  108673. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  108674. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  108675. * @param onLoad — defines a callback called when texture is loaded
  108676. * @param onError — defines a callback called if there is an error
  108677. */
  108678. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  108679. /**
  108680. * Load the image data, by putting the image on a canvas and extracting its buffer.
  108681. */
  108682. private loadImage;
  108683. /**
  108684. * Convert the image buffer into a cubemap and create a CubeTexture.
  108685. */
  108686. private loadTexture;
  108687. /**
  108688. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  108689. * @param buffer The ArrayBuffer that should be converted.
  108690. * @returns The buffer as Float32Array.
  108691. */
  108692. private getFloat32ArrayFromArrayBuffer;
  108693. /**
  108694. * Get the current class name of the texture useful for serialization or dynamic coding.
  108695. * @returns "EquiRectangularCubeTexture"
  108696. */
  108697. getClassName(): string;
  108698. /**
  108699. * Create a clone of the current EquiRectangularCubeTexture and return it.
  108700. * @returns A clone of the current EquiRectangularCubeTexture.
  108701. */
  108702. clone(): EquiRectangularCubeTexture;
  108703. }
  108704. }
  108705. declare module BABYLON {
  108706. /**
  108707. * Based on jsTGALoader - Javascript loader for TGA file
  108708. * By Vincent Thibault
  108709. * @see http://blog.robrowser.com/javascript-tga-loader.html
  108710. */
  108711. export class TGATools {
  108712. private static _TYPE_INDEXED;
  108713. private static _TYPE_RGB;
  108714. private static _TYPE_GREY;
  108715. private static _TYPE_RLE_INDEXED;
  108716. private static _TYPE_RLE_RGB;
  108717. private static _TYPE_RLE_GREY;
  108718. private static _ORIGIN_MASK;
  108719. private static _ORIGIN_SHIFT;
  108720. private static _ORIGIN_BL;
  108721. private static _ORIGIN_BR;
  108722. private static _ORIGIN_UL;
  108723. private static _ORIGIN_UR;
  108724. /**
  108725. * Gets the header of a TGA file
  108726. * @param data defines the TGA data
  108727. * @returns the header
  108728. */
  108729. static GetTGAHeader(data: Uint8Array): any;
  108730. /**
  108731. * Uploads TGA content to a Babylon Texture
  108732. * @hidden
  108733. */
  108734. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  108735. /** @hidden */
  108736. 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;
  108737. /** @hidden */
  108738. 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;
  108739. /** @hidden */
  108740. 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;
  108741. /** @hidden */
  108742. 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;
  108743. /** @hidden */
  108744. 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;
  108745. /** @hidden */
  108746. 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;
  108747. }
  108748. }
  108749. declare module BABYLON {
  108750. /**
  108751. * Implementation of the TGA Texture Loader.
  108752. * @hidden
  108753. */
  108754. export class _TGATextureLoader implements IInternalTextureLoader {
  108755. /**
  108756. * Defines wether the loader supports cascade loading the different faces.
  108757. */
  108758. readonly supportCascades: boolean;
  108759. /**
  108760. * This returns if the loader support the current file information.
  108761. * @param extension defines the file extension of the file being loaded
  108762. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108763. * @param fallback defines the fallback internal texture if any
  108764. * @param isBase64 defines whether the texture is encoded as a base64
  108765. * @param isBuffer defines whether the texture data are stored as a buffer
  108766. * @returns true if the loader can load the specified file
  108767. */
  108768. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108769. /**
  108770. * Transform the url before loading if required.
  108771. * @param rootUrl the url of the texture
  108772. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108773. * @returns the transformed texture
  108774. */
  108775. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108776. /**
  108777. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108778. * @param rootUrl the url of the texture
  108779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108780. * @returns the fallback texture
  108781. */
  108782. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108783. /**
  108784. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108785. * @param data contains the texture data
  108786. * @param texture defines the BabylonJS internal texture
  108787. * @param createPolynomials will be true if polynomials have been requested
  108788. * @param onLoad defines the callback to trigger once the texture is ready
  108789. * @param onError defines the callback to trigger in case of error
  108790. */
  108791. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108792. /**
  108793. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108794. * @param data contains the texture data
  108795. * @param texture defines the BabylonJS internal texture
  108796. * @param callback defines the method to call once ready to upload
  108797. */
  108798. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108799. }
  108800. }
  108801. declare module BABYLON {
  108802. /**
  108803. * 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.
  108804. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108805. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108806. */
  108807. export class CustomProceduralTexture extends ProceduralTexture {
  108808. private _animate;
  108809. private _time;
  108810. private _config;
  108811. private _texturePath;
  108812. /**
  108813. * Instantiates a new Custom Procedural Texture.
  108814. * 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.
  108815. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108816. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108817. * @param name Define the name of the texture
  108818. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  108819. * @param size Define the size of the texture to create
  108820. * @param scene Define the scene the texture belongs to
  108821. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  108822. * @param generateMipMaps Define if the texture should creates mip maps or not
  108823. */
  108824. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108825. private _loadJson;
  108826. /**
  108827. * Is the texture ready to be used ? (rendered at least once)
  108828. * @returns true if ready, otherwise, false.
  108829. */
  108830. isReady(): boolean;
  108831. /**
  108832. * Render the texture to its associated render target.
  108833. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  108834. */
  108835. render(useCameraPostProcess?: boolean): void;
  108836. /**
  108837. * Update the list of dependant textures samplers in the shader.
  108838. */
  108839. updateTextures(): void;
  108840. /**
  108841. * Update the uniform values of the procedural texture in the shader.
  108842. */
  108843. updateShaderUniforms(): void;
  108844. /**
  108845. * Define if the texture animates or not.
  108846. */
  108847. animate: boolean;
  108848. }
  108849. }
  108850. declare module BABYLON {
  108851. /** @hidden */
  108852. export var noisePixelShader: {
  108853. name: string;
  108854. shader: string;
  108855. };
  108856. }
  108857. declare module BABYLON {
  108858. /**
  108859. * Class used to generate noise procedural textures
  108860. */
  108861. export class NoiseProceduralTexture extends ProceduralTexture {
  108862. private _time;
  108863. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  108864. brightness: number;
  108865. /** Defines the number of octaves to process */
  108866. octaves: number;
  108867. /** Defines the level of persistence (0.8 by default) */
  108868. persistence: number;
  108869. /** Gets or sets animation speed factor (default is 1) */
  108870. animationSpeedFactor: number;
  108871. /**
  108872. * Creates a new NoiseProceduralTexture
  108873. * @param name defines the name fo the texture
  108874. * @param size defines the size of the texture (default is 256)
  108875. * @param scene defines the hosting scene
  108876. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  108877. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  108878. */
  108879. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108880. private _updateShaderUniforms;
  108881. protected _getDefines(): string;
  108882. /** Generate the current state of the procedural texture */
  108883. render(useCameraPostProcess?: boolean): void;
  108884. /**
  108885. * Serializes this noise procedural texture
  108886. * @returns a serialized noise procedural texture object
  108887. */
  108888. serialize(): any;
  108889. /**
  108890. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  108891. * @param parsedTexture defines parsed texture data
  108892. * @param scene defines the current scene
  108893. * @param rootUrl defines the root URL containing noise procedural texture information
  108894. * @returns a parsed NoiseProceduralTexture
  108895. */
  108896. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  108897. }
  108898. }
  108899. declare module BABYLON {
  108900. /**
  108901. * Raw cube texture where the raw buffers are passed in
  108902. */
  108903. export class RawCubeTexture extends CubeTexture {
  108904. /**
  108905. * Creates a cube texture where the raw buffers are passed in.
  108906. * @param scene defines the scene the texture is attached to
  108907. * @param data defines the array of data to use to create each face
  108908. * @param size defines the size of the textures
  108909. * @param format defines the format of the data
  108910. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  108911. * @param generateMipMaps defines if the engine should generate the mip levels
  108912. * @param invertY defines if data must be stored with Y axis inverted
  108913. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  108914. * @param compression defines the compression used (null by default)
  108915. */
  108916. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  108917. /**
  108918. * Updates the raw cube texture.
  108919. * @param data defines the data to store
  108920. * @param format defines the data format
  108921. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  108922. * @param invertY defines if data must be stored with Y axis inverted
  108923. * @param compression defines the compression used (null by default)
  108924. * @param level defines which level of the texture to update
  108925. */
  108926. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  108927. /**
  108928. * Updates a raw cube texture with RGBD encoded data.
  108929. * @param data defines the array of data [mipmap][face] to use to create each face
  108930. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  108931. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  108932. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  108933. * @returns a promsie that resolves when the operation is complete
  108934. */
  108935. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  108936. /**
  108937. * Clones the raw cube texture.
  108938. * @return a new cube texture
  108939. */
  108940. clone(): CubeTexture;
  108941. /** @hidden */
  108942. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108943. }
  108944. }
  108945. declare module BABYLON {
  108946. /**
  108947. * Class used to store 3D textures containing user data
  108948. */
  108949. export class RawTexture3D extends Texture {
  108950. /** Gets or sets the texture format to use */
  108951. format: number;
  108952. private _engine;
  108953. /**
  108954. * Create a new RawTexture3D
  108955. * @param data defines the data of the texture
  108956. * @param width defines the width of the texture
  108957. * @param height defines the height of the texture
  108958. * @param depth defines the depth of the texture
  108959. * @param format defines the texture format to use
  108960. * @param scene defines the hosting scene
  108961. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  108962. * @param invertY defines if texture must be stored with Y axis inverted
  108963. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108964. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  108965. */
  108966. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  108967. /** Gets or sets the texture format to use */
  108968. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  108969. /**
  108970. * Update the texture with new data
  108971. * @param data defines the data to store in the texture
  108972. */
  108973. update(data: ArrayBufferView): void;
  108974. }
  108975. }
  108976. declare module BABYLON {
  108977. /**
  108978. * Creates a refraction texture used by refraction channel of the standard material.
  108979. * It is like a mirror but to see through a material.
  108980. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108981. */
  108982. export class RefractionTexture extends RenderTargetTexture {
  108983. /**
  108984. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  108985. * 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.
  108986. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108987. */
  108988. refractionPlane: Plane;
  108989. /**
  108990. * Define how deep under the surface we should see.
  108991. */
  108992. depth: number;
  108993. /**
  108994. * Creates a refraction texture used by refraction channel of the standard material.
  108995. * It is like a mirror but to see through a material.
  108996. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108997. * @param name Define the texture name
  108998. * @param size Define the size of the underlying texture
  108999. * @param scene Define the scene the refraction belongs to
  109000. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109001. */
  109002. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109003. /**
  109004. * Clone the refraction texture.
  109005. * @returns the cloned texture
  109006. */
  109007. clone(): RefractionTexture;
  109008. /**
  109009. * Serialize the texture to a JSON representation you could use in Parse later on
  109010. * @returns the serialized JSON representation
  109011. */
  109012. serialize(): any;
  109013. }
  109014. }
  109015. declare module BABYLON {
  109016. /**
  109017. * Defines the options related to the creation of an HtmlElementTexture
  109018. */
  109019. export interface IHtmlElementTextureOptions {
  109020. /**
  109021. * Defines wether mip maps should be created or not.
  109022. */
  109023. generateMipMaps?: boolean;
  109024. /**
  109025. * Defines the sampling mode of the texture.
  109026. */
  109027. samplingMode?: number;
  109028. /**
  109029. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109030. */
  109031. engine: Nullable<Engine>;
  109032. /**
  109033. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109034. */
  109035. scene: Nullable<Scene>;
  109036. }
  109037. /**
  109038. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109039. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109040. * is automatically managed.
  109041. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109042. * in your application.
  109043. *
  109044. * As the update is not automatic, you need to call them manually.
  109045. */
  109046. export class HtmlElementTexture extends BaseTexture {
  109047. /**
  109048. * The texture URL.
  109049. */
  109050. element: HTMLVideoElement | HTMLCanvasElement;
  109051. private static readonly DefaultOptions;
  109052. private _textureMatrix;
  109053. private _engine;
  109054. private _isVideo;
  109055. private _generateMipMaps;
  109056. private _samplingMode;
  109057. /**
  109058. * Instantiates a HtmlElementTexture from the following parameters.
  109059. *
  109060. * @param name Defines the name of the texture
  109061. * @param element Defines the video or canvas the texture is filled with
  109062. * @param options Defines the other none mandatory texture creation options
  109063. */
  109064. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109065. private _createInternalTexture;
  109066. /**
  109067. * Returns the texture matrix used in most of the material.
  109068. */
  109069. getTextureMatrix(): Matrix;
  109070. /**
  109071. * Updates the content of the texture.
  109072. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109073. */
  109074. update(invertY?: Nullable<boolean>): void;
  109075. }
  109076. }
  109077. declare module BABYLON {
  109078. /**
  109079. * Helper class to push actions to a pool of workers.
  109080. */
  109081. export class WorkerPool implements IDisposable {
  109082. private _workerInfos;
  109083. private _pendingActions;
  109084. /**
  109085. * Constructor
  109086. * @param workers Array of workers to use for actions
  109087. */
  109088. constructor(workers: Array<Worker>);
  109089. /**
  109090. * Terminates all workers and clears any pending actions.
  109091. */
  109092. dispose(): void;
  109093. /**
  109094. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109095. * pended until a worker has completed its action.
  109096. * @param action The action to perform. Call onComplete when the action is complete.
  109097. */
  109098. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109099. private _execute;
  109100. }
  109101. }
  109102. declare module BABYLON {
  109103. /**
  109104. * Configuration for Draco compression
  109105. */
  109106. export interface IDracoCompressionConfiguration {
  109107. /**
  109108. * Configuration for the decoder.
  109109. */
  109110. decoder?: {
  109111. /**
  109112. * The url to the WebAssembly module.
  109113. */
  109114. wasmUrl?: string;
  109115. /**
  109116. * The url to the WebAssembly binary.
  109117. */
  109118. wasmBinaryUrl?: string;
  109119. /**
  109120. * The url to the fallback JavaScript module.
  109121. */
  109122. fallbackUrl?: string;
  109123. };
  109124. }
  109125. /**
  109126. * Draco compression (https://google.github.io/draco/)
  109127. *
  109128. * This class wraps the Draco module.
  109129. *
  109130. * **Encoder**
  109131. *
  109132. * The encoder is not currently implemented.
  109133. *
  109134. * **Decoder**
  109135. *
  109136. * 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.
  109137. *
  109138. * To update the configuration, use the following code:
  109139. * ```javascript
  109140. * DracoCompression.Configuration = {
  109141. * decoder: {
  109142. * wasmUrl: "<url to the WebAssembly library>",
  109143. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109144. * fallbackUrl: "<url to the fallback JavaScript library>",
  109145. * }
  109146. * };
  109147. * ```
  109148. *
  109149. * 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.
  109150. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109151. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  109152. *
  109153. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  109154. * ```javascript
  109155. * var dracoCompression = new DracoCompression();
  109156. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  109157. * [VertexBuffer.PositionKind]: 0
  109158. * });
  109159. * ```
  109160. *
  109161. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109162. */
  109163. export class DracoCompression implements IDisposable {
  109164. private _workerPoolPromise;
  109165. /**
  109166. * The configuration. Defaults to the following urls:
  109167. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109168. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109169. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109170. */
  109171. static Configuration: IDracoCompressionConfiguration;
  109172. /**
  109173. * Returns true if the decoder is available.
  109174. */
  109175. static readonly DecoderAvailable: boolean;
  109176. /**
  109177. * Default number of workers to create when creating the draco compression object.
  109178. */
  109179. static DefaultNumWorkers: number;
  109180. private static GetDefaultNumWorkers;
  109181. /**
  109182. * Constructor
  109183. * @param numWorkers The number of workers for async operations
  109184. */
  109185. constructor(numWorkers?: number);
  109186. /**
  109187. * Stop all async operations and release resources.
  109188. */
  109189. dispose(): void;
  109190. /**
  109191. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109192. * @returns a promise that resolves when ready
  109193. */
  109194. whenReadyAsync(): Promise<void>;
  109195. /**
  109196. * Decode Draco compressed mesh data to vertex data.
  109197. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109198. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109199. * @returns A promise that resolves with the decoded vertex data
  109200. */
  109201. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109202. [kind: string]: number;
  109203. }): Promise<VertexData>;
  109204. /**
  109205. * The worker function that gets converted to a blob url to pass into a worker.
  109206. */
  109207. private static _Worker;
  109208. private _loadDecoderWasmBinaryAsync;
  109209. }
  109210. }
  109211. declare module BABYLON {
  109212. /**
  109213. * Class for building Constructive Solid Geometry
  109214. */
  109215. export class CSG {
  109216. private polygons;
  109217. /**
  109218. * The world matrix
  109219. */
  109220. matrix: Matrix;
  109221. /**
  109222. * Stores the position
  109223. */
  109224. position: Vector3;
  109225. /**
  109226. * Stores the rotation
  109227. */
  109228. rotation: Vector3;
  109229. /**
  109230. * Stores the rotation quaternion
  109231. */
  109232. rotationQuaternion: Nullable<Quaternion>;
  109233. /**
  109234. * Stores the scaling vector
  109235. */
  109236. scaling: Vector3;
  109237. /**
  109238. * Convert the Mesh to CSG
  109239. * @param mesh The Mesh to convert to CSG
  109240. * @returns A new CSG from the Mesh
  109241. */
  109242. static FromMesh(mesh: Mesh): CSG;
  109243. /**
  109244. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109245. * @param polygons Polygons used to construct a CSG solid
  109246. */
  109247. private static FromPolygons;
  109248. /**
  109249. * Clones, or makes a deep copy, of the CSG
  109250. * @returns A new CSG
  109251. */
  109252. clone(): CSG;
  109253. /**
  109254. * Unions this CSG with another CSG
  109255. * @param csg The CSG to union against this CSG
  109256. * @returns The unioned CSG
  109257. */
  109258. union(csg: CSG): CSG;
  109259. /**
  109260. * Unions this CSG with another CSG in place
  109261. * @param csg The CSG to union against this CSG
  109262. */
  109263. unionInPlace(csg: CSG): void;
  109264. /**
  109265. * Subtracts this CSG with another CSG
  109266. * @param csg The CSG to subtract against this CSG
  109267. * @returns A new CSG
  109268. */
  109269. subtract(csg: CSG): CSG;
  109270. /**
  109271. * Subtracts this CSG with another CSG in place
  109272. * @param csg The CSG to subtact against this CSG
  109273. */
  109274. subtractInPlace(csg: CSG): void;
  109275. /**
  109276. * Intersect this CSG with another CSG
  109277. * @param csg The CSG to intersect against this CSG
  109278. * @returns A new CSG
  109279. */
  109280. intersect(csg: CSG): CSG;
  109281. /**
  109282. * Intersects this CSG with another CSG in place
  109283. * @param csg The CSG to intersect against this CSG
  109284. */
  109285. intersectInPlace(csg: CSG): void;
  109286. /**
  109287. * Return a new CSG solid with solid and empty space switched. This solid is
  109288. * not modified.
  109289. * @returns A new CSG solid with solid and empty space switched
  109290. */
  109291. inverse(): CSG;
  109292. /**
  109293. * Inverses the CSG in place
  109294. */
  109295. inverseInPlace(): void;
  109296. /**
  109297. * This is used to keep meshes transformations so they can be restored
  109298. * when we build back a Babylon Mesh
  109299. * NB : All CSG operations are performed in world coordinates
  109300. * @param csg The CSG to copy the transform attributes from
  109301. * @returns This CSG
  109302. */
  109303. copyTransformAttributes(csg: CSG): CSG;
  109304. /**
  109305. * Build Raw mesh from CSG
  109306. * Coordinates here are in world space
  109307. * @param name The name of the mesh geometry
  109308. * @param scene The Scene
  109309. * @param keepSubMeshes Specifies if the submeshes should be kept
  109310. * @returns A new Mesh
  109311. */
  109312. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109313. /**
  109314. * Build Mesh from CSG taking material and transforms into account
  109315. * @param name The name of the Mesh
  109316. * @param material The material of the Mesh
  109317. * @param scene The Scene
  109318. * @param keepSubMeshes Specifies if submeshes should be kept
  109319. * @returns The new Mesh
  109320. */
  109321. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109322. }
  109323. }
  109324. declare module BABYLON {
  109325. /**
  109326. * Class used to create a trail following a mesh
  109327. */
  109328. export class TrailMesh extends Mesh {
  109329. private _generator;
  109330. private _autoStart;
  109331. private _running;
  109332. private _diameter;
  109333. private _length;
  109334. private _sectionPolygonPointsCount;
  109335. private _sectionVectors;
  109336. private _sectionNormalVectors;
  109337. private _beforeRenderObserver;
  109338. /**
  109339. * @constructor
  109340. * @param name The value used by scene.getMeshByName() to do a lookup.
  109341. * @param generator The mesh to generate a trail.
  109342. * @param scene The scene to add this mesh to.
  109343. * @param diameter Diameter of trailing mesh. Default is 1.
  109344. * @param length Length of trailing mesh. Default is 60.
  109345. * @param autoStart Automatically start trailing mesh. Default true.
  109346. */
  109347. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109348. /**
  109349. * "TrailMesh"
  109350. * @returns "TrailMesh"
  109351. */
  109352. getClassName(): string;
  109353. private _createMesh;
  109354. /**
  109355. * Start trailing mesh.
  109356. */
  109357. start(): void;
  109358. /**
  109359. * Stop trailing mesh.
  109360. */
  109361. stop(): void;
  109362. /**
  109363. * Update trailing mesh geometry.
  109364. */
  109365. update(): void;
  109366. /**
  109367. * Returns a new TrailMesh object.
  109368. * @param name is a string, the name given to the new mesh
  109369. * @param newGenerator use new generator object for cloned trail mesh
  109370. * @returns a new mesh
  109371. */
  109372. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109373. /**
  109374. * Serializes this trail mesh
  109375. * @param serializationObject object to write serialization to
  109376. */
  109377. serialize(serializationObject: any): void;
  109378. /**
  109379. * Parses a serialized trail mesh
  109380. * @param parsedMesh the serialized mesh
  109381. * @param scene the scene to create the trail mesh in
  109382. * @returns the created trail mesh
  109383. */
  109384. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109385. }
  109386. }
  109387. declare module BABYLON {
  109388. /**
  109389. * Class containing static functions to help procedurally build meshes
  109390. */
  109391. export class TorusKnotBuilder {
  109392. /**
  109393. * Creates a torus knot mesh
  109394. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109395. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109396. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109397. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109401. * @param name defines the name of the mesh
  109402. * @param options defines the options used to create the mesh
  109403. * @param scene defines the hosting scene
  109404. * @returns the torus knot mesh
  109405. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109406. */
  109407. static CreateTorusKnot(name: string, options: {
  109408. radius?: number;
  109409. tube?: number;
  109410. radialSegments?: number;
  109411. tubularSegments?: number;
  109412. p?: number;
  109413. q?: number;
  109414. updatable?: boolean;
  109415. sideOrientation?: number;
  109416. frontUVs?: Vector4;
  109417. backUVs?: Vector4;
  109418. }, scene: any): Mesh;
  109419. }
  109420. }
  109421. declare module BABYLON {
  109422. /**
  109423. * Polygon
  109424. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109425. */
  109426. export class Polygon {
  109427. /**
  109428. * Creates a rectangle
  109429. * @param xmin bottom X coord
  109430. * @param ymin bottom Y coord
  109431. * @param xmax top X coord
  109432. * @param ymax top Y coord
  109433. * @returns points that make the resulting rectation
  109434. */
  109435. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109436. /**
  109437. * Creates a circle
  109438. * @param radius radius of circle
  109439. * @param cx scale in x
  109440. * @param cy scale in y
  109441. * @param numberOfSides number of sides that make up the circle
  109442. * @returns points that make the resulting circle
  109443. */
  109444. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109445. /**
  109446. * Creates a polygon from input string
  109447. * @param input Input polygon data
  109448. * @returns the parsed points
  109449. */
  109450. static Parse(input: string): Vector2[];
  109451. /**
  109452. * Starts building a polygon from x and y coordinates
  109453. * @param x x coordinate
  109454. * @param y y coordinate
  109455. * @returns the started path2
  109456. */
  109457. static StartingAt(x: number, y: number): Path2;
  109458. }
  109459. /**
  109460. * Builds a polygon
  109461. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  109462. */
  109463. export class PolygonMeshBuilder {
  109464. private _points;
  109465. private _outlinepoints;
  109466. private _holes;
  109467. private _name;
  109468. private _scene;
  109469. private _epoints;
  109470. private _eholes;
  109471. private _addToepoint;
  109472. /**
  109473. * Babylon reference to the earcut plugin.
  109474. */
  109475. bjsEarcut: any;
  109476. /**
  109477. * Creates a PolygonMeshBuilder
  109478. * @param name name of the builder
  109479. * @param contours Path of the polygon
  109480. * @param scene scene to add to when creating the mesh
  109481. * @param earcutInjection can be used to inject your own earcut reference
  109482. */
  109483. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  109484. /**
  109485. * Adds a whole within the polygon
  109486. * @param hole Array of points defining the hole
  109487. * @returns this
  109488. */
  109489. addHole(hole: Vector2[]): PolygonMeshBuilder;
  109490. /**
  109491. * Creates the polygon
  109492. * @param updatable If the mesh should be updatable
  109493. * @param depth The depth of the mesh created
  109494. * @returns the created mesh
  109495. */
  109496. build(updatable?: boolean, depth?: number): Mesh;
  109497. /**
  109498. * Creates the polygon
  109499. * @param depth The depth of the mesh created
  109500. * @returns the created VertexData
  109501. */
  109502. buildVertexData(depth?: number): VertexData;
  109503. /**
  109504. * Adds a side to the polygon
  109505. * @param positions points that make the polygon
  109506. * @param normals normals of the polygon
  109507. * @param uvs uvs of the polygon
  109508. * @param indices indices of the polygon
  109509. * @param bounds bounds of the polygon
  109510. * @param points points of the polygon
  109511. * @param depth depth of the polygon
  109512. * @param flip flip of the polygon
  109513. */
  109514. private addSide;
  109515. }
  109516. }
  109517. declare module BABYLON {
  109518. /**
  109519. * Class containing static functions to help procedurally build meshes
  109520. */
  109521. export class PolygonBuilder {
  109522. /**
  109523. * Creates a polygon mesh
  109524. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109525. * * 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
  109526. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109529. * * Remember you can only change the shape positions, not their number when updating a polygon
  109530. * @param name defines the name of the mesh
  109531. * @param options defines the options used to create the mesh
  109532. * @param scene defines the hosting scene
  109533. * @param earcutInjection can be used to inject your own earcut reference
  109534. * @returns the polygon mesh
  109535. */
  109536. static CreatePolygon(name: string, options: {
  109537. shape: Vector3[];
  109538. holes?: Vector3[][];
  109539. depth?: number;
  109540. faceUV?: Vector4[];
  109541. faceColors?: Color4[];
  109542. updatable?: boolean;
  109543. sideOrientation?: number;
  109544. frontUVs?: Vector4;
  109545. backUVs?: Vector4;
  109546. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109547. /**
  109548. * Creates an extruded polygon mesh, with depth in the Y direction.
  109549. * * 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)
  109550. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109551. * @param name defines the name of the mesh
  109552. * @param options defines the options used to create the mesh
  109553. * @param scene defines the hosting scene
  109554. * @param earcutInjection can be used to inject your own earcut reference
  109555. * @returns the polygon mesh
  109556. */
  109557. static ExtrudePolygon(name: string, options: {
  109558. shape: Vector3[];
  109559. holes?: Vector3[][];
  109560. depth?: number;
  109561. faceUV?: Vector4[];
  109562. faceColors?: Color4[];
  109563. updatable?: boolean;
  109564. sideOrientation?: number;
  109565. frontUVs?: Vector4;
  109566. backUVs?: Vector4;
  109567. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109568. }
  109569. }
  109570. declare module BABYLON {
  109571. /**
  109572. * Class containing static functions to help procedurally build meshes
  109573. */
  109574. export class LatheBuilder {
  109575. /**
  109576. * Creates lathe mesh.
  109577. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109578. * * 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
  109579. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109580. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109581. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109582. * * 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
  109583. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109584. * * 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
  109585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109587. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109589. * @param name defines the name of the mesh
  109590. * @param options defines the options used to create the mesh
  109591. * @param scene defines the hosting scene
  109592. * @returns the lathe mesh
  109593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109594. */
  109595. static CreateLathe(name: string, options: {
  109596. shape: Vector3[];
  109597. radius?: number;
  109598. tessellation?: number;
  109599. clip?: number;
  109600. arc?: number;
  109601. closed?: boolean;
  109602. updatable?: boolean;
  109603. sideOrientation?: number;
  109604. frontUVs?: Vector4;
  109605. backUVs?: Vector4;
  109606. cap?: number;
  109607. invertUV?: boolean;
  109608. }, scene?: Nullable<Scene>): Mesh;
  109609. }
  109610. }
  109611. declare module BABYLON {
  109612. /**
  109613. * Class containing static functions to help procedurally build meshes
  109614. */
  109615. export class TubeBuilder {
  109616. /**
  109617. * Creates a tube mesh.
  109618. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109619. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109620. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109621. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109622. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109623. * * 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)
  109624. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109625. * * 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
  109626. * * 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
  109627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109631. * @param name defines the name of the mesh
  109632. * @param options defines the options used to create the mesh
  109633. * @param scene defines the hosting scene
  109634. * @returns the tube mesh
  109635. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109636. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109637. */
  109638. static CreateTube(name: string, options: {
  109639. path: Vector3[];
  109640. radius?: number;
  109641. tessellation?: number;
  109642. radiusFunction?: {
  109643. (i: number, distance: number): number;
  109644. };
  109645. cap?: number;
  109646. arc?: number;
  109647. updatable?: boolean;
  109648. sideOrientation?: number;
  109649. frontUVs?: Vector4;
  109650. backUVs?: Vector4;
  109651. instance?: Mesh;
  109652. invertUV?: boolean;
  109653. }, scene?: Nullable<Scene>): Mesh;
  109654. }
  109655. }
  109656. declare module BABYLON {
  109657. /**
  109658. * Class containing static functions to help procedurally build meshes
  109659. */
  109660. export class IcoSphereBuilder {
  109661. /**
  109662. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109663. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109664. * * 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`)
  109665. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109666. * * 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
  109667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109670. * @param name defines the name of the mesh
  109671. * @param options defines the options used to create the mesh
  109672. * @param scene defines the hosting scene
  109673. * @returns the icosahedron mesh
  109674. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109675. */
  109676. static CreateIcoSphere(name: string, options: {
  109677. radius?: number;
  109678. radiusX?: number;
  109679. radiusY?: number;
  109680. radiusZ?: number;
  109681. flat?: boolean;
  109682. subdivisions?: number;
  109683. sideOrientation?: number;
  109684. frontUVs?: Vector4;
  109685. backUVs?: Vector4;
  109686. updatable?: boolean;
  109687. }, scene?: Nullable<Scene>): Mesh;
  109688. }
  109689. }
  109690. declare module BABYLON {
  109691. /**
  109692. * Class containing static functions to help procedurally build meshes
  109693. */
  109694. export class DecalBuilder {
  109695. /**
  109696. * Creates a decal mesh.
  109697. * 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
  109698. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109699. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109700. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109701. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109702. * @param name defines the name of the mesh
  109703. * @param sourceMesh defines the mesh where the decal must be applied
  109704. * @param options defines the options used to create the mesh
  109705. * @param scene defines the hosting scene
  109706. * @returns the decal mesh
  109707. * @see https://doc.babylonjs.com/how_to/decals
  109708. */
  109709. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109710. position?: Vector3;
  109711. normal?: Vector3;
  109712. size?: Vector3;
  109713. angle?: number;
  109714. }): Mesh;
  109715. }
  109716. }
  109717. declare module BABYLON {
  109718. /**
  109719. * Class containing static functions to help procedurally build meshes
  109720. */
  109721. export class MeshBuilder {
  109722. /**
  109723. * Creates a box mesh
  109724. * * The parameter `size` sets the size (float) of each box side (default 1)
  109725. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109726. * * 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)
  109727. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109731. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109732. * @param name defines the name of the mesh
  109733. * @param options defines the options used to create the mesh
  109734. * @param scene defines the hosting scene
  109735. * @returns the box mesh
  109736. */
  109737. static CreateBox(name: string, options: {
  109738. size?: number;
  109739. width?: number;
  109740. height?: number;
  109741. depth?: number;
  109742. faceUV?: Vector4[];
  109743. faceColors?: Color4[];
  109744. sideOrientation?: number;
  109745. frontUVs?: Vector4;
  109746. backUVs?: Vector4;
  109747. updatable?: boolean;
  109748. }, scene?: Nullable<Scene>): Mesh;
  109749. /**
  109750. * Creates a sphere mesh
  109751. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109752. * * 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`)
  109753. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109754. * * 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
  109755. * * 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)
  109756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109759. * @param name defines the name of the mesh
  109760. * @param options defines the options used to create the mesh
  109761. * @param scene defines the hosting scene
  109762. * @returns the sphere mesh
  109763. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109764. */
  109765. static CreateSphere(name: string, options: {
  109766. segments?: number;
  109767. diameter?: number;
  109768. diameterX?: number;
  109769. diameterY?: number;
  109770. diameterZ?: number;
  109771. arc?: number;
  109772. slice?: number;
  109773. sideOrientation?: number;
  109774. frontUVs?: Vector4;
  109775. backUVs?: Vector4;
  109776. updatable?: boolean;
  109777. }, scene?: Nullable<Scene>): Mesh;
  109778. /**
  109779. * Creates a plane polygonal mesh. By default, this is a disc
  109780. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109781. * * 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
  109782. * * 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
  109783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109786. * @param name defines the name of the mesh
  109787. * @param options defines the options used to create the mesh
  109788. * @param scene defines the hosting scene
  109789. * @returns the plane polygonal mesh
  109790. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109791. */
  109792. static CreateDisc(name: string, options: {
  109793. radius?: number;
  109794. tessellation?: number;
  109795. arc?: number;
  109796. updatable?: boolean;
  109797. sideOrientation?: number;
  109798. frontUVs?: Vector4;
  109799. backUVs?: Vector4;
  109800. }, scene?: Nullable<Scene>): Mesh;
  109801. /**
  109802. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109803. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109804. * * 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`)
  109805. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109806. * * 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
  109807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109808. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109810. * @param name defines the name of the mesh
  109811. * @param options defines the options used to create the mesh
  109812. * @param scene defines the hosting scene
  109813. * @returns the icosahedron mesh
  109814. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109815. */
  109816. static CreateIcoSphere(name: string, options: {
  109817. radius?: number;
  109818. radiusX?: number;
  109819. radiusY?: number;
  109820. radiusZ?: number;
  109821. flat?: boolean;
  109822. subdivisions?: number;
  109823. sideOrientation?: number;
  109824. frontUVs?: Vector4;
  109825. backUVs?: Vector4;
  109826. updatable?: boolean;
  109827. }, scene?: Nullable<Scene>): Mesh;
  109828. /**
  109829. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109830. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  109831. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  109832. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  109833. * * 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
  109834. * * 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
  109835. * * 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
  109836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109838. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109839. * * 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
  109840. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  109841. * * 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
  109842. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  109843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109844. * @param name defines the name of the mesh
  109845. * @param options defines the options used to create the mesh
  109846. * @param scene defines the hosting scene
  109847. * @returns the ribbon mesh
  109848. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  109849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109850. */
  109851. static CreateRibbon(name: string, options: {
  109852. pathArray: Vector3[][];
  109853. closeArray?: boolean;
  109854. closePath?: boolean;
  109855. offset?: number;
  109856. updatable?: boolean;
  109857. sideOrientation?: number;
  109858. frontUVs?: Vector4;
  109859. backUVs?: Vector4;
  109860. instance?: Mesh;
  109861. invertUV?: boolean;
  109862. uvs?: Vector2[];
  109863. colors?: Color4[];
  109864. }, scene?: Nullable<Scene>): Mesh;
  109865. /**
  109866. * Creates a cylinder or a cone mesh
  109867. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109868. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109869. * * 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.
  109870. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109871. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109872. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109873. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109874. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109875. * * 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).
  109876. * * 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
  109877. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109878. * * 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
  109879. * * 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.
  109880. * * If `enclose` is false, a ring surface is one element.
  109881. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109882. * * 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
  109883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109886. * @param name defines the name of the mesh
  109887. * @param options defines the options used to create the mesh
  109888. * @param scene defines the hosting scene
  109889. * @returns the cylinder mesh
  109890. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109891. */
  109892. static CreateCylinder(name: string, options: {
  109893. height?: number;
  109894. diameterTop?: number;
  109895. diameterBottom?: number;
  109896. diameter?: number;
  109897. tessellation?: number;
  109898. subdivisions?: number;
  109899. arc?: number;
  109900. faceColors?: Color4[];
  109901. faceUV?: Vector4[];
  109902. updatable?: boolean;
  109903. hasRings?: boolean;
  109904. enclose?: boolean;
  109905. sideOrientation?: number;
  109906. frontUVs?: Vector4;
  109907. backUVs?: Vector4;
  109908. }, scene?: Nullable<Scene>): Mesh;
  109909. /**
  109910. * Creates a torus mesh
  109911. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109912. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109913. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109917. * @param name defines the name of the mesh
  109918. * @param options defines the options used to create the mesh
  109919. * @param scene defines the hosting scene
  109920. * @returns the torus mesh
  109921. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109922. */
  109923. static CreateTorus(name: string, options: {
  109924. diameter?: number;
  109925. thickness?: number;
  109926. tessellation?: number;
  109927. updatable?: boolean;
  109928. sideOrientation?: number;
  109929. frontUVs?: Vector4;
  109930. backUVs?: Vector4;
  109931. }, scene?: Nullable<Scene>): Mesh;
  109932. /**
  109933. * Creates a torus knot mesh
  109934. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109935. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109936. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109937. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109941. * @param name defines the name of the mesh
  109942. * @param options defines the options used to create the mesh
  109943. * @param scene defines the hosting scene
  109944. * @returns the torus knot mesh
  109945. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109946. */
  109947. static CreateTorusKnot(name: string, options: {
  109948. radius?: number;
  109949. tube?: number;
  109950. radialSegments?: number;
  109951. tubularSegments?: number;
  109952. p?: number;
  109953. q?: number;
  109954. updatable?: boolean;
  109955. sideOrientation?: number;
  109956. frontUVs?: Vector4;
  109957. backUVs?: Vector4;
  109958. }, scene?: Nullable<Scene>): Mesh;
  109959. /**
  109960. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109961. * * 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
  109962. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109963. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109964. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109965. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109966. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109967. * * 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
  109968. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109970. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109971. * @param name defines the name of the new line system
  109972. * @param options defines the options used to create the line system
  109973. * @param scene defines the hosting scene
  109974. * @returns a new line system mesh
  109975. */
  109976. static CreateLineSystem(name: string, options: {
  109977. lines: Vector3[][];
  109978. updatable?: boolean;
  109979. instance?: Nullable<LinesMesh>;
  109980. colors?: Nullable<Color4[][]>;
  109981. useVertexAlpha?: boolean;
  109982. }, scene: Nullable<Scene>): LinesMesh;
  109983. /**
  109984. * Creates a line mesh
  109985. * 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
  109986. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109987. * * The parameter `points` is an array successive Vector3
  109988. * * 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
  109989. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109990. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109991. * * When updating an instance, remember that only point positions can change, not the number of points
  109992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109993. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109994. * @param name defines the name of the new line system
  109995. * @param options defines the options used to create the line system
  109996. * @param scene defines the hosting scene
  109997. * @returns a new line mesh
  109998. */
  109999. static CreateLines(name: string, options: {
  110000. points: Vector3[];
  110001. updatable?: boolean;
  110002. instance?: Nullable<LinesMesh>;
  110003. colors?: Color4[];
  110004. useVertexAlpha?: boolean;
  110005. }, scene?: Nullable<Scene>): LinesMesh;
  110006. /**
  110007. * Creates a dashed line mesh
  110008. * * 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
  110009. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110010. * * The parameter `points` is an array successive Vector3
  110011. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110012. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110013. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110014. * * 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
  110015. * * When updating an instance, remember that only point positions can change, not the number of points
  110016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110017. * @param name defines the name of the mesh
  110018. * @param options defines the options used to create the mesh
  110019. * @param scene defines the hosting scene
  110020. * @returns the dashed line mesh
  110021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110022. */
  110023. static CreateDashedLines(name: string, options: {
  110024. points: Vector3[];
  110025. dashSize?: number;
  110026. gapSize?: number;
  110027. dashNb?: number;
  110028. updatable?: boolean;
  110029. instance?: LinesMesh;
  110030. }, scene?: Nullable<Scene>): LinesMesh;
  110031. /**
  110032. * 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.
  110033. * * 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.
  110034. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110035. * * 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.
  110036. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110037. * * 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
  110038. * * 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
  110039. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110042. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110044. * @param name defines the name of the mesh
  110045. * @param options defines the options used to create the mesh
  110046. * @param scene defines the hosting scene
  110047. * @returns the extruded shape mesh
  110048. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110049. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110050. */
  110051. static ExtrudeShape(name: string, options: {
  110052. shape: Vector3[];
  110053. path: Vector3[];
  110054. scale?: number;
  110055. rotation?: number;
  110056. cap?: number;
  110057. updatable?: boolean;
  110058. sideOrientation?: number;
  110059. frontUVs?: Vector4;
  110060. backUVs?: Vector4;
  110061. instance?: Mesh;
  110062. invertUV?: boolean;
  110063. }, scene?: Nullable<Scene>): Mesh;
  110064. /**
  110065. * Creates an custom extruded shape mesh.
  110066. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110067. * * 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.
  110068. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110069. * * 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
  110070. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110071. * * 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
  110072. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110073. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110074. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110075. * * 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
  110076. * * 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
  110077. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110082. * @param name defines the name of the mesh
  110083. * @param options defines the options used to create the mesh
  110084. * @param scene defines the hosting scene
  110085. * @returns the custom extruded shape mesh
  110086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110087. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110088. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110089. */
  110090. static ExtrudeShapeCustom(name: string, options: {
  110091. shape: Vector3[];
  110092. path: Vector3[];
  110093. scaleFunction?: any;
  110094. rotationFunction?: any;
  110095. ribbonCloseArray?: boolean;
  110096. ribbonClosePath?: boolean;
  110097. cap?: number;
  110098. updatable?: boolean;
  110099. sideOrientation?: number;
  110100. frontUVs?: Vector4;
  110101. backUVs?: Vector4;
  110102. instance?: Mesh;
  110103. invertUV?: boolean;
  110104. }, scene?: Nullable<Scene>): Mesh;
  110105. /**
  110106. * Creates lathe mesh.
  110107. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110108. * * 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
  110109. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110110. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110111. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110112. * * 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
  110113. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110114. * * 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
  110115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110117. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110119. * @param name defines the name of the mesh
  110120. * @param options defines the options used to create the mesh
  110121. * @param scene defines the hosting scene
  110122. * @returns the lathe mesh
  110123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110124. */
  110125. static CreateLathe(name: string, options: {
  110126. shape: Vector3[];
  110127. radius?: number;
  110128. tessellation?: number;
  110129. clip?: number;
  110130. arc?: number;
  110131. closed?: boolean;
  110132. updatable?: boolean;
  110133. sideOrientation?: number;
  110134. frontUVs?: Vector4;
  110135. backUVs?: Vector4;
  110136. cap?: number;
  110137. invertUV?: boolean;
  110138. }, scene?: Nullable<Scene>): Mesh;
  110139. /**
  110140. * Creates a plane mesh
  110141. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110142. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110143. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110147. * @param name defines the name of the mesh
  110148. * @param options defines the options used to create the mesh
  110149. * @param scene defines the hosting scene
  110150. * @returns the plane mesh
  110151. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110152. */
  110153. static CreatePlane(name: string, options: {
  110154. size?: number;
  110155. width?: number;
  110156. height?: number;
  110157. sideOrientation?: number;
  110158. frontUVs?: Vector4;
  110159. backUVs?: Vector4;
  110160. updatable?: boolean;
  110161. sourcePlane?: Plane;
  110162. }, scene?: Nullable<Scene>): Mesh;
  110163. /**
  110164. * Creates a ground mesh
  110165. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110166. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 ground mesh
  110172. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110173. */
  110174. static CreateGround(name: string, options: {
  110175. width?: number;
  110176. height?: number;
  110177. subdivisions?: number;
  110178. subdivisionsX?: number;
  110179. subdivisionsY?: number;
  110180. updatable?: boolean;
  110181. }, scene?: Nullable<Scene>): Mesh;
  110182. /**
  110183. * Creates a tiled ground mesh
  110184. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110185. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110186. * * 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
  110187. * * 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
  110188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110189. * @param name defines the name of the mesh
  110190. * @param options defines the options used to create the mesh
  110191. * @param scene defines the hosting scene
  110192. * @returns the tiled ground mesh
  110193. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110194. */
  110195. static CreateTiledGround(name: string, options: {
  110196. xmin: number;
  110197. zmin: number;
  110198. xmax: number;
  110199. zmax: number;
  110200. subdivisions?: {
  110201. w: number;
  110202. h: number;
  110203. };
  110204. precision?: {
  110205. w: number;
  110206. h: number;
  110207. };
  110208. updatable?: boolean;
  110209. }, scene?: Nullable<Scene>): Mesh;
  110210. /**
  110211. * Creates a ground mesh from a height map
  110212. * * The parameter `url` sets the URL of the height map image resource.
  110213. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110214. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110215. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110216. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110217. * * 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.
  110218. * * 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).
  110219. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110221. * @param name defines the name of the mesh
  110222. * @param url defines the url to the height map
  110223. * @param options defines the options used to create the mesh
  110224. * @param scene defines the hosting scene
  110225. * @returns the ground mesh
  110226. * @see https://doc.babylonjs.com/babylon101/height_map
  110227. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110228. */
  110229. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110230. width?: number;
  110231. height?: number;
  110232. subdivisions?: number;
  110233. minHeight?: number;
  110234. maxHeight?: number;
  110235. colorFilter?: Color3;
  110236. alphaFilter?: number;
  110237. updatable?: boolean;
  110238. onReady?: (mesh: GroundMesh) => void;
  110239. }, scene?: Nullable<Scene>): GroundMesh;
  110240. /**
  110241. * Creates a polygon mesh
  110242. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110243. * * 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
  110244. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110247. * * Remember you can only change the shape positions, not their number when updating a polygon
  110248. * @param name defines the name of the mesh
  110249. * @param options defines the options used to create the mesh
  110250. * @param scene defines the hosting scene
  110251. * @param earcutInjection can be used to inject your own earcut reference
  110252. * @returns the polygon mesh
  110253. */
  110254. static CreatePolygon(name: string, options: {
  110255. shape: Vector3[];
  110256. holes?: Vector3[][];
  110257. depth?: number;
  110258. faceUV?: Vector4[];
  110259. faceColors?: Color4[];
  110260. updatable?: boolean;
  110261. sideOrientation?: number;
  110262. frontUVs?: Vector4;
  110263. backUVs?: Vector4;
  110264. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110265. /**
  110266. * Creates an extruded polygon mesh, with depth in the Y direction.
  110267. * * 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)
  110268. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110269. * @param name defines the name of the mesh
  110270. * @param options defines the options used to create the mesh
  110271. * @param scene defines the hosting scene
  110272. * @param earcutInjection can be used to inject your own earcut reference
  110273. * @returns the polygon mesh
  110274. */
  110275. static ExtrudePolygon(name: string, options: {
  110276. shape: Vector3[];
  110277. holes?: Vector3[][];
  110278. depth?: number;
  110279. faceUV?: Vector4[];
  110280. faceColors?: Color4[];
  110281. updatable?: boolean;
  110282. sideOrientation?: number;
  110283. frontUVs?: Vector4;
  110284. backUVs?: Vector4;
  110285. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110286. /**
  110287. * Creates a tube mesh.
  110288. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110289. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110290. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110291. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110292. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110293. * * 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)
  110294. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110295. * * 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
  110296. * * 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
  110297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110299. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110301. * @param name defines the name of the mesh
  110302. * @param options defines the options used to create the mesh
  110303. * @param scene defines the hosting scene
  110304. * @returns the tube mesh
  110305. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110306. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110307. */
  110308. static CreateTube(name: string, options: {
  110309. path: Vector3[];
  110310. radius?: number;
  110311. tessellation?: number;
  110312. radiusFunction?: {
  110313. (i: number, distance: number): number;
  110314. };
  110315. cap?: number;
  110316. arc?: number;
  110317. updatable?: boolean;
  110318. sideOrientation?: number;
  110319. frontUVs?: Vector4;
  110320. backUVs?: Vector4;
  110321. instance?: Mesh;
  110322. invertUV?: boolean;
  110323. }, scene?: Nullable<Scene>): Mesh;
  110324. /**
  110325. * Creates a polyhedron mesh
  110326. * * 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
  110327. * * The parameter `size` (positive float, default 1) sets the polygon size
  110328. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110329. * * 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`
  110330. * * 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
  110331. * * 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)`)
  110332. * * 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
  110333. * * 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
  110334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110337. * @param name defines the name of the mesh
  110338. * @param options defines the options used to create the mesh
  110339. * @param scene defines the hosting scene
  110340. * @returns the polyhedron mesh
  110341. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110342. */
  110343. static CreatePolyhedron(name: string, options: {
  110344. type?: number;
  110345. size?: number;
  110346. sizeX?: number;
  110347. sizeY?: number;
  110348. sizeZ?: number;
  110349. custom?: any;
  110350. faceUV?: Vector4[];
  110351. faceColors?: Color4[];
  110352. flat?: boolean;
  110353. updatable?: boolean;
  110354. sideOrientation?: number;
  110355. frontUVs?: Vector4;
  110356. backUVs?: Vector4;
  110357. }, scene?: Nullable<Scene>): Mesh;
  110358. /**
  110359. * Creates a decal mesh.
  110360. * 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
  110361. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110362. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110363. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110364. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110365. * @param name defines the name of the mesh
  110366. * @param sourceMesh defines the mesh where the decal must be applied
  110367. * @param options defines the options used to create the mesh
  110368. * @param scene defines the hosting scene
  110369. * @returns the decal mesh
  110370. * @see https://doc.babylonjs.com/how_to/decals
  110371. */
  110372. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110373. position?: Vector3;
  110374. normal?: Vector3;
  110375. size?: Vector3;
  110376. angle?: number;
  110377. }): Mesh;
  110378. }
  110379. }
  110380. declare module BABYLON {
  110381. /**
  110382. * A simplifier interface for future simplification implementations
  110383. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110384. */
  110385. export interface ISimplifier {
  110386. /**
  110387. * Simplification of a given mesh according to the given settings.
  110388. * Since this requires computation, it is assumed that the function runs async.
  110389. * @param settings The settings of the simplification, including quality and distance
  110390. * @param successCallback A callback that will be called after the mesh was simplified.
  110391. * @param errorCallback in case of an error, this callback will be called. optional.
  110392. */
  110393. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110394. }
  110395. /**
  110396. * Expected simplification settings.
  110397. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110398. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110399. */
  110400. export interface ISimplificationSettings {
  110401. /**
  110402. * Gets or sets the expected quality
  110403. */
  110404. quality: number;
  110405. /**
  110406. * Gets or sets the distance when this optimized version should be used
  110407. */
  110408. distance: number;
  110409. /**
  110410. * Gets an already optimized mesh
  110411. */
  110412. optimizeMesh?: boolean;
  110413. }
  110414. /**
  110415. * Class used to specify simplification options
  110416. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110417. */
  110418. export class SimplificationSettings implements ISimplificationSettings {
  110419. /** expected quality */
  110420. quality: number;
  110421. /** distance when this optimized version should be used */
  110422. distance: number;
  110423. /** already optimized mesh */
  110424. optimizeMesh?: boolean | undefined;
  110425. /**
  110426. * Creates a SimplificationSettings
  110427. * @param quality expected quality
  110428. * @param distance distance when this optimized version should be used
  110429. * @param optimizeMesh already optimized mesh
  110430. */
  110431. constructor(
  110432. /** expected quality */
  110433. quality: number,
  110434. /** distance when this optimized version should be used */
  110435. distance: number,
  110436. /** already optimized mesh */
  110437. optimizeMesh?: boolean | undefined);
  110438. }
  110439. /**
  110440. * Interface used to define a simplification task
  110441. */
  110442. export interface ISimplificationTask {
  110443. /**
  110444. * Array of settings
  110445. */
  110446. settings: Array<ISimplificationSettings>;
  110447. /**
  110448. * Simplification type
  110449. */
  110450. simplificationType: SimplificationType;
  110451. /**
  110452. * Mesh to simplify
  110453. */
  110454. mesh: Mesh;
  110455. /**
  110456. * Callback called on success
  110457. */
  110458. successCallback?: () => void;
  110459. /**
  110460. * Defines if parallel processing can be used
  110461. */
  110462. parallelProcessing: boolean;
  110463. }
  110464. /**
  110465. * Queue used to order the simplification tasks
  110466. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110467. */
  110468. export class SimplificationQueue {
  110469. private _simplificationArray;
  110470. /**
  110471. * Gets a boolean indicating that the process is still running
  110472. */
  110473. running: boolean;
  110474. /**
  110475. * Creates a new queue
  110476. */
  110477. constructor();
  110478. /**
  110479. * Adds a new simplification task
  110480. * @param task defines a task to add
  110481. */
  110482. addTask(task: ISimplificationTask): void;
  110483. /**
  110484. * Execute next task
  110485. */
  110486. executeNext(): void;
  110487. /**
  110488. * Execute a simplification task
  110489. * @param task defines the task to run
  110490. */
  110491. runSimplification(task: ISimplificationTask): void;
  110492. private getSimplifier;
  110493. }
  110494. /**
  110495. * The implemented types of simplification
  110496. * At the moment only Quadratic Error Decimation is implemented
  110497. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110498. */
  110499. export enum SimplificationType {
  110500. /** Quadratic error decimation */
  110501. QUADRATIC = 0
  110502. }
  110503. }
  110504. declare module BABYLON {
  110505. interface Scene {
  110506. /** @hidden (Backing field) */
  110507. _simplificationQueue: SimplificationQueue;
  110508. /**
  110509. * Gets or sets the simplification queue attached to the scene
  110510. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110511. */
  110512. simplificationQueue: SimplificationQueue;
  110513. }
  110514. interface Mesh {
  110515. /**
  110516. * Simplify the mesh according to the given array of settings.
  110517. * Function will return immediately and will simplify async
  110518. * @param settings a collection of simplification settings
  110519. * @param parallelProcessing should all levels calculate parallel or one after the other
  110520. * @param simplificationType the type of simplification to run
  110521. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  110522. * @returns the current mesh
  110523. */
  110524. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  110525. }
  110526. /**
  110527. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  110528. * created in a scene
  110529. */
  110530. export class SimplicationQueueSceneComponent implements ISceneComponent {
  110531. /**
  110532. * The component name helpfull to identify the component in the list of scene components.
  110533. */
  110534. readonly name: string;
  110535. /**
  110536. * The scene the component belongs to.
  110537. */
  110538. scene: Scene;
  110539. /**
  110540. * Creates a new instance of the component for the given scene
  110541. * @param scene Defines the scene to register the component in
  110542. */
  110543. constructor(scene: Scene);
  110544. /**
  110545. * Registers the component in a given scene
  110546. */
  110547. register(): void;
  110548. /**
  110549. * Rebuilds the elements related to this component in case of
  110550. * context lost for instance.
  110551. */
  110552. rebuild(): void;
  110553. /**
  110554. * Disposes the component and the associated ressources
  110555. */
  110556. dispose(): void;
  110557. private _beforeCameraUpdate;
  110558. }
  110559. }
  110560. declare module BABYLON {
  110561. /**
  110562. * Class used to enable access to IndexedDB
  110563. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110564. */
  110565. export class Database implements IOfflineProvider {
  110566. private _callbackManifestChecked;
  110567. private _currentSceneUrl;
  110568. private _db;
  110569. private _enableSceneOffline;
  110570. private _enableTexturesOffline;
  110571. private _manifestVersionFound;
  110572. private _mustUpdateRessources;
  110573. private _hasReachedQuota;
  110574. private _isSupported;
  110575. private _idbFactory;
  110576. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  110577. private static IsUASupportingBlobStorage;
  110578. /**
  110579. * Gets a boolean indicating if Database storate is enabled (off by default)
  110580. */
  110581. static IDBStorageEnabled: boolean;
  110582. /**
  110583. * Gets a boolean indicating if scene must be saved in the database
  110584. */
  110585. readonly enableSceneOffline: boolean;
  110586. /**
  110587. * Gets a boolean indicating if textures must be saved in the database
  110588. */
  110589. readonly enableTexturesOffline: boolean;
  110590. /**
  110591. * Creates a new Database
  110592. * @param urlToScene defines the url to load the scene
  110593. * @param callbackManifestChecked defines the callback to use when manifest is checked
  110594. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  110595. */
  110596. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  110597. private static _ParseURL;
  110598. private static _ReturnFullUrlLocation;
  110599. private _checkManifestFile;
  110600. /**
  110601. * Open the database and make it available
  110602. * @param successCallback defines the callback to call on success
  110603. * @param errorCallback defines the callback to call on error
  110604. */
  110605. open(successCallback: () => void, errorCallback: () => void): void;
  110606. /**
  110607. * Loads an image from the database
  110608. * @param url defines the url to load from
  110609. * @param image defines the target DOM image
  110610. */
  110611. loadImage(url: string, image: HTMLImageElement): void;
  110612. private _loadImageFromDBAsync;
  110613. private _saveImageIntoDBAsync;
  110614. private _checkVersionFromDB;
  110615. private _loadVersionFromDBAsync;
  110616. private _saveVersionIntoDBAsync;
  110617. /**
  110618. * Loads a file from database
  110619. * @param url defines the URL to load from
  110620. * @param sceneLoaded defines a callback to call on success
  110621. * @param progressCallBack defines a callback to call when progress changed
  110622. * @param errorCallback defines a callback to call on error
  110623. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  110624. */
  110625. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  110626. private _loadFileAsync;
  110627. private _saveFileAsync;
  110628. /**
  110629. * Validates if xhr data is correct
  110630. * @param xhr defines the request to validate
  110631. * @param dataType defines the expected data type
  110632. * @returns true if data is correct
  110633. */
  110634. private static _ValidateXHRData;
  110635. }
  110636. }
  110637. declare module BABYLON {
  110638. /** @hidden */
  110639. export var gpuUpdateParticlesPixelShader: {
  110640. name: string;
  110641. shader: string;
  110642. };
  110643. }
  110644. declare module BABYLON {
  110645. /** @hidden */
  110646. export var gpuUpdateParticlesVertexShader: {
  110647. name: string;
  110648. shader: string;
  110649. };
  110650. }
  110651. declare module BABYLON {
  110652. /** @hidden */
  110653. export var clipPlaneFragmentDeclaration2: {
  110654. name: string;
  110655. shader: string;
  110656. };
  110657. }
  110658. declare module BABYLON {
  110659. /** @hidden */
  110660. export var gpuRenderParticlesPixelShader: {
  110661. name: string;
  110662. shader: string;
  110663. };
  110664. }
  110665. declare module BABYLON {
  110666. /** @hidden */
  110667. export var clipPlaneVertexDeclaration2: {
  110668. name: string;
  110669. shader: string;
  110670. };
  110671. }
  110672. declare module BABYLON {
  110673. /** @hidden */
  110674. export var gpuRenderParticlesVertexShader: {
  110675. name: string;
  110676. shader: string;
  110677. };
  110678. }
  110679. declare module BABYLON {
  110680. /**
  110681. * This represents a GPU particle system in Babylon
  110682. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  110683. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  110684. */
  110685. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  110686. /**
  110687. * The layer mask we are rendering the particles through.
  110688. */
  110689. layerMask: number;
  110690. private _capacity;
  110691. private _activeCount;
  110692. private _currentActiveCount;
  110693. private _accumulatedCount;
  110694. private _renderEffect;
  110695. private _updateEffect;
  110696. private _buffer0;
  110697. private _buffer1;
  110698. private _spriteBuffer;
  110699. private _updateVAO;
  110700. private _renderVAO;
  110701. private _targetIndex;
  110702. private _sourceBuffer;
  110703. private _targetBuffer;
  110704. private _engine;
  110705. private _currentRenderId;
  110706. private _started;
  110707. private _stopped;
  110708. private _timeDelta;
  110709. private _randomTexture;
  110710. private _randomTexture2;
  110711. private _attributesStrideSize;
  110712. private _updateEffectOptions;
  110713. private _randomTextureSize;
  110714. private _actualFrame;
  110715. private readonly _rawTextureWidth;
  110716. /**
  110717. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  110718. */
  110719. static readonly IsSupported: boolean;
  110720. /**
  110721. * An event triggered when the system is disposed.
  110722. */
  110723. onDisposeObservable: Observable<GPUParticleSystem>;
  110724. /**
  110725. * Gets the maximum number of particles active at the same time.
  110726. * @returns The max number of active particles.
  110727. */
  110728. getCapacity(): number;
  110729. /**
  110730. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  110731. * to override the particles.
  110732. */
  110733. forceDepthWrite: boolean;
  110734. /**
  110735. * Gets or set the number of active particles
  110736. */
  110737. activeParticleCount: number;
  110738. private _preWarmDone;
  110739. /**
  110740. * Is this system ready to be used/rendered
  110741. * @return true if the system is ready
  110742. */
  110743. isReady(): boolean;
  110744. /**
  110745. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110746. * @returns True if it has been started, otherwise false.
  110747. */
  110748. isStarted(): boolean;
  110749. /**
  110750. * Starts the particle system and begins to emit
  110751. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110752. */
  110753. start(delay?: number): void;
  110754. /**
  110755. * Stops the particle system.
  110756. */
  110757. stop(): void;
  110758. /**
  110759. * Remove all active particles
  110760. */
  110761. reset(): void;
  110762. /**
  110763. * Returns the string "GPUParticleSystem"
  110764. * @returns a string containing the class name
  110765. */
  110766. getClassName(): string;
  110767. private _colorGradientsTexture;
  110768. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  110769. /**
  110770. * Adds a new color gradient
  110771. * @param gradient defines the gradient to use (between 0 and 1)
  110772. * @param color1 defines the color to affect to the specified gradient
  110773. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110774. * @returns the current particle system
  110775. */
  110776. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  110777. /**
  110778. * Remove a specific color gradient
  110779. * @param gradient defines the gradient to remove
  110780. * @returns the current particle system
  110781. */
  110782. removeColorGradient(gradient: number): GPUParticleSystem;
  110783. private _angularSpeedGradientsTexture;
  110784. private _sizeGradientsTexture;
  110785. private _velocityGradientsTexture;
  110786. private _limitVelocityGradientsTexture;
  110787. private _dragGradientsTexture;
  110788. private _addFactorGradient;
  110789. /**
  110790. * Adds a new size gradient
  110791. * @param gradient defines the gradient to use (between 0 and 1)
  110792. * @param factor defines the size factor to affect to the specified gradient
  110793. * @returns the current particle system
  110794. */
  110795. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  110796. /**
  110797. * Remove a specific size gradient
  110798. * @param gradient defines the gradient to remove
  110799. * @returns the current particle system
  110800. */
  110801. removeSizeGradient(gradient: number): GPUParticleSystem;
  110802. /**
  110803. * Adds a new angular speed gradient
  110804. * @param gradient defines the gradient to use (between 0 and 1)
  110805. * @param factor defines the angular speed to affect to the specified gradient
  110806. * @returns the current particle system
  110807. */
  110808. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  110809. /**
  110810. * Remove a specific angular speed gradient
  110811. * @param gradient defines the gradient to remove
  110812. * @returns the current particle system
  110813. */
  110814. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  110815. /**
  110816. * Adds a new velocity gradient
  110817. * @param gradient defines the gradient to use (between 0 and 1)
  110818. * @param factor defines the velocity to affect to the specified gradient
  110819. * @returns the current particle system
  110820. */
  110821. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110822. /**
  110823. * Remove a specific velocity gradient
  110824. * @param gradient defines the gradient to remove
  110825. * @returns the current particle system
  110826. */
  110827. removeVelocityGradient(gradient: number): GPUParticleSystem;
  110828. /**
  110829. * Adds a new limit velocity gradient
  110830. * @param gradient defines the gradient to use (between 0 and 1)
  110831. * @param factor defines the limit velocity value to affect to the specified gradient
  110832. * @returns the current particle system
  110833. */
  110834. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110835. /**
  110836. * Remove a specific limit velocity gradient
  110837. * @param gradient defines the gradient to remove
  110838. * @returns the current particle system
  110839. */
  110840. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  110841. /**
  110842. * Adds a new drag gradient
  110843. * @param gradient defines the gradient to use (between 0 and 1)
  110844. * @param factor defines the drag value to affect to the specified gradient
  110845. * @returns the current particle system
  110846. */
  110847. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  110848. /**
  110849. * Remove a specific drag gradient
  110850. * @param gradient defines the gradient to remove
  110851. * @returns the current particle system
  110852. */
  110853. removeDragGradient(gradient: number): GPUParticleSystem;
  110854. /**
  110855. * Not supported by GPUParticleSystem
  110856. * @param gradient defines the gradient to use (between 0 and 1)
  110857. * @param factor defines the emit rate value to affect to the specified gradient
  110858. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110859. * @returns the current particle system
  110860. */
  110861. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110862. /**
  110863. * Not supported by GPUParticleSystem
  110864. * @param gradient defines the gradient to remove
  110865. * @returns the current particle system
  110866. */
  110867. removeEmitRateGradient(gradient: number): IParticleSystem;
  110868. /**
  110869. * Not supported by GPUParticleSystem
  110870. * @param gradient defines the gradient to use (between 0 and 1)
  110871. * @param factor defines the start size value to affect to the specified gradient
  110872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110873. * @returns the current particle system
  110874. */
  110875. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110876. /**
  110877. * Not supported by GPUParticleSystem
  110878. * @param gradient defines the gradient to remove
  110879. * @returns the current particle system
  110880. */
  110881. removeStartSizeGradient(gradient: number): IParticleSystem;
  110882. /**
  110883. * Not supported by GPUParticleSystem
  110884. * @param gradient defines the gradient to use (between 0 and 1)
  110885. * @param min defines the color remap minimal range
  110886. * @param max defines the color remap maximal range
  110887. * @returns the current particle system
  110888. */
  110889. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110890. /**
  110891. * Not supported by GPUParticleSystem
  110892. * @param gradient defines the gradient to remove
  110893. * @returns the current particle system
  110894. */
  110895. removeColorRemapGradient(): IParticleSystem;
  110896. /**
  110897. * Not supported by GPUParticleSystem
  110898. * @param gradient defines the gradient to use (between 0 and 1)
  110899. * @param min defines the alpha remap minimal range
  110900. * @param max defines the alpha remap maximal range
  110901. * @returns the current particle system
  110902. */
  110903. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110904. /**
  110905. * Not supported by GPUParticleSystem
  110906. * @param gradient defines the gradient to remove
  110907. * @returns the current particle system
  110908. */
  110909. removeAlphaRemapGradient(): IParticleSystem;
  110910. /**
  110911. * Not supported by GPUParticleSystem
  110912. * @param gradient defines the gradient to use (between 0 and 1)
  110913. * @param color defines the color to affect to the specified gradient
  110914. * @returns the current particle system
  110915. */
  110916. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  110917. /**
  110918. * Not supported by GPUParticleSystem
  110919. * @param gradient defines the gradient to remove
  110920. * @returns the current particle system
  110921. */
  110922. removeRampGradient(): IParticleSystem;
  110923. /**
  110924. * Not supported by GPUParticleSystem
  110925. * @returns the list of ramp gradients
  110926. */
  110927. getRampGradients(): Nullable<Array<Color3Gradient>>;
  110928. /**
  110929. * Not supported by GPUParticleSystem
  110930. * Gets or sets a boolean indicating that ramp gradients must be used
  110931. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110932. */
  110933. useRampGradients: boolean;
  110934. /**
  110935. * Not supported by GPUParticleSystem
  110936. * @param gradient defines the gradient to use (between 0 and 1)
  110937. * @param factor defines the life time factor to affect to the specified gradient
  110938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110939. * @returns the current particle system
  110940. */
  110941. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110942. /**
  110943. * Not supported by GPUParticleSystem
  110944. * @param gradient defines the gradient to remove
  110945. * @returns the current particle system
  110946. */
  110947. removeLifeTimeGradient(gradient: number): IParticleSystem;
  110948. /**
  110949. * Instantiates a GPU particle system.
  110950. * 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.
  110951. * @param name The name of the particle system
  110952. * @param options The options used to create the system
  110953. * @param scene The scene the particle system belongs to
  110954. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  110955. */
  110956. constructor(name: string, options: Partial<{
  110957. capacity: number;
  110958. randomTextureSize: number;
  110959. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  110960. protected _reset(): void;
  110961. private _createUpdateVAO;
  110962. private _createRenderVAO;
  110963. private _initialize;
  110964. /** @hidden */
  110965. _recreateUpdateEffect(): void;
  110966. /** @hidden */
  110967. _recreateRenderEffect(): void;
  110968. /**
  110969. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  110970. * @param preWarm defines if we are in the pre-warmimg phase
  110971. */
  110972. animate(preWarm?: boolean): void;
  110973. private _createFactorGradientTexture;
  110974. private _createSizeGradientTexture;
  110975. private _createAngularSpeedGradientTexture;
  110976. private _createVelocityGradientTexture;
  110977. private _createLimitVelocityGradientTexture;
  110978. private _createDragGradientTexture;
  110979. private _createColorGradientTexture;
  110980. /**
  110981. * Renders the particle system in its current state
  110982. * @param preWarm defines if the system should only update the particles but not render them
  110983. * @returns the current number of particles
  110984. */
  110985. render(preWarm?: boolean): number;
  110986. /**
  110987. * Rebuilds the particle system
  110988. */
  110989. rebuild(): void;
  110990. private _releaseBuffers;
  110991. private _releaseVAOs;
  110992. /**
  110993. * Disposes the particle system and free the associated resources
  110994. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  110995. */
  110996. dispose(disposeTexture?: boolean): void;
  110997. /**
  110998. * Clones the particle system.
  110999. * @param name The name of the cloned object
  111000. * @param newEmitter The new emitter to use
  111001. * @returns the cloned particle system
  111002. */
  111003. clone(name: string, newEmitter: any): GPUParticleSystem;
  111004. /**
  111005. * Serializes the particle system to a JSON object.
  111006. * @returns the JSON object
  111007. */
  111008. serialize(): any;
  111009. /**
  111010. * Parses a JSON object to create a GPU particle system.
  111011. * @param parsedParticleSystem The JSON object to parse
  111012. * @param scene The scene to create the particle system in
  111013. * @param rootUrl The root url to use to load external dependencies like texture
  111014. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111015. * @returns the parsed GPU particle system
  111016. */
  111017. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111018. }
  111019. }
  111020. declare module BABYLON {
  111021. /**
  111022. * Represents a set of particle systems working together to create a specific effect
  111023. */
  111024. export class ParticleSystemSet implements IDisposable {
  111025. private _emitterCreationOptions;
  111026. private _emitterNode;
  111027. /**
  111028. * Gets the particle system list
  111029. */
  111030. systems: IParticleSystem[];
  111031. /**
  111032. * Gets the emitter node used with this set
  111033. */
  111034. readonly emitterNode: Nullable<TransformNode>;
  111035. /**
  111036. * Creates a new emitter mesh as a sphere
  111037. * @param options defines the options used to create the sphere
  111038. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111039. * @param scene defines the hosting scene
  111040. */
  111041. setEmitterAsSphere(options: {
  111042. diameter: number;
  111043. segments: number;
  111044. color: Color3;
  111045. }, renderingGroupId: number, scene: Scene): void;
  111046. /**
  111047. * Starts all particle systems of the set
  111048. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111049. */
  111050. start(emitter?: AbstractMesh): void;
  111051. /**
  111052. * Release all associated resources
  111053. */
  111054. dispose(): void;
  111055. /**
  111056. * Serialize the set into a JSON compatible object
  111057. * @returns a JSON compatible representation of the set
  111058. */
  111059. serialize(): any;
  111060. /**
  111061. * Parse a new ParticleSystemSet from a serialized source
  111062. * @param data defines a JSON compatible representation of the set
  111063. * @param scene defines the hosting scene
  111064. * @param gpu defines if we want GPU particles or CPU particles
  111065. * @returns a new ParticleSystemSet
  111066. */
  111067. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111068. }
  111069. }
  111070. declare module BABYLON {
  111071. /**
  111072. * This class is made for on one-liner static method to help creating particle system set.
  111073. */
  111074. export class ParticleHelper {
  111075. /**
  111076. * Gets or sets base Assets URL
  111077. */
  111078. static BaseAssetsUrl: string;
  111079. /**
  111080. * Create a default particle system that you can tweak
  111081. * @param emitter defines the emitter to use
  111082. * @param capacity defines the system capacity (default is 500 particles)
  111083. * @param scene defines the hosting scene
  111084. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111085. * @returns the new Particle system
  111086. */
  111087. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111088. /**
  111089. * This is the main static method (one-liner) of this helper to create different particle systems
  111090. * @param type This string represents the type to the particle system to create
  111091. * @param scene The scene where the particle system should live
  111092. * @param gpu If the system will use gpu
  111093. * @returns the ParticleSystemSet created
  111094. */
  111095. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111096. /**
  111097. * Static function used to export a particle system to a ParticleSystemSet variable.
  111098. * Please note that the emitter shape is not exported
  111099. * @param systems defines the particle systems to export
  111100. * @returns the created particle system set
  111101. */
  111102. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111103. }
  111104. }
  111105. declare module BABYLON {
  111106. interface Engine {
  111107. /**
  111108. * Create an effect to use with particle systems.
  111109. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111110. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111111. * @param uniformsNames defines a list of attribute names
  111112. * @param samplers defines an array of string used to represent textures
  111113. * @param defines defines the string containing the defines to use to compile the shaders
  111114. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111115. * @param onCompiled defines a function to call when the effect creation is successful
  111116. * @param onError defines a function to call when the effect creation has failed
  111117. * @returns the new Effect
  111118. */
  111119. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111120. }
  111121. interface Mesh {
  111122. /**
  111123. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111124. * @returns an array of IParticleSystem
  111125. */
  111126. getEmittedParticleSystems(): IParticleSystem[];
  111127. /**
  111128. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111129. * @returns an array of IParticleSystem
  111130. */
  111131. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111132. }
  111133. /**
  111134. * @hidden
  111135. */
  111136. export var _IDoNeedToBeInTheBuild: number;
  111137. }
  111138. declare module BABYLON {
  111139. interface Scene {
  111140. /** @hidden (Backing field) */
  111141. _physicsEngine: Nullable<IPhysicsEngine>;
  111142. /**
  111143. * Gets the current physics engine
  111144. * @returns a IPhysicsEngine or null if none attached
  111145. */
  111146. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111147. /**
  111148. * Enables physics to the current scene
  111149. * @param gravity defines the scene's gravity for the physics engine
  111150. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111151. * @return a boolean indicating if the physics engine was initialized
  111152. */
  111153. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111154. /**
  111155. * Disables and disposes the physics engine associated with the scene
  111156. */
  111157. disablePhysicsEngine(): void;
  111158. /**
  111159. * Gets a boolean indicating if there is an active physics engine
  111160. * @returns a boolean indicating if there is an active physics engine
  111161. */
  111162. isPhysicsEnabled(): boolean;
  111163. /**
  111164. * Deletes a physics compound impostor
  111165. * @param compound defines the compound to delete
  111166. */
  111167. deleteCompoundImpostor(compound: any): void;
  111168. /**
  111169. * An event triggered when physic simulation is about to be run
  111170. */
  111171. onBeforePhysicsObservable: Observable<Scene>;
  111172. /**
  111173. * An event triggered when physic simulation has been done
  111174. */
  111175. onAfterPhysicsObservable: Observable<Scene>;
  111176. }
  111177. interface AbstractMesh {
  111178. /** @hidden */
  111179. _physicsImpostor: Nullable<PhysicsImpostor>;
  111180. /**
  111181. * Gets or sets impostor used for physic simulation
  111182. * @see http://doc.babylonjs.com/features/physics_engine
  111183. */
  111184. physicsImpostor: Nullable<PhysicsImpostor>;
  111185. /**
  111186. * Gets the current physics impostor
  111187. * @see http://doc.babylonjs.com/features/physics_engine
  111188. * @returns a physics impostor or null
  111189. */
  111190. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111191. /** Apply a physic impulse to the mesh
  111192. * @param force defines the force to apply
  111193. * @param contactPoint defines where to apply the force
  111194. * @returns the current mesh
  111195. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111196. */
  111197. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111198. /**
  111199. * Creates a physic joint between two meshes
  111200. * @param otherMesh defines the other mesh to use
  111201. * @param pivot1 defines the pivot to use on this mesh
  111202. * @param pivot2 defines the pivot to use on the other mesh
  111203. * @param options defines additional options (can be plugin dependent)
  111204. * @returns the current mesh
  111205. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111206. */
  111207. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111208. /** @hidden */
  111209. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111210. }
  111211. /**
  111212. * Defines the physics engine scene component responsible to manage a physics engine
  111213. */
  111214. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111215. /**
  111216. * The component name helpful to identify the component in the list of scene components.
  111217. */
  111218. readonly name: string;
  111219. /**
  111220. * The scene the component belongs to.
  111221. */
  111222. scene: Scene;
  111223. /**
  111224. * Creates a new instance of the component for the given scene
  111225. * @param scene Defines the scene to register the component in
  111226. */
  111227. constructor(scene: Scene);
  111228. /**
  111229. * Registers the component in a given scene
  111230. */
  111231. register(): void;
  111232. /**
  111233. * Rebuilds the elements related to this component in case of
  111234. * context lost for instance.
  111235. */
  111236. rebuild(): void;
  111237. /**
  111238. * Disposes the component and the associated ressources
  111239. */
  111240. dispose(): void;
  111241. }
  111242. }
  111243. declare module BABYLON {
  111244. /**
  111245. * A helper for physics simulations
  111246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111247. */
  111248. export class PhysicsHelper {
  111249. private _scene;
  111250. private _physicsEngine;
  111251. /**
  111252. * Initializes the Physics helper
  111253. * @param scene Babylon.js scene
  111254. */
  111255. constructor(scene: Scene);
  111256. /**
  111257. * Applies a radial explosion impulse
  111258. * @param origin the origin of the explosion
  111259. * @param radiusOrEventOptions the radius or the options of radial explosion
  111260. * @param strength the explosion strength
  111261. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111262. * @returns A physics radial explosion event, or null
  111263. */
  111264. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111265. /**
  111266. * Applies a radial explosion force
  111267. * @param origin the origin of the explosion
  111268. * @param radiusOrEventOptions the radius or the options of radial explosion
  111269. * @param strength the explosion strength
  111270. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111271. * @returns A physics radial explosion event, or null
  111272. */
  111273. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111274. /**
  111275. * Creates a gravitational field
  111276. * @param origin the origin of the explosion
  111277. * @param radiusOrEventOptions the radius or the options of radial explosion
  111278. * @param strength the explosion strength
  111279. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111280. * @returns A physics gravitational field event, or null
  111281. */
  111282. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111283. /**
  111284. * Creates a physics updraft event
  111285. * @param origin the origin of the updraft
  111286. * @param radiusOrEventOptions the radius or the options of the updraft
  111287. * @param strength the strength of the updraft
  111288. * @param height the height of the updraft
  111289. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111290. * @returns A physics updraft event, or null
  111291. */
  111292. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111293. /**
  111294. * Creates a physics vortex event
  111295. * @param origin the of the vortex
  111296. * @param radiusOrEventOptions the radius or the options of the vortex
  111297. * @param strength the strength of the vortex
  111298. * @param height the height of the vortex
  111299. * @returns a Physics vortex event, or null
  111300. * A physics vortex event or null
  111301. */
  111302. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111303. }
  111304. /**
  111305. * Represents a physics radial explosion event
  111306. */
  111307. class PhysicsRadialExplosionEvent {
  111308. private _scene;
  111309. private _options;
  111310. private _sphere;
  111311. private _dataFetched;
  111312. /**
  111313. * Initializes a radial explosioin event
  111314. * @param _scene BabylonJS scene
  111315. * @param _options The options for the vortex event
  111316. */
  111317. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111318. /**
  111319. * Returns the data related to the radial explosion event (sphere).
  111320. * @returns The radial explosion event data
  111321. */
  111322. getData(): PhysicsRadialExplosionEventData;
  111323. /**
  111324. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111325. * @param impostor A physics imposter
  111326. * @param origin the origin of the explosion
  111327. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111328. */
  111329. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111330. /**
  111331. * Triggers affecterd impostors callbacks
  111332. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111333. */
  111334. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111335. /**
  111336. * Disposes the sphere.
  111337. * @param force Specifies if the sphere should be disposed by force
  111338. */
  111339. dispose(force?: boolean): void;
  111340. /*** Helpers ***/
  111341. private _prepareSphere;
  111342. private _intersectsWithSphere;
  111343. }
  111344. /**
  111345. * Represents a gravitational field event
  111346. */
  111347. class PhysicsGravitationalFieldEvent {
  111348. private _physicsHelper;
  111349. private _scene;
  111350. private _origin;
  111351. private _options;
  111352. private _tickCallback;
  111353. private _sphere;
  111354. private _dataFetched;
  111355. /**
  111356. * Initializes the physics gravitational field event
  111357. * @param _physicsHelper A physics helper
  111358. * @param _scene BabylonJS scene
  111359. * @param _origin The origin position of the gravitational field event
  111360. * @param _options The options for the vortex event
  111361. */
  111362. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111363. /**
  111364. * Returns the data related to the gravitational field event (sphere).
  111365. * @returns A gravitational field event
  111366. */
  111367. getData(): PhysicsGravitationalFieldEventData;
  111368. /**
  111369. * Enables the gravitational field.
  111370. */
  111371. enable(): void;
  111372. /**
  111373. * Disables the gravitational field.
  111374. */
  111375. disable(): void;
  111376. /**
  111377. * Disposes the sphere.
  111378. * @param force The force to dispose from the gravitational field event
  111379. */
  111380. dispose(force?: boolean): void;
  111381. private _tick;
  111382. }
  111383. /**
  111384. * Represents a physics updraft event
  111385. */
  111386. class PhysicsUpdraftEvent {
  111387. private _scene;
  111388. private _origin;
  111389. private _options;
  111390. private _physicsEngine;
  111391. private _originTop;
  111392. private _originDirection;
  111393. private _tickCallback;
  111394. private _cylinder;
  111395. private _cylinderPosition;
  111396. private _dataFetched;
  111397. /**
  111398. * Initializes the physics updraft event
  111399. * @param _scene BabylonJS scene
  111400. * @param _origin The origin position of the updraft
  111401. * @param _options The options for the updraft event
  111402. */
  111403. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111404. /**
  111405. * Returns the data related to the updraft event (cylinder).
  111406. * @returns A physics updraft event
  111407. */
  111408. getData(): PhysicsUpdraftEventData;
  111409. /**
  111410. * Enables the updraft.
  111411. */
  111412. enable(): void;
  111413. /**
  111414. * Disables the updraft.
  111415. */
  111416. disable(): void;
  111417. /**
  111418. * Disposes the cylinder.
  111419. * @param force Specifies if the updraft should be disposed by force
  111420. */
  111421. dispose(force?: boolean): void;
  111422. private getImpostorHitData;
  111423. private _tick;
  111424. /*** Helpers ***/
  111425. private _prepareCylinder;
  111426. private _intersectsWithCylinder;
  111427. }
  111428. /**
  111429. * Represents a physics vortex event
  111430. */
  111431. class PhysicsVortexEvent {
  111432. private _scene;
  111433. private _origin;
  111434. private _options;
  111435. private _physicsEngine;
  111436. private _originTop;
  111437. private _tickCallback;
  111438. private _cylinder;
  111439. private _cylinderPosition;
  111440. private _dataFetched;
  111441. /**
  111442. * Initializes the physics vortex event
  111443. * @param _scene The BabylonJS scene
  111444. * @param _origin The origin position of the vortex
  111445. * @param _options The options for the vortex event
  111446. */
  111447. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111448. /**
  111449. * Returns the data related to the vortex event (cylinder).
  111450. * @returns The physics vortex event data
  111451. */
  111452. getData(): PhysicsVortexEventData;
  111453. /**
  111454. * Enables the vortex.
  111455. */
  111456. enable(): void;
  111457. /**
  111458. * Disables the cortex.
  111459. */
  111460. disable(): void;
  111461. /**
  111462. * Disposes the sphere.
  111463. * @param force
  111464. */
  111465. dispose(force?: boolean): void;
  111466. private getImpostorHitData;
  111467. private _tick;
  111468. /*** Helpers ***/
  111469. private _prepareCylinder;
  111470. private _intersectsWithCylinder;
  111471. }
  111472. /**
  111473. * Options fot the radial explosion event
  111474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111475. */
  111476. export class PhysicsRadialExplosionEventOptions {
  111477. /**
  111478. * The radius of the sphere for the radial explosion.
  111479. */
  111480. radius: number;
  111481. /**
  111482. * The strenth of the explosion.
  111483. */
  111484. strength: number;
  111485. /**
  111486. * The strenght of the force in correspondence to the distance of the affected object
  111487. */
  111488. falloff: PhysicsRadialImpulseFalloff;
  111489. /**
  111490. * Sphere options for the radial explosion.
  111491. */
  111492. sphere: {
  111493. segments: number;
  111494. diameter: number;
  111495. };
  111496. /**
  111497. * Sphere options for the radial explosion.
  111498. */
  111499. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  111500. }
  111501. /**
  111502. * Options fot the updraft event
  111503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111504. */
  111505. export class PhysicsUpdraftEventOptions {
  111506. /**
  111507. * The radius of the cylinder for the vortex
  111508. */
  111509. radius: number;
  111510. /**
  111511. * The strenth of the updraft.
  111512. */
  111513. strength: number;
  111514. /**
  111515. * The height of the cylinder for the updraft.
  111516. */
  111517. height: number;
  111518. /**
  111519. * The mode for the the updraft.
  111520. */
  111521. updraftMode: PhysicsUpdraftMode;
  111522. }
  111523. /**
  111524. * Options fot the vortex event
  111525. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111526. */
  111527. export class PhysicsVortexEventOptions {
  111528. /**
  111529. * The radius of the cylinder for the vortex
  111530. */
  111531. radius: number;
  111532. /**
  111533. * The strenth of the vortex.
  111534. */
  111535. strength: number;
  111536. /**
  111537. * The height of the cylinder for the vortex.
  111538. */
  111539. height: number;
  111540. /**
  111541. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  111542. */
  111543. centripetalForceThreshold: number;
  111544. /**
  111545. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  111546. */
  111547. centripetalForceMultiplier: number;
  111548. /**
  111549. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  111550. */
  111551. centrifugalForceMultiplier: number;
  111552. /**
  111553. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  111554. */
  111555. updraftForceMultiplier: number;
  111556. }
  111557. /**
  111558. * The strenght of the force in correspondence to the distance of the affected object
  111559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111560. */
  111561. export enum PhysicsRadialImpulseFalloff {
  111562. /** Defines that impulse is constant in strength across it's whole radius */
  111563. Constant = 0,
  111564. /** Defines that impulse gets weaker if it's further from the origin */
  111565. Linear = 1
  111566. }
  111567. /**
  111568. * The strength of the force in correspondence to the distance of the affected object
  111569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111570. */
  111571. export enum PhysicsUpdraftMode {
  111572. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111573. Center = 0,
  111574. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111575. Perpendicular = 1
  111576. }
  111577. /**
  111578. * Interface for a physics hit data
  111579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111580. */
  111581. export interface PhysicsHitData {
  111582. /**
  111583. * The force applied at the contact point
  111584. */
  111585. force: Vector3;
  111586. /**
  111587. * The contact point
  111588. */
  111589. contactPoint: Vector3;
  111590. /**
  111591. * The distance from the origin to the contact point
  111592. */
  111593. distanceFromOrigin: number;
  111594. }
  111595. /**
  111596. * Interface for radial explosion event data
  111597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111598. */
  111599. export interface PhysicsRadialExplosionEventData {
  111600. /**
  111601. * A sphere used for the radial explosion event
  111602. */
  111603. sphere: Mesh;
  111604. }
  111605. /**
  111606. * Interface for gravitational field event data
  111607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111608. */
  111609. export interface PhysicsGravitationalFieldEventData {
  111610. /**
  111611. * A sphere mesh used for the gravitational field event
  111612. */
  111613. sphere: Mesh;
  111614. }
  111615. /**
  111616. * Interface for updraft event data
  111617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111618. */
  111619. export interface PhysicsUpdraftEventData {
  111620. /**
  111621. * A cylinder used for the updraft event
  111622. */
  111623. cylinder: Mesh;
  111624. }
  111625. /**
  111626. * Interface for vortex event data
  111627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111628. */
  111629. export interface PhysicsVortexEventData {
  111630. /**
  111631. * A cylinder used for the vortex event
  111632. */
  111633. cylinder: Mesh;
  111634. }
  111635. /**
  111636. * Interface for an affected physics impostor
  111637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111638. */
  111639. export interface PhysicsAffectedImpostorWithData {
  111640. /**
  111641. * The impostor affected by the effect
  111642. */
  111643. impostor: PhysicsImpostor;
  111644. /**
  111645. * The data about the hit/horce from the explosion
  111646. */
  111647. hitData: PhysicsHitData;
  111648. }
  111649. }
  111650. declare module BABYLON {
  111651. /** @hidden */
  111652. export var blackAndWhitePixelShader: {
  111653. name: string;
  111654. shader: string;
  111655. };
  111656. }
  111657. declare module BABYLON {
  111658. /**
  111659. * Post process used to render in black and white
  111660. */
  111661. export class BlackAndWhitePostProcess extends PostProcess {
  111662. /**
  111663. * Linear about to convert he result to black and white (default: 1)
  111664. */
  111665. degree: number;
  111666. /**
  111667. * Creates a black and white post process
  111668. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  111669. * @param name The name of the effect.
  111670. * @param options The required width/height ratio to downsize to before computing the render pass.
  111671. * @param camera The camera to apply the render pass to.
  111672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111673. * @param engine The engine which the post process will be applied. (default: current engine)
  111674. * @param reusable If the post process can be reused on the same frame. (default: false)
  111675. */
  111676. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111677. }
  111678. }
  111679. declare module BABYLON {
  111680. /**
  111681. * This represents a set of one or more post processes in Babylon.
  111682. * A post process can be used to apply a shader to a texture after it is rendered.
  111683. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111684. */
  111685. export class PostProcessRenderEffect {
  111686. private _postProcesses;
  111687. private _getPostProcesses;
  111688. private _singleInstance;
  111689. private _cameras;
  111690. private _indicesForCamera;
  111691. /**
  111692. * Name of the effect
  111693. * @hidden
  111694. */
  111695. _name: string;
  111696. /**
  111697. * Instantiates a post process render effect.
  111698. * A post process can be used to apply a shader to a texture after it is rendered.
  111699. * @param engine The engine the effect is tied to
  111700. * @param name The name of the effect
  111701. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  111702. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  111703. */
  111704. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  111705. /**
  111706. * Checks if all the post processes in the effect are supported.
  111707. */
  111708. readonly isSupported: boolean;
  111709. /**
  111710. * Updates the current state of the effect
  111711. * @hidden
  111712. */
  111713. _update(): void;
  111714. /**
  111715. * Attaches the effect on cameras
  111716. * @param cameras The camera to attach to.
  111717. * @hidden
  111718. */
  111719. _attachCameras(cameras: Camera): void;
  111720. /**
  111721. * Attaches the effect on cameras
  111722. * @param cameras The camera to attach to.
  111723. * @hidden
  111724. */
  111725. _attachCameras(cameras: Camera[]): void;
  111726. /**
  111727. * Detatches the effect on cameras
  111728. * @param cameras The camera to detatch from.
  111729. * @hidden
  111730. */
  111731. _detachCameras(cameras: Camera): void;
  111732. /**
  111733. * Detatches the effect on cameras
  111734. * @param cameras The camera to detatch from.
  111735. * @hidden
  111736. */
  111737. _detachCameras(cameras: Camera[]): void;
  111738. /**
  111739. * Enables the effect on given cameras
  111740. * @param cameras The camera to enable.
  111741. * @hidden
  111742. */
  111743. _enable(cameras: Camera): void;
  111744. /**
  111745. * Enables the effect on given cameras
  111746. * @param cameras The camera to enable.
  111747. * @hidden
  111748. */
  111749. _enable(cameras: Nullable<Camera[]>): void;
  111750. /**
  111751. * Disables the effect on the given cameras
  111752. * @param cameras The camera to disable.
  111753. * @hidden
  111754. */
  111755. _disable(cameras: Camera): void;
  111756. /**
  111757. * Disables the effect on the given cameras
  111758. * @param cameras The camera to disable.
  111759. * @hidden
  111760. */
  111761. _disable(cameras: Nullable<Camera[]>): void;
  111762. /**
  111763. * Gets a list of the post processes contained in the effect.
  111764. * @param camera The camera to get the post processes on.
  111765. * @returns The list of the post processes in the effect.
  111766. */
  111767. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  111768. }
  111769. }
  111770. declare module BABYLON {
  111771. /** @hidden */
  111772. export var extractHighlightsPixelShader: {
  111773. name: string;
  111774. shader: string;
  111775. };
  111776. }
  111777. declare module BABYLON {
  111778. /**
  111779. * 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.
  111780. */
  111781. export class ExtractHighlightsPostProcess extends PostProcess {
  111782. /**
  111783. * The luminance threshold, pixels below this value will be set to black.
  111784. */
  111785. threshold: number;
  111786. /** @hidden */
  111787. _exposure: number;
  111788. /**
  111789. * Post process which has the input texture to be used when performing highlight extraction
  111790. * @hidden
  111791. */
  111792. _inputPostProcess: Nullable<PostProcess>;
  111793. constructor(name: string, 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 bloomMergePixelShader: {
  111799. name: string;
  111800. shader: string;
  111801. };
  111802. }
  111803. declare module BABYLON {
  111804. /**
  111805. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111806. */
  111807. export class BloomMergePostProcess extends PostProcess {
  111808. /** Weight of the bloom to be added to the original input. */
  111809. weight: number;
  111810. /**
  111811. * Creates a new instance of @see BloomMergePostProcess
  111812. * @param name The name of the effect.
  111813. * @param originalFromInput Post process which's input will be used for the merge.
  111814. * @param blurred Blurred highlights post process which's output will be used.
  111815. * @param weight Weight of the bloom to be added to the original input.
  111816. * @param options The required width/height ratio to downsize to before computing the render pass.
  111817. * @param camera The camera to apply the render pass to.
  111818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111819. * @param engine The engine which the post process will be applied. (default: current engine)
  111820. * @param reusable If the post process can be reused on the same frame. (default: false)
  111821. * @param textureType Type of textures used when performing the post process. (default: 0)
  111822. * @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)
  111823. */
  111824. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  111825. /** Weight of the bloom to be added to the original input. */
  111826. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111827. }
  111828. }
  111829. declare module BABYLON {
  111830. /**
  111831. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  111832. */
  111833. export class BloomEffect extends PostProcessRenderEffect {
  111834. private bloomScale;
  111835. /**
  111836. * @hidden Internal
  111837. */
  111838. _effects: Array<PostProcess>;
  111839. /**
  111840. * @hidden Internal
  111841. */
  111842. _downscale: ExtractHighlightsPostProcess;
  111843. private _blurX;
  111844. private _blurY;
  111845. private _merge;
  111846. /**
  111847. * The luminance threshold to find bright areas of the image to bloom.
  111848. */
  111849. threshold: number;
  111850. /**
  111851. * The strength of the bloom.
  111852. */
  111853. weight: number;
  111854. /**
  111855. * Specifies the size of the bloom blur kernel, relative to the final output size
  111856. */
  111857. kernel: number;
  111858. /**
  111859. * Creates a new instance of @see BloomEffect
  111860. * @param scene The scene the effect belongs to.
  111861. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  111862. * @param bloomKernel The size of the kernel to be used when applying the blur.
  111863. * @param bloomWeight The the strength of bloom.
  111864. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111865. * @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)
  111866. */
  111867. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  111868. /**
  111869. * Disposes each of the internal effects for a given camera.
  111870. * @param camera The camera to dispose the effect on.
  111871. */
  111872. disposeEffects(camera: Camera): void;
  111873. /**
  111874. * @hidden Internal
  111875. */
  111876. _updateEffects(): void;
  111877. /**
  111878. * Internal
  111879. * @returns if all the contained post processes are ready.
  111880. * @hidden
  111881. */
  111882. _isReady(): boolean;
  111883. }
  111884. }
  111885. declare module BABYLON {
  111886. /** @hidden */
  111887. export var chromaticAberrationPixelShader: {
  111888. name: string;
  111889. shader: string;
  111890. };
  111891. }
  111892. declare module BABYLON {
  111893. /**
  111894. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  111895. */
  111896. export class ChromaticAberrationPostProcess extends PostProcess {
  111897. /**
  111898. * The amount of seperation of rgb channels (default: 30)
  111899. */
  111900. aberrationAmount: number;
  111901. /**
  111902. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  111903. */
  111904. radialIntensity: number;
  111905. /**
  111906. * 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))
  111907. */
  111908. direction: Vector2;
  111909. /**
  111910. * 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))
  111911. */
  111912. centerPosition: Vector2;
  111913. /**
  111914. * Creates a new instance ChromaticAberrationPostProcess
  111915. * @param name The name of the effect.
  111916. * @param screenWidth The width of the screen to apply the effect on.
  111917. * @param screenHeight The height of the screen to apply the effect on.
  111918. * @param options The required width/height ratio to downsize to before computing the render pass.
  111919. * @param camera The camera to apply the render pass to.
  111920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111921. * @param engine The engine which the post process will be applied. (default: current engine)
  111922. * @param reusable If the post process can be reused on the same frame. (default: false)
  111923. * @param textureType Type of textures used when performing the post process. (default: 0)
  111924. * @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)
  111925. */
  111926. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111927. }
  111928. }
  111929. declare module BABYLON {
  111930. /** @hidden */
  111931. export var circleOfConfusionPixelShader: {
  111932. name: string;
  111933. shader: string;
  111934. };
  111935. }
  111936. declare module BABYLON {
  111937. /**
  111938. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  111939. */
  111940. export class CircleOfConfusionPostProcess extends PostProcess {
  111941. /**
  111942. * 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.
  111943. */
  111944. lensSize: number;
  111945. /**
  111946. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111947. */
  111948. fStop: number;
  111949. /**
  111950. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111951. */
  111952. focusDistance: number;
  111953. /**
  111954. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  111955. */
  111956. focalLength: number;
  111957. private _depthTexture;
  111958. /**
  111959. * Creates a new instance CircleOfConfusionPostProcess
  111960. * @param name The name of the effect.
  111961. * @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.
  111962. * @param options The required width/height ratio to downsize to before computing the render pass.
  111963. * @param camera The camera to apply the render pass to.
  111964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111965. * @param engine The engine which the post process will be applied. (default: current engine)
  111966. * @param reusable If the post process can be reused on the same frame. (default: false)
  111967. * @param textureType Type of textures used when performing the post process. (default: 0)
  111968. * @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)
  111969. */
  111970. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111971. /**
  111972. * 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.
  111973. */
  111974. depthTexture: RenderTargetTexture;
  111975. }
  111976. }
  111977. declare module BABYLON {
  111978. /** @hidden */
  111979. export var colorCorrectionPixelShader: {
  111980. name: string;
  111981. shader: string;
  111982. };
  111983. }
  111984. declare module BABYLON {
  111985. /**
  111986. *
  111987. * This post-process allows the modification of rendered colors by using
  111988. * a 'look-up table' (LUT). This effect is also called Color Grading.
  111989. *
  111990. * The object needs to be provided an url to a texture containing the color
  111991. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  111992. * Use an image editing software to tweak the LUT to match your needs.
  111993. *
  111994. * For an example of a color LUT, see here:
  111995. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  111996. * For explanations on color grading, see here:
  111997. * @see http://udn.epicgames.com/Three/ColorGrading.html
  111998. *
  111999. */
  112000. export class ColorCorrectionPostProcess extends PostProcess {
  112001. private _colorTableTexture;
  112002. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112003. }
  112004. }
  112005. declare module BABYLON {
  112006. /** @hidden */
  112007. export var convolutionPixelShader: {
  112008. name: string;
  112009. shader: string;
  112010. };
  112011. }
  112012. declare module BABYLON {
  112013. /**
  112014. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112015. * input texture to perform effects such as edge detection or sharpening
  112016. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112017. */
  112018. export class ConvolutionPostProcess extends PostProcess {
  112019. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112020. kernel: number[];
  112021. /**
  112022. * Creates a new instance ConvolutionPostProcess
  112023. * @param name The name of the effect.
  112024. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112025. * @param options The required width/height ratio to downsize to before computing the render pass.
  112026. * @param camera The camera to apply the render pass to.
  112027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112028. * @param engine The engine which the post process will be applied. (default: current engine)
  112029. * @param reusable If the post process can be reused on the same frame. (default: false)
  112030. * @param textureType Type of textures used when performing the post process. (default: 0)
  112031. */
  112032. constructor(name: string,
  112033. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112034. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112035. /**
  112036. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112037. */
  112038. static EdgeDetect0Kernel: number[];
  112039. /**
  112040. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112041. */
  112042. static EdgeDetect1Kernel: number[];
  112043. /**
  112044. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112045. */
  112046. static EdgeDetect2Kernel: number[];
  112047. /**
  112048. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112049. */
  112050. static SharpenKernel: number[];
  112051. /**
  112052. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112053. */
  112054. static EmbossKernel: number[];
  112055. /**
  112056. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112057. */
  112058. static GaussianKernel: number[];
  112059. }
  112060. }
  112061. declare module BABYLON {
  112062. /**
  112063. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112064. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112065. * based on samples that have a large difference in distance than the center pixel.
  112066. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112067. */
  112068. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112069. direction: Vector2;
  112070. /**
  112071. * Creates a new instance CircleOfConfusionPostProcess
  112072. * @param name The name of the effect.
  112073. * @param scene The scene the effect belongs to.
  112074. * @param direction The direction the blur should be applied.
  112075. * @param kernel The size of the kernel used to blur.
  112076. * @param options The required width/height ratio to downsize to before computing the render pass.
  112077. * @param camera The camera to apply the render pass to.
  112078. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112079. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112081. * @param engine The engine which the post process will be applied. (default: current engine)
  112082. * @param reusable If the post process can be reused on the same frame. (default: false)
  112083. * @param textureType Type of textures used when performing the post process. (default: 0)
  112084. * @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)
  112085. */
  112086. 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);
  112087. }
  112088. }
  112089. declare module BABYLON {
  112090. /** @hidden */
  112091. export var depthOfFieldMergePixelShader: {
  112092. name: string;
  112093. shader: string;
  112094. };
  112095. }
  112096. declare module BABYLON {
  112097. /**
  112098. * Options to be set when merging outputs from the default pipeline.
  112099. */
  112100. export class DepthOfFieldMergePostProcessOptions {
  112101. /**
  112102. * The original image to merge on top of
  112103. */
  112104. originalFromInput: PostProcess;
  112105. /**
  112106. * Parameters to perform the merge of the depth of field effect
  112107. */
  112108. depthOfField?: {
  112109. circleOfConfusion: PostProcess;
  112110. blurSteps: Array<PostProcess>;
  112111. };
  112112. /**
  112113. * Parameters to perform the merge of bloom effect
  112114. */
  112115. bloom?: {
  112116. blurred: PostProcess;
  112117. weight: number;
  112118. };
  112119. }
  112120. /**
  112121. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112122. */
  112123. export class DepthOfFieldMergePostProcess extends PostProcess {
  112124. private blurSteps;
  112125. /**
  112126. * Creates a new instance of DepthOfFieldMergePostProcess
  112127. * @param name The name of the effect.
  112128. * @param originalFromInput Post process which's input will be used for the merge.
  112129. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112130. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112131. * @param options The required width/height ratio to downsize to before computing the render pass.
  112132. * @param camera The camera to apply the render pass to.
  112133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112134. * @param engine The engine which the post process will be applied. (default: current engine)
  112135. * @param reusable If the post process can be reused on the same frame. (default: false)
  112136. * @param textureType Type of textures used when performing the post process. (default: 0)
  112137. * @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)
  112138. */
  112139. 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);
  112140. /**
  112141. * Updates the effect with the current post process compile time values and recompiles the shader.
  112142. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112143. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112144. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112145. * @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
  112146. * @param onCompiled Called when the shader has been compiled.
  112147. * @param onError Called if there is an error when compiling a shader.
  112148. */
  112149. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112150. }
  112151. }
  112152. declare module BABYLON {
  112153. /**
  112154. * Specifies the level of max blur that should be applied when using the depth of field effect
  112155. */
  112156. export enum DepthOfFieldEffectBlurLevel {
  112157. /**
  112158. * Subtle blur
  112159. */
  112160. Low = 0,
  112161. /**
  112162. * Medium blur
  112163. */
  112164. Medium = 1,
  112165. /**
  112166. * Large blur
  112167. */
  112168. High = 2
  112169. }
  112170. /**
  112171. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112172. */
  112173. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112174. private _circleOfConfusion;
  112175. /**
  112176. * @hidden Internal, blurs from high to low
  112177. */
  112178. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112179. private _depthOfFieldBlurY;
  112180. private _dofMerge;
  112181. /**
  112182. * @hidden Internal post processes in depth of field effect
  112183. */
  112184. _effects: Array<PostProcess>;
  112185. /**
  112186. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112187. */
  112188. focalLength: number;
  112189. /**
  112190. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112191. */
  112192. fStop: number;
  112193. /**
  112194. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112195. */
  112196. focusDistance: number;
  112197. /**
  112198. * 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.
  112199. */
  112200. lensSize: number;
  112201. /**
  112202. * Creates a new instance DepthOfFieldEffect
  112203. * @param scene The scene the effect belongs to.
  112204. * @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.
  112205. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112206. * @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)
  112207. */
  112208. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112209. /**
  112210. * 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.
  112211. */
  112212. depthTexture: RenderTargetTexture;
  112213. /**
  112214. * Disposes each of the internal effects for a given camera.
  112215. * @param camera The camera to dispose the effect on.
  112216. */
  112217. disposeEffects(camera: Camera): void;
  112218. /**
  112219. * @hidden Internal
  112220. */
  112221. _updateEffects(): void;
  112222. /**
  112223. * Internal
  112224. * @returns if all the contained post processes are ready.
  112225. * @hidden
  112226. */
  112227. _isReady(): boolean;
  112228. }
  112229. }
  112230. declare module BABYLON {
  112231. /** @hidden */
  112232. export var displayPassPixelShader: {
  112233. name: string;
  112234. shader: string;
  112235. };
  112236. }
  112237. declare module BABYLON {
  112238. /**
  112239. * DisplayPassPostProcess which produces an output the same as it's input
  112240. */
  112241. export class DisplayPassPostProcess extends PostProcess {
  112242. /**
  112243. * Creates the DisplayPassPostProcess
  112244. * @param name The name of the effect.
  112245. * @param options The required width/height ratio to downsize to before computing the render pass.
  112246. * @param camera The camera to apply the render pass to.
  112247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112248. * @param engine The engine which the post process will be applied. (default: current engine)
  112249. * @param reusable If the post process can be reused on the same frame. (default: false)
  112250. */
  112251. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112252. }
  112253. }
  112254. declare module BABYLON {
  112255. /** @hidden */
  112256. export var filterPixelShader: {
  112257. name: string;
  112258. shader: string;
  112259. };
  112260. }
  112261. declare module BABYLON {
  112262. /**
  112263. * Applies a kernel filter to the image
  112264. */
  112265. export class FilterPostProcess extends PostProcess {
  112266. /** The matrix to be applied to the image */
  112267. kernelMatrix: Matrix;
  112268. /**
  112269. *
  112270. * @param name The name of the effect.
  112271. * @param kernelMatrix The matrix to be applied to the image
  112272. * @param options The required width/height ratio to downsize to before computing the render pass.
  112273. * @param camera The camera to apply the render pass to.
  112274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112275. * @param engine The engine which the post process will be applied. (default: current engine)
  112276. * @param reusable If the post process can be reused on the same frame. (default: false)
  112277. */
  112278. constructor(name: string,
  112279. /** The matrix to be applied to the image */
  112280. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112281. }
  112282. }
  112283. declare module BABYLON {
  112284. /** @hidden */
  112285. export var fxaaPixelShader: {
  112286. name: string;
  112287. shader: string;
  112288. };
  112289. }
  112290. declare module BABYLON {
  112291. /** @hidden */
  112292. export var fxaaVertexShader: {
  112293. name: string;
  112294. shader: string;
  112295. };
  112296. }
  112297. declare module BABYLON {
  112298. /**
  112299. * Fxaa post process
  112300. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112301. */
  112302. export class FxaaPostProcess extends PostProcess {
  112303. /** @hidden */
  112304. texelWidth: number;
  112305. /** @hidden */
  112306. texelHeight: number;
  112307. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112308. private _getDefines;
  112309. }
  112310. }
  112311. declare module BABYLON {
  112312. /** @hidden */
  112313. export var grainPixelShader: {
  112314. name: string;
  112315. shader: string;
  112316. };
  112317. }
  112318. declare module BABYLON {
  112319. /**
  112320. * The GrainPostProcess adds noise to the image at mid luminance levels
  112321. */
  112322. export class GrainPostProcess extends PostProcess {
  112323. /**
  112324. * The intensity of the grain added (default: 30)
  112325. */
  112326. intensity: number;
  112327. /**
  112328. * If the grain should be randomized on every frame
  112329. */
  112330. animated: boolean;
  112331. /**
  112332. * Creates a new instance of @see GrainPostProcess
  112333. * @param name The name of the effect.
  112334. * @param options The required width/height ratio to downsize to before computing the render pass.
  112335. * @param camera The camera to apply the render pass to.
  112336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112337. * @param engine The engine which the post process will be applied. (default: current engine)
  112338. * @param reusable If the post process can be reused on the same frame. (default: false)
  112339. * @param textureType Type of textures used when performing the post process. (default: 0)
  112340. * @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)
  112341. */
  112342. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112343. }
  112344. }
  112345. declare module BABYLON {
  112346. /** @hidden */
  112347. export var highlightsPixelShader: {
  112348. name: string;
  112349. shader: string;
  112350. };
  112351. }
  112352. declare module BABYLON {
  112353. /**
  112354. * Extracts highlights from the image
  112355. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112356. */
  112357. export class HighlightsPostProcess extends PostProcess {
  112358. /**
  112359. * Extracts highlights from the image
  112360. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112361. * @param name The name of the effect.
  112362. * @param options The required width/height ratio to downsize to before computing the render pass.
  112363. * @param camera The camera to apply the render pass to.
  112364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112365. * @param engine The engine which the post process will be applied. (default: current engine)
  112366. * @param reusable If the post process can be reused on the same frame. (default: false)
  112367. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112368. */
  112369. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112370. }
  112371. }
  112372. declare module BABYLON {
  112373. /** @hidden */
  112374. export var mrtFragmentDeclaration: {
  112375. name: string;
  112376. shader: string;
  112377. };
  112378. }
  112379. declare module BABYLON {
  112380. /** @hidden */
  112381. export var geometryPixelShader: {
  112382. name: string;
  112383. shader: string;
  112384. };
  112385. }
  112386. declare module BABYLON {
  112387. /** @hidden */
  112388. export var geometryVertexShader: {
  112389. name: string;
  112390. shader: string;
  112391. };
  112392. }
  112393. declare module BABYLON {
  112394. /**
  112395. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112396. */
  112397. export class GeometryBufferRenderer {
  112398. /**
  112399. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112400. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112401. */
  112402. static readonly POSITION_TEXTURE_TYPE: number;
  112403. /**
  112404. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112405. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112406. */
  112407. static readonly VELOCITY_TEXTURE_TYPE: number;
  112408. /**
  112409. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112410. * in order to compute objects velocities when enableVelocity is set to "true"
  112411. * @hidden
  112412. */
  112413. _previousTransformationMatrices: {
  112414. [index: number]: Matrix;
  112415. };
  112416. private _scene;
  112417. private _multiRenderTarget;
  112418. private _ratio;
  112419. private _enablePosition;
  112420. private _enableVelocity;
  112421. private _positionIndex;
  112422. private _velocityIndex;
  112423. protected _effect: Effect;
  112424. protected _cachedDefines: string;
  112425. /**
  112426. * Set the render list (meshes to be rendered) used in the G buffer.
  112427. */
  112428. renderList: Mesh[];
  112429. /**
  112430. * Gets wether or not G buffer are supported by the running hardware.
  112431. * This requires draw buffer supports
  112432. */
  112433. readonly isSupported: boolean;
  112434. /**
  112435. * Returns the index of the given texture type in the G-Buffer textures array
  112436. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112437. * @returns the index of the given texture type in the G-Buffer textures array
  112438. */
  112439. getTextureIndex(textureType: number): number;
  112440. /**
  112441. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112442. */
  112443. /**
  112444. * Sets whether or not objects positions are enabled for the G buffer.
  112445. */
  112446. enablePosition: boolean;
  112447. /**
  112448. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112449. */
  112450. /**
  112451. * Sets wether or not objects velocities are enabled for the G buffer.
  112452. */
  112453. enableVelocity: boolean;
  112454. /**
  112455. * Gets the scene associated with the buffer.
  112456. */
  112457. readonly scene: Scene;
  112458. /**
  112459. * Gets the ratio used by the buffer during its creation.
  112460. * How big is the buffer related to the main canvas.
  112461. */
  112462. readonly ratio: number;
  112463. /** @hidden */
  112464. static _SceneComponentInitialization: (scene: Scene) => void;
  112465. /**
  112466. * Creates a new G Buffer for the scene
  112467. * @param scene The scene the buffer belongs to
  112468. * @param ratio How big is the buffer related to the main canvas.
  112469. */
  112470. constructor(scene: Scene, ratio?: number);
  112471. /**
  112472. * Checks wether everything is ready to render a submesh to the G buffer.
  112473. * @param subMesh the submesh to check readiness for
  112474. * @param useInstances is the mesh drawn using instance or not
  112475. * @returns true if ready otherwise false
  112476. */
  112477. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112478. /**
  112479. * Gets the current underlying G Buffer.
  112480. * @returns the buffer
  112481. */
  112482. getGBuffer(): MultiRenderTarget;
  112483. /**
  112484. * Gets the number of samples used to render the buffer (anti aliasing).
  112485. */
  112486. /**
  112487. * Sets the number of samples used to render the buffer (anti aliasing).
  112488. */
  112489. samples: number;
  112490. /**
  112491. * Disposes the renderer and frees up associated resources.
  112492. */
  112493. dispose(): void;
  112494. protected _createRenderTargets(): void;
  112495. }
  112496. }
  112497. declare module BABYLON {
  112498. interface Scene {
  112499. /** @hidden (Backing field) */
  112500. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112501. /**
  112502. * Gets or Sets the current geometry buffer associated to the scene.
  112503. */
  112504. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112505. /**
  112506. * Enables a GeometryBufferRender and associates it with the scene
  112507. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  112508. * @returns the GeometryBufferRenderer
  112509. */
  112510. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  112511. /**
  112512. * Disables the GeometryBufferRender associated with the scene
  112513. */
  112514. disableGeometryBufferRenderer(): void;
  112515. }
  112516. /**
  112517. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  112518. * in several rendering techniques.
  112519. */
  112520. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  112521. /**
  112522. * The component name helpful to identify the component in the list of scene components.
  112523. */
  112524. readonly name: string;
  112525. /**
  112526. * The scene the component belongs to.
  112527. */
  112528. scene: Scene;
  112529. /**
  112530. * Creates a new instance of the component for the given scene
  112531. * @param scene Defines the scene to register the component in
  112532. */
  112533. constructor(scene: Scene);
  112534. /**
  112535. * Registers the component in a given scene
  112536. */
  112537. register(): void;
  112538. /**
  112539. * Rebuilds the elements related to this component in case of
  112540. * context lost for instance.
  112541. */
  112542. rebuild(): void;
  112543. /**
  112544. * Disposes the component and the associated ressources
  112545. */
  112546. dispose(): void;
  112547. private _gatherRenderTargets;
  112548. }
  112549. }
  112550. declare module BABYLON {
  112551. /** @hidden */
  112552. export var motionBlurPixelShader: {
  112553. name: string;
  112554. shader: string;
  112555. };
  112556. }
  112557. declare module BABYLON {
  112558. /**
  112559. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  112560. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  112561. * As an example, all you have to do is to create the post-process:
  112562. * var mb = new BABYLON.MotionBlurPostProcess(
  112563. * 'mb', // The name of the effect.
  112564. * scene, // The scene containing the objects to blur according to their velocity.
  112565. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  112566. * camera // The camera to apply the render pass to.
  112567. * );
  112568. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  112569. */
  112570. export class MotionBlurPostProcess extends PostProcess {
  112571. /**
  112572. * Defines how much the image is blurred by the movement. Default value is equal to 1
  112573. */
  112574. motionStrength: number;
  112575. /**
  112576. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  112577. */
  112578. /**
  112579. * Sets the number of iterations to be used for motion blur quality
  112580. */
  112581. motionBlurSamples: number;
  112582. private _motionBlurSamples;
  112583. private _geometryBufferRenderer;
  112584. /**
  112585. * Creates a new instance MotionBlurPostProcess
  112586. * @param name The name of the effect.
  112587. * @param scene The scene containing the objects to blur according to their velocity.
  112588. * @param options The required width/height ratio to downsize to before computing the render pass.
  112589. * @param camera The camera to apply the render pass to.
  112590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112591. * @param engine The engine which the post process will be applied. (default: current engine)
  112592. * @param reusable If the post process can be reused on the same frame. (default: false)
  112593. * @param textureType Type of textures used when performing the post process. (default: 0)
  112594. * @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)
  112595. */
  112596. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112597. /**
  112598. * Disposes the post process.
  112599. * @param camera The camera to dispose the post process on.
  112600. */
  112601. dispose(camera?: Camera): void;
  112602. }
  112603. }
  112604. declare module BABYLON {
  112605. /** @hidden */
  112606. export var refractionPixelShader: {
  112607. name: string;
  112608. shader: string;
  112609. };
  112610. }
  112611. declare module BABYLON {
  112612. /**
  112613. * Post process which applies a refractin texture
  112614. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112615. */
  112616. export class RefractionPostProcess extends PostProcess {
  112617. /** the base color of the refraction (used to taint the rendering) */
  112618. color: Color3;
  112619. /** simulated refraction depth */
  112620. depth: number;
  112621. /** the coefficient of the base color (0 to remove base color tainting) */
  112622. colorLevel: number;
  112623. private _refTexture;
  112624. private _ownRefractionTexture;
  112625. /**
  112626. * Gets or sets the refraction texture
  112627. * Please note that you are responsible for disposing the texture if you set it manually
  112628. */
  112629. refractionTexture: Texture;
  112630. /**
  112631. * Initializes the RefractionPostProcess
  112632. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112633. * @param name The name of the effect.
  112634. * @param refractionTextureUrl Url of the refraction texture to use
  112635. * @param color the base color of the refraction (used to taint the rendering)
  112636. * @param depth simulated refraction depth
  112637. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  112638. * @param camera The camera to apply the render pass to.
  112639. * @param options The required width/height ratio to downsize to before computing the render pass.
  112640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112641. * @param engine The engine which the post process will be applied. (default: current engine)
  112642. * @param reusable If the post process can be reused on the same frame. (default: false)
  112643. */
  112644. constructor(name: string, refractionTextureUrl: string,
  112645. /** the base color of the refraction (used to taint the rendering) */
  112646. color: Color3,
  112647. /** simulated refraction depth */
  112648. depth: number,
  112649. /** the coefficient of the base color (0 to remove base color tainting) */
  112650. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112651. /**
  112652. * Disposes of the post process
  112653. * @param camera Camera to dispose post process on
  112654. */
  112655. dispose(camera: Camera): void;
  112656. }
  112657. }
  112658. declare module BABYLON {
  112659. /** @hidden */
  112660. export var sharpenPixelShader: {
  112661. name: string;
  112662. shader: string;
  112663. };
  112664. }
  112665. declare module BABYLON {
  112666. /**
  112667. * The SharpenPostProcess applies a sharpen kernel to every pixel
  112668. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112669. */
  112670. export class SharpenPostProcess extends PostProcess {
  112671. /**
  112672. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  112673. */
  112674. colorAmount: number;
  112675. /**
  112676. * How much sharpness should be applied (default: 0.3)
  112677. */
  112678. edgeAmount: number;
  112679. /**
  112680. * Creates a new instance ConvolutionPostProcess
  112681. * @param name The name of the effect.
  112682. * @param options The required width/height ratio to downsize to before computing the render pass.
  112683. * @param camera The camera to apply the render pass to.
  112684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112685. * @param engine The engine which the post process will be applied. (default: current engine)
  112686. * @param reusable If the post process can be reused on the same frame. (default: false)
  112687. * @param textureType Type of textures used when performing the post process. (default: 0)
  112688. * @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)
  112689. */
  112690. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112691. }
  112692. }
  112693. declare module BABYLON {
  112694. /**
  112695. * PostProcessRenderPipeline
  112696. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112697. */
  112698. export class PostProcessRenderPipeline {
  112699. private engine;
  112700. private _renderEffects;
  112701. private _renderEffectsForIsolatedPass;
  112702. /**
  112703. * List of inspectable custom properties (used by the Inspector)
  112704. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112705. */
  112706. inspectableCustomProperties: IInspectable[];
  112707. /**
  112708. * @hidden
  112709. */
  112710. protected _cameras: Camera[];
  112711. /** @hidden */
  112712. _name: string;
  112713. /**
  112714. * Gets pipeline name
  112715. */
  112716. readonly name: string;
  112717. /**
  112718. * Initializes a PostProcessRenderPipeline
  112719. * @param engine engine to add the pipeline to
  112720. * @param name name of the pipeline
  112721. */
  112722. constructor(engine: Engine, name: string);
  112723. /**
  112724. * Gets the class name
  112725. * @returns "PostProcessRenderPipeline"
  112726. */
  112727. getClassName(): string;
  112728. /**
  112729. * If all the render effects in the pipeline are supported
  112730. */
  112731. readonly isSupported: boolean;
  112732. /**
  112733. * Adds an effect to the pipeline
  112734. * @param renderEffect the effect to add
  112735. */
  112736. addEffect(renderEffect: PostProcessRenderEffect): void;
  112737. /** @hidden */
  112738. _rebuild(): void;
  112739. /** @hidden */
  112740. _enableEffect(renderEffectName: string, cameras: Camera): void;
  112741. /** @hidden */
  112742. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  112743. /** @hidden */
  112744. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112745. /** @hidden */
  112746. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112747. /** @hidden */
  112748. _attachCameras(cameras: Camera, unique: boolean): void;
  112749. /** @hidden */
  112750. _attachCameras(cameras: Camera[], unique: boolean): void;
  112751. /** @hidden */
  112752. _detachCameras(cameras: Camera): void;
  112753. /** @hidden */
  112754. _detachCameras(cameras: Nullable<Camera[]>): void;
  112755. /** @hidden */
  112756. _update(): void;
  112757. /** @hidden */
  112758. _reset(): void;
  112759. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  112760. /**
  112761. * Disposes of the pipeline
  112762. */
  112763. dispose(): void;
  112764. }
  112765. }
  112766. declare module BABYLON {
  112767. /**
  112768. * PostProcessRenderPipelineManager class
  112769. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112770. */
  112771. export class PostProcessRenderPipelineManager {
  112772. private _renderPipelines;
  112773. /**
  112774. * Initializes a PostProcessRenderPipelineManager
  112775. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112776. */
  112777. constructor();
  112778. /**
  112779. * Gets the list of supported render pipelines
  112780. */
  112781. readonly supportedPipelines: PostProcessRenderPipeline[];
  112782. /**
  112783. * Adds a pipeline to the manager
  112784. * @param renderPipeline The pipeline to add
  112785. */
  112786. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  112787. /**
  112788. * Attaches a camera to the pipeline
  112789. * @param renderPipelineName The name of the pipeline to attach to
  112790. * @param cameras the camera to attach
  112791. * @param unique if the camera can be attached multiple times to the pipeline
  112792. */
  112793. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  112794. /**
  112795. * Detaches a camera from the pipeline
  112796. * @param renderPipelineName The name of the pipeline to detach from
  112797. * @param cameras the camera to detach
  112798. */
  112799. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  112800. /**
  112801. * Enables an effect by name on a pipeline
  112802. * @param renderPipelineName the name of the pipeline to enable the effect in
  112803. * @param renderEffectName the name of the effect to enable
  112804. * @param cameras the cameras that the effect should be enabled on
  112805. */
  112806. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112807. /**
  112808. * Disables an effect by name on a pipeline
  112809. * @param renderPipelineName the name of the pipeline to disable the effect in
  112810. * @param renderEffectName the name of the effect to disable
  112811. * @param cameras the cameras that the effect should be disabled on
  112812. */
  112813. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112814. /**
  112815. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  112816. */
  112817. update(): void;
  112818. /** @hidden */
  112819. _rebuild(): void;
  112820. /**
  112821. * Disposes of the manager and pipelines
  112822. */
  112823. dispose(): void;
  112824. }
  112825. }
  112826. declare module BABYLON {
  112827. interface Scene {
  112828. /** @hidden (Backing field) */
  112829. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112830. /**
  112831. * Gets the postprocess render pipeline manager
  112832. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112833. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112834. */
  112835. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112836. }
  112837. /**
  112838. * Defines the Render Pipeline scene component responsible to rendering pipelines
  112839. */
  112840. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  112841. /**
  112842. * The component name helpfull to identify the component in the list of scene components.
  112843. */
  112844. readonly name: string;
  112845. /**
  112846. * The scene the component belongs to.
  112847. */
  112848. scene: Scene;
  112849. /**
  112850. * Creates a new instance of the component for the given scene
  112851. * @param scene Defines the scene to register the component in
  112852. */
  112853. constructor(scene: Scene);
  112854. /**
  112855. * Registers the component in a given scene
  112856. */
  112857. register(): void;
  112858. /**
  112859. * Rebuilds the elements related to this component in case of
  112860. * context lost for instance.
  112861. */
  112862. rebuild(): void;
  112863. /**
  112864. * Disposes the component and the associated ressources
  112865. */
  112866. dispose(): void;
  112867. private _gatherRenderTargets;
  112868. }
  112869. }
  112870. declare module BABYLON {
  112871. /**
  112872. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  112873. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112874. */
  112875. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  112876. private _scene;
  112877. private _camerasToBeAttached;
  112878. /**
  112879. * ID of the sharpen post process,
  112880. */
  112881. private readonly SharpenPostProcessId;
  112882. /**
  112883. * @ignore
  112884. * ID of the image processing post process;
  112885. */
  112886. readonly ImageProcessingPostProcessId: string;
  112887. /**
  112888. * @ignore
  112889. * ID of the Fast Approximate Anti-Aliasing post process;
  112890. */
  112891. readonly FxaaPostProcessId: string;
  112892. /**
  112893. * ID of the chromatic aberration post process,
  112894. */
  112895. private readonly ChromaticAberrationPostProcessId;
  112896. /**
  112897. * ID of the grain post process
  112898. */
  112899. private readonly GrainPostProcessId;
  112900. /**
  112901. * Sharpen post process which will apply a sharpen convolution to enhance edges
  112902. */
  112903. sharpen: SharpenPostProcess;
  112904. private _sharpenEffect;
  112905. private bloom;
  112906. /**
  112907. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  112908. */
  112909. depthOfField: DepthOfFieldEffect;
  112910. /**
  112911. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  112912. */
  112913. fxaa: FxaaPostProcess;
  112914. /**
  112915. * Image post processing pass used to perform operations such as tone mapping or color grading.
  112916. */
  112917. imageProcessing: ImageProcessingPostProcess;
  112918. /**
  112919. * Chromatic aberration post process which will shift rgb colors in the image
  112920. */
  112921. chromaticAberration: ChromaticAberrationPostProcess;
  112922. private _chromaticAberrationEffect;
  112923. /**
  112924. * Grain post process which add noise to the image
  112925. */
  112926. grain: GrainPostProcess;
  112927. private _grainEffect;
  112928. /**
  112929. * Glow post process which adds a glow to emissive areas of the image
  112930. */
  112931. private _glowLayer;
  112932. /**
  112933. * Animations which can be used to tweak settings over a period of time
  112934. */
  112935. animations: Animation[];
  112936. private _imageProcessingConfigurationObserver;
  112937. private _sharpenEnabled;
  112938. private _bloomEnabled;
  112939. private _depthOfFieldEnabled;
  112940. private _depthOfFieldBlurLevel;
  112941. private _fxaaEnabled;
  112942. private _imageProcessingEnabled;
  112943. private _defaultPipelineTextureType;
  112944. private _bloomScale;
  112945. private _chromaticAberrationEnabled;
  112946. private _grainEnabled;
  112947. private _buildAllowed;
  112948. /**
  112949. * Gets active scene
  112950. */
  112951. readonly scene: Scene;
  112952. /**
  112953. * Enable or disable the sharpen process from the pipeline
  112954. */
  112955. sharpenEnabled: boolean;
  112956. private _resizeObserver;
  112957. private _hardwareScaleLevel;
  112958. private _bloomKernel;
  112959. /**
  112960. * Specifies the size of the bloom blur kernel, relative to the final output size
  112961. */
  112962. bloomKernel: number;
  112963. /**
  112964. * Specifies the weight of the bloom in the final rendering
  112965. */
  112966. private _bloomWeight;
  112967. /**
  112968. * Specifies the luma threshold for the area that will be blurred by the bloom
  112969. */
  112970. private _bloomThreshold;
  112971. private _hdr;
  112972. /**
  112973. * The strength of the bloom.
  112974. */
  112975. bloomWeight: number;
  112976. /**
  112977. * The strength of the bloom.
  112978. */
  112979. bloomThreshold: number;
  112980. /**
  112981. * The scale of the bloom, lower value will provide better performance.
  112982. */
  112983. bloomScale: number;
  112984. /**
  112985. * Enable or disable the bloom from the pipeline
  112986. */
  112987. bloomEnabled: boolean;
  112988. private _rebuildBloom;
  112989. /**
  112990. * If the depth of field is enabled.
  112991. */
  112992. depthOfFieldEnabled: boolean;
  112993. /**
  112994. * Blur level of the depth of field effect. (Higher blur will effect performance)
  112995. */
  112996. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  112997. /**
  112998. * If the anti aliasing is enabled.
  112999. */
  113000. fxaaEnabled: boolean;
  113001. private _samples;
  113002. /**
  113003. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113004. */
  113005. samples: number;
  113006. /**
  113007. * If image processing is enabled.
  113008. */
  113009. imageProcessingEnabled: boolean;
  113010. /**
  113011. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113012. */
  113013. glowLayerEnabled: boolean;
  113014. /**
  113015. * Enable or disable the chromaticAberration process from the pipeline
  113016. */
  113017. chromaticAberrationEnabled: boolean;
  113018. /**
  113019. * Enable or disable the grain process from the pipeline
  113020. */
  113021. grainEnabled: boolean;
  113022. /**
  113023. * @constructor
  113024. * @param name - The rendering pipeline name (default: "")
  113025. * @param hdr - If high dynamic range textures should be used (default: true)
  113026. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113027. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113028. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113029. */
  113030. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113031. /**
  113032. * Get the class name
  113033. * @returns "DefaultRenderingPipeline"
  113034. */
  113035. getClassName(): string;
  113036. /**
  113037. * Force the compilation of the entire pipeline.
  113038. */
  113039. prepare(): void;
  113040. private _hasCleared;
  113041. private _prevPostProcess;
  113042. private _prevPrevPostProcess;
  113043. private _setAutoClearAndTextureSharing;
  113044. private _depthOfFieldSceneObserver;
  113045. private _buildPipeline;
  113046. private _disposePostProcesses;
  113047. /**
  113048. * Adds a camera to the pipeline
  113049. * @param camera the camera to be added
  113050. */
  113051. addCamera(camera: Camera): void;
  113052. /**
  113053. * Removes a camera from the pipeline
  113054. * @param camera the camera to remove
  113055. */
  113056. removeCamera(camera: Camera): void;
  113057. /**
  113058. * Dispose of the pipeline and stop all post processes
  113059. */
  113060. dispose(): void;
  113061. /**
  113062. * Serialize the rendering pipeline (Used when exporting)
  113063. * @returns the serialized object
  113064. */
  113065. serialize(): any;
  113066. /**
  113067. * Parse the serialized pipeline
  113068. * @param source Source pipeline.
  113069. * @param scene The scene to load the pipeline to.
  113070. * @param rootUrl The URL of the serialized pipeline.
  113071. * @returns An instantiated pipeline from the serialized object.
  113072. */
  113073. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113074. }
  113075. }
  113076. declare module BABYLON {
  113077. /** @hidden */
  113078. export var lensHighlightsPixelShader: {
  113079. name: string;
  113080. shader: string;
  113081. };
  113082. }
  113083. declare module BABYLON {
  113084. /** @hidden */
  113085. export var depthOfFieldPixelShader: {
  113086. name: string;
  113087. shader: string;
  113088. };
  113089. }
  113090. declare module BABYLON {
  113091. /**
  113092. * BABYLON.JS Chromatic Aberration GLSL Shader
  113093. * Author: Olivier Guyot
  113094. * Separates very slightly R, G and B colors on the edges of the screen
  113095. * Inspired by Francois Tarlier & Martins Upitis
  113096. */
  113097. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113098. /**
  113099. * @ignore
  113100. * The chromatic aberration PostProcess id in the pipeline
  113101. */
  113102. LensChromaticAberrationEffect: string;
  113103. /**
  113104. * @ignore
  113105. * The highlights enhancing PostProcess id in the pipeline
  113106. */
  113107. HighlightsEnhancingEffect: string;
  113108. /**
  113109. * @ignore
  113110. * The depth-of-field PostProcess id in the pipeline
  113111. */
  113112. LensDepthOfFieldEffect: string;
  113113. private _scene;
  113114. private _depthTexture;
  113115. private _grainTexture;
  113116. private _chromaticAberrationPostProcess;
  113117. private _highlightsPostProcess;
  113118. private _depthOfFieldPostProcess;
  113119. private _edgeBlur;
  113120. private _grainAmount;
  113121. private _chromaticAberration;
  113122. private _distortion;
  113123. private _highlightsGain;
  113124. private _highlightsThreshold;
  113125. private _dofDistance;
  113126. private _dofAperture;
  113127. private _dofDarken;
  113128. private _dofPentagon;
  113129. private _blurNoise;
  113130. /**
  113131. * @constructor
  113132. *
  113133. * Effect parameters are as follow:
  113134. * {
  113135. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113136. * edge_blur: number; // from 0 to x (1 for realism)
  113137. * distortion: number; // from 0 to x (1 for realism)
  113138. * grain_amount: number; // from 0 to 1
  113139. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113140. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113141. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113142. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113143. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113144. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113145. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113146. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113147. * }
  113148. * Note: if an effect parameter is unset, effect is disabled
  113149. *
  113150. * @param name The rendering pipeline name
  113151. * @param parameters - An object containing all parameters (see above)
  113152. * @param scene The scene linked to this pipeline
  113153. * @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)
  113154. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113155. */
  113156. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113157. /**
  113158. * Get the class name
  113159. * @returns "LensRenderingPipeline"
  113160. */
  113161. getClassName(): string;
  113162. /**
  113163. * Gets associated scene
  113164. */
  113165. readonly scene: Scene;
  113166. /**
  113167. * Gets or sets the edge blur
  113168. */
  113169. edgeBlur: number;
  113170. /**
  113171. * Gets or sets the grain amount
  113172. */
  113173. grainAmount: number;
  113174. /**
  113175. * Gets or sets the chromatic aberration amount
  113176. */
  113177. chromaticAberration: number;
  113178. /**
  113179. * Gets or sets the depth of field aperture
  113180. */
  113181. dofAperture: number;
  113182. /**
  113183. * Gets or sets the edge distortion
  113184. */
  113185. edgeDistortion: number;
  113186. /**
  113187. * Gets or sets the depth of field distortion
  113188. */
  113189. dofDistortion: number;
  113190. /**
  113191. * Gets or sets the darken out of focus amount
  113192. */
  113193. darkenOutOfFocus: number;
  113194. /**
  113195. * Gets or sets a boolean indicating if blur noise is enabled
  113196. */
  113197. blurNoise: boolean;
  113198. /**
  113199. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113200. */
  113201. pentagonBokeh: boolean;
  113202. /**
  113203. * Gets or sets the highlight grain amount
  113204. */
  113205. highlightsGain: number;
  113206. /**
  113207. * Gets or sets the highlight threshold
  113208. */
  113209. highlightsThreshold: number;
  113210. /**
  113211. * Sets the amount of blur at the edges
  113212. * @param amount blur amount
  113213. */
  113214. setEdgeBlur(amount: number): void;
  113215. /**
  113216. * Sets edge blur to 0
  113217. */
  113218. disableEdgeBlur(): void;
  113219. /**
  113220. * Sets the amout of grain
  113221. * @param amount Amount of grain
  113222. */
  113223. setGrainAmount(amount: number): void;
  113224. /**
  113225. * Set grain amount to 0
  113226. */
  113227. disableGrain(): void;
  113228. /**
  113229. * Sets the chromatic aberration amount
  113230. * @param amount amount of chromatic aberration
  113231. */
  113232. setChromaticAberration(amount: number): void;
  113233. /**
  113234. * Sets chromatic aberration amount to 0
  113235. */
  113236. disableChromaticAberration(): void;
  113237. /**
  113238. * Sets the EdgeDistortion amount
  113239. * @param amount amount of EdgeDistortion
  113240. */
  113241. setEdgeDistortion(amount: number): void;
  113242. /**
  113243. * Sets edge distortion to 0
  113244. */
  113245. disableEdgeDistortion(): void;
  113246. /**
  113247. * Sets the FocusDistance amount
  113248. * @param amount amount of FocusDistance
  113249. */
  113250. setFocusDistance(amount: number): void;
  113251. /**
  113252. * Disables depth of field
  113253. */
  113254. disableDepthOfField(): void;
  113255. /**
  113256. * Sets the Aperture amount
  113257. * @param amount amount of Aperture
  113258. */
  113259. setAperture(amount: number): void;
  113260. /**
  113261. * Sets the DarkenOutOfFocus amount
  113262. * @param amount amount of DarkenOutOfFocus
  113263. */
  113264. setDarkenOutOfFocus(amount: number): void;
  113265. private _pentagonBokehIsEnabled;
  113266. /**
  113267. * Creates a pentagon bokeh effect
  113268. */
  113269. enablePentagonBokeh(): void;
  113270. /**
  113271. * Disables the pentagon bokeh effect
  113272. */
  113273. disablePentagonBokeh(): void;
  113274. /**
  113275. * Enables noise blur
  113276. */
  113277. enableNoiseBlur(): void;
  113278. /**
  113279. * Disables noise blur
  113280. */
  113281. disableNoiseBlur(): void;
  113282. /**
  113283. * Sets the HighlightsGain amount
  113284. * @param amount amount of HighlightsGain
  113285. */
  113286. setHighlightsGain(amount: number): void;
  113287. /**
  113288. * Sets the HighlightsThreshold amount
  113289. * @param amount amount of HighlightsThreshold
  113290. */
  113291. setHighlightsThreshold(amount: number): void;
  113292. /**
  113293. * Disables highlights
  113294. */
  113295. disableHighlights(): void;
  113296. /**
  113297. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113298. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113299. */
  113300. dispose(disableDepthRender?: boolean): void;
  113301. private _createChromaticAberrationPostProcess;
  113302. private _createHighlightsPostProcess;
  113303. private _createDepthOfFieldPostProcess;
  113304. private _createGrainTexture;
  113305. }
  113306. }
  113307. declare module BABYLON {
  113308. /** @hidden */
  113309. export var ssao2PixelShader: {
  113310. name: string;
  113311. shader: string;
  113312. };
  113313. }
  113314. declare module BABYLON {
  113315. /** @hidden */
  113316. export var ssaoCombinePixelShader: {
  113317. name: string;
  113318. shader: string;
  113319. };
  113320. }
  113321. declare module BABYLON {
  113322. /**
  113323. * Render pipeline to produce ssao effect
  113324. */
  113325. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113326. /**
  113327. * @ignore
  113328. * The PassPostProcess id in the pipeline that contains the original scene color
  113329. */
  113330. SSAOOriginalSceneColorEffect: string;
  113331. /**
  113332. * @ignore
  113333. * The SSAO PostProcess id in the pipeline
  113334. */
  113335. SSAORenderEffect: string;
  113336. /**
  113337. * @ignore
  113338. * The horizontal blur PostProcess id in the pipeline
  113339. */
  113340. SSAOBlurHRenderEffect: string;
  113341. /**
  113342. * @ignore
  113343. * The vertical blur PostProcess id in the pipeline
  113344. */
  113345. SSAOBlurVRenderEffect: string;
  113346. /**
  113347. * @ignore
  113348. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113349. */
  113350. SSAOCombineRenderEffect: string;
  113351. /**
  113352. * The output strength of the SSAO post-process. Default value is 1.0.
  113353. */
  113354. totalStrength: number;
  113355. /**
  113356. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113357. */
  113358. maxZ: number;
  113359. /**
  113360. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113361. */
  113362. minZAspect: number;
  113363. private _samples;
  113364. /**
  113365. * Number of samples used for the SSAO calculations. Default value is 8
  113366. */
  113367. samples: number;
  113368. private _textureSamples;
  113369. /**
  113370. * Number of samples to use for antialiasing
  113371. */
  113372. textureSamples: number;
  113373. /**
  113374. * Ratio object used for SSAO ratio and blur ratio
  113375. */
  113376. private _ratio;
  113377. /**
  113378. * Dynamically generated sphere sampler.
  113379. */
  113380. private _sampleSphere;
  113381. /**
  113382. * Blur filter offsets
  113383. */
  113384. private _samplerOffsets;
  113385. private _expensiveBlur;
  113386. /**
  113387. * If bilateral blur should be used
  113388. */
  113389. expensiveBlur: boolean;
  113390. /**
  113391. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113392. */
  113393. radius: number;
  113394. /**
  113395. * The base color of the SSAO post-process
  113396. * The final result is "base + ssao" between [0, 1]
  113397. */
  113398. base: number;
  113399. /**
  113400. * Support test.
  113401. */
  113402. static readonly IsSupported: boolean;
  113403. private _scene;
  113404. private _depthTexture;
  113405. private _normalTexture;
  113406. private _randomTexture;
  113407. private _originalColorPostProcess;
  113408. private _ssaoPostProcess;
  113409. private _blurHPostProcess;
  113410. private _blurVPostProcess;
  113411. private _ssaoCombinePostProcess;
  113412. private _firstUpdate;
  113413. /**
  113414. * Gets active scene
  113415. */
  113416. readonly scene: Scene;
  113417. /**
  113418. * @constructor
  113419. * @param name The rendering pipeline name
  113420. * @param scene The scene linked to this pipeline
  113421. * @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 }
  113422. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113423. */
  113424. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113425. /**
  113426. * Get the class name
  113427. * @returns "SSAO2RenderingPipeline"
  113428. */
  113429. getClassName(): string;
  113430. /**
  113431. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113432. */
  113433. dispose(disableGeometryBufferRenderer?: boolean): void;
  113434. private _createBlurPostProcess;
  113435. /** @hidden */
  113436. _rebuild(): void;
  113437. private _bits;
  113438. private _radicalInverse_VdC;
  113439. private _hammersley;
  113440. private _hemisphereSample_uniform;
  113441. private _generateHemisphere;
  113442. private _createSSAOPostProcess;
  113443. private _createSSAOCombinePostProcess;
  113444. private _createRandomTexture;
  113445. /**
  113446. * Serialize the rendering pipeline (Used when exporting)
  113447. * @returns the serialized object
  113448. */
  113449. serialize(): any;
  113450. /**
  113451. * Parse the serialized pipeline
  113452. * @param source Source pipeline.
  113453. * @param scene The scene to load the pipeline to.
  113454. * @param rootUrl The URL of the serialized pipeline.
  113455. * @returns An instantiated pipeline from the serialized object.
  113456. */
  113457. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  113458. }
  113459. }
  113460. declare module BABYLON {
  113461. /** @hidden */
  113462. export var ssaoPixelShader: {
  113463. name: string;
  113464. shader: string;
  113465. };
  113466. }
  113467. declare module BABYLON {
  113468. /**
  113469. * Render pipeline to produce ssao effect
  113470. */
  113471. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  113472. /**
  113473. * @ignore
  113474. * The PassPostProcess id in the pipeline that contains the original scene color
  113475. */
  113476. SSAOOriginalSceneColorEffect: string;
  113477. /**
  113478. * @ignore
  113479. * The SSAO PostProcess id in the pipeline
  113480. */
  113481. SSAORenderEffect: string;
  113482. /**
  113483. * @ignore
  113484. * The horizontal blur PostProcess id in the pipeline
  113485. */
  113486. SSAOBlurHRenderEffect: string;
  113487. /**
  113488. * @ignore
  113489. * The vertical blur PostProcess id in the pipeline
  113490. */
  113491. SSAOBlurVRenderEffect: string;
  113492. /**
  113493. * @ignore
  113494. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113495. */
  113496. SSAOCombineRenderEffect: string;
  113497. /**
  113498. * The output strength of the SSAO post-process. Default value is 1.0.
  113499. */
  113500. totalStrength: number;
  113501. /**
  113502. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  113503. */
  113504. radius: number;
  113505. /**
  113506. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  113507. * Must not be equal to fallOff and superior to fallOff.
  113508. * Default value is 0.0075
  113509. */
  113510. area: number;
  113511. /**
  113512. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  113513. * Must not be equal to area and inferior to area.
  113514. * Default value is 0.000001
  113515. */
  113516. fallOff: number;
  113517. /**
  113518. * The base color of the SSAO post-process
  113519. * The final result is "base + ssao" between [0, 1]
  113520. */
  113521. base: number;
  113522. private _scene;
  113523. private _depthTexture;
  113524. private _randomTexture;
  113525. private _originalColorPostProcess;
  113526. private _ssaoPostProcess;
  113527. private _blurHPostProcess;
  113528. private _blurVPostProcess;
  113529. private _ssaoCombinePostProcess;
  113530. private _firstUpdate;
  113531. /**
  113532. * Gets active scene
  113533. */
  113534. readonly scene: Scene;
  113535. /**
  113536. * @constructor
  113537. * @param name - The rendering pipeline name
  113538. * @param scene - The scene linked to this pipeline
  113539. * @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 }
  113540. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113541. */
  113542. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113543. /**
  113544. * Get the class name
  113545. * @returns "SSAORenderingPipeline"
  113546. */
  113547. getClassName(): string;
  113548. /**
  113549. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113550. */
  113551. dispose(disableDepthRender?: boolean): void;
  113552. private _createBlurPostProcess;
  113553. /** @hidden */
  113554. _rebuild(): void;
  113555. private _createSSAOPostProcess;
  113556. private _createSSAOCombinePostProcess;
  113557. private _createRandomTexture;
  113558. }
  113559. }
  113560. declare module BABYLON {
  113561. /** @hidden */
  113562. export var standardPixelShader: {
  113563. name: string;
  113564. shader: string;
  113565. };
  113566. }
  113567. declare module BABYLON {
  113568. /**
  113569. * Standard rendering pipeline
  113570. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113571. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113572. */
  113573. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113574. /**
  113575. * Public members
  113576. */
  113577. /**
  113578. * Post-process which contains the original scene color before the pipeline applies all the effects
  113579. */
  113580. originalPostProcess: Nullable<PostProcess>;
  113581. /**
  113582. * Post-process used to down scale an image x4
  113583. */
  113584. downSampleX4PostProcess: Nullable<PostProcess>;
  113585. /**
  113586. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113587. */
  113588. brightPassPostProcess: Nullable<PostProcess>;
  113589. /**
  113590. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113591. */
  113592. blurHPostProcesses: PostProcess[];
  113593. /**
  113594. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113595. */
  113596. blurVPostProcesses: PostProcess[];
  113597. /**
  113598. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113599. */
  113600. textureAdderPostProcess: Nullable<PostProcess>;
  113601. /**
  113602. * Post-process used to create volumetric lighting effect
  113603. */
  113604. volumetricLightPostProcess: Nullable<PostProcess>;
  113605. /**
  113606. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113607. */
  113608. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  113609. /**
  113610. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113611. */
  113612. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  113613. /**
  113614. * Post-process used to merge the volumetric light effect and the real scene color
  113615. */
  113616. volumetricLightMergePostProces: Nullable<PostProcess>;
  113617. /**
  113618. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113619. */
  113620. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  113621. /**
  113622. * Base post-process used to calculate the average luminance of the final image for HDR
  113623. */
  113624. luminancePostProcess: Nullable<PostProcess>;
  113625. /**
  113626. * Post-processes used to create down sample post-processes in order to get
  113627. * the average luminance of the final image for HDR
  113628. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113629. */
  113630. luminanceDownSamplePostProcesses: PostProcess[];
  113631. /**
  113632. * Post-process used to create a HDR effect (light adaptation)
  113633. */
  113634. hdrPostProcess: Nullable<PostProcess>;
  113635. /**
  113636. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113637. */
  113638. textureAdderFinalPostProcess: Nullable<PostProcess>;
  113639. /**
  113640. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113641. */
  113642. lensFlareFinalPostProcess: Nullable<PostProcess>;
  113643. /**
  113644. * Post-process used to merge the final HDR post-process and the real scene color
  113645. */
  113646. hdrFinalPostProcess: Nullable<PostProcess>;
  113647. /**
  113648. * Post-process used to create a lens flare effect
  113649. */
  113650. lensFlarePostProcess: Nullable<PostProcess>;
  113651. /**
  113652. * Post-process that merges the result of the lens flare post-process and the real scene color
  113653. */
  113654. lensFlareComposePostProcess: Nullable<PostProcess>;
  113655. /**
  113656. * Post-process used to create a motion blur effect
  113657. */
  113658. motionBlurPostProcess: Nullable<PostProcess>;
  113659. /**
  113660. * Post-process used to create a depth of field effect
  113661. */
  113662. depthOfFieldPostProcess: Nullable<PostProcess>;
  113663. /**
  113664. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113665. */
  113666. fxaaPostProcess: Nullable<FxaaPostProcess>;
  113667. /**
  113668. * Represents the brightness threshold in order to configure the illuminated surfaces
  113669. */
  113670. brightThreshold: number;
  113671. /**
  113672. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113673. */
  113674. blurWidth: number;
  113675. /**
  113676. * Sets if the blur for highlighted surfaces must be only horizontal
  113677. */
  113678. horizontalBlur: boolean;
  113679. /**
  113680. * Gets the overall exposure used by the pipeline
  113681. */
  113682. /**
  113683. * Sets the overall exposure used by the pipeline
  113684. */
  113685. exposure: number;
  113686. /**
  113687. * Texture used typically to simulate "dirty" on camera lens
  113688. */
  113689. lensTexture: Nullable<Texture>;
  113690. /**
  113691. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113692. */
  113693. volumetricLightCoefficient: number;
  113694. /**
  113695. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113696. */
  113697. volumetricLightPower: number;
  113698. /**
  113699. * Used the set the blur intensity to smooth the volumetric lights
  113700. */
  113701. volumetricLightBlurScale: number;
  113702. /**
  113703. * Light (spot or directional) used to generate the volumetric lights rays
  113704. * The source light must have a shadow generate so the pipeline can get its
  113705. * depth map
  113706. */
  113707. sourceLight: Nullable<SpotLight | DirectionalLight>;
  113708. /**
  113709. * For eye adaptation, represents the minimum luminance the eye can see
  113710. */
  113711. hdrMinimumLuminance: number;
  113712. /**
  113713. * For eye adaptation, represents the decrease luminance speed
  113714. */
  113715. hdrDecreaseRate: number;
  113716. /**
  113717. * For eye adaptation, represents the increase luminance speed
  113718. */
  113719. hdrIncreaseRate: number;
  113720. /**
  113721. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113722. */
  113723. /**
  113724. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113725. */
  113726. hdrAutoExposure: boolean;
  113727. /**
  113728. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113729. */
  113730. lensColorTexture: Nullable<Texture>;
  113731. /**
  113732. * The overall strengh for the lens flare effect
  113733. */
  113734. lensFlareStrength: number;
  113735. /**
  113736. * Dispersion coefficient for lens flare ghosts
  113737. */
  113738. lensFlareGhostDispersal: number;
  113739. /**
  113740. * Main lens flare halo width
  113741. */
  113742. lensFlareHaloWidth: number;
  113743. /**
  113744. * Based on the lens distortion effect, defines how much the lens flare result
  113745. * is distorted
  113746. */
  113747. lensFlareDistortionStrength: number;
  113748. /**
  113749. * Lens star texture must be used to simulate rays on the flares and is available
  113750. * in the documentation
  113751. */
  113752. lensStarTexture: Nullable<Texture>;
  113753. /**
  113754. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113755. * flare effect by taking account of the dirt texture
  113756. */
  113757. lensFlareDirtTexture: Nullable<Texture>;
  113758. /**
  113759. * Represents the focal length for the depth of field effect
  113760. */
  113761. depthOfFieldDistance: number;
  113762. /**
  113763. * Represents the blur intensity for the blurred part of the depth of field effect
  113764. */
  113765. depthOfFieldBlurWidth: number;
  113766. /**
  113767. * For motion blur, defines how much the image is blurred by the movement
  113768. */
  113769. motionStrength: number;
  113770. /**
  113771. * List of animations for the pipeline (IAnimatable implementation)
  113772. */
  113773. animations: Animation[];
  113774. /**
  113775. * Private members
  113776. */
  113777. private _scene;
  113778. private _currentDepthOfFieldSource;
  113779. private _basePostProcess;
  113780. private _fixedExposure;
  113781. private _currentExposure;
  113782. private _hdrAutoExposure;
  113783. private _hdrCurrentLuminance;
  113784. private _floatTextureType;
  113785. private _ratio;
  113786. private _bloomEnabled;
  113787. private _depthOfFieldEnabled;
  113788. private _vlsEnabled;
  113789. private _lensFlareEnabled;
  113790. private _hdrEnabled;
  113791. private _motionBlurEnabled;
  113792. private _fxaaEnabled;
  113793. private _motionBlurSamples;
  113794. private _volumetricLightStepsCount;
  113795. private _samples;
  113796. /**
  113797. * @ignore
  113798. * Specifies if the bloom pipeline is enabled
  113799. */
  113800. BloomEnabled: boolean;
  113801. /**
  113802. * @ignore
  113803. * Specifies if the depth of field pipeline is enabed
  113804. */
  113805. DepthOfFieldEnabled: boolean;
  113806. /**
  113807. * @ignore
  113808. * Specifies if the lens flare pipeline is enabed
  113809. */
  113810. LensFlareEnabled: boolean;
  113811. /**
  113812. * @ignore
  113813. * Specifies if the HDR pipeline is enabled
  113814. */
  113815. HDREnabled: boolean;
  113816. /**
  113817. * @ignore
  113818. * Specifies if the volumetric lights scattering effect is enabled
  113819. */
  113820. VLSEnabled: boolean;
  113821. /**
  113822. * @ignore
  113823. * Specifies if the motion blur effect is enabled
  113824. */
  113825. MotionBlurEnabled: boolean;
  113826. /**
  113827. * Specifies if anti-aliasing is enabled
  113828. */
  113829. fxaaEnabled: boolean;
  113830. /**
  113831. * Specifies the number of steps used to calculate the volumetric lights
  113832. * Typically in interval [50, 200]
  113833. */
  113834. volumetricLightStepsCount: number;
  113835. /**
  113836. * Specifies the number of samples used for the motion blur effect
  113837. * Typically in interval [16, 64]
  113838. */
  113839. motionBlurSamples: number;
  113840. /**
  113841. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113842. */
  113843. samples: number;
  113844. /**
  113845. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113846. * @constructor
  113847. * @param name The rendering pipeline name
  113848. * @param scene The scene linked to this pipeline
  113849. * @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)
  113850. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  113851. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113852. */
  113853. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  113854. private _buildPipeline;
  113855. private _createDownSampleX4PostProcess;
  113856. private _createBrightPassPostProcess;
  113857. private _createBlurPostProcesses;
  113858. private _createTextureAdderPostProcess;
  113859. private _createVolumetricLightPostProcess;
  113860. private _createLuminancePostProcesses;
  113861. private _createHdrPostProcess;
  113862. private _createLensFlarePostProcess;
  113863. private _createDepthOfFieldPostProcess;
  113864. private _createMotionBlurPostProcess;
  113865. private _getDepthTexture;
  113866. private _disposePostProcesses;
  113867. /**
  113868. * Dispose of the pipeline and stop all post processes
  113869. */
  113870. dispose(): void;
  113871. /**
  113872. * Serialize the rendering pipeline (Used when exporting)
  113873. * @returns the serialized object
  113874. */
  113875. serialize(): any;
  113876. /**
  113877. * Parse the serialized pipeline
  113878. * @param source Source pipeline.
  113879. * @param scene The scene to load the pipeline to.
  113880. * @param rootUrl The URL of the serialized pipeline.
  113881. * @returns An instantiated pipeline from the serialized object.
  113882. */
  113883. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  113884. /**
  113885. * Luminance steps
  113886. */
  113887. static LuminanceSteps: number;
  113888. }
  113889. }
  113890. declare module BABYLON {
  113891. /** @hidden */
  113892. export var tonemapPixelShader: {
  113893. name: string;
  113894. shader: string;
  113895. };
  113896. }
  113897. declare module BABYLON {
  113898. /** Defines operator used for tonemapping */
  113899. export enum TonemappingOperator {
  113900. /** Hable */
  113901. Hable = 0,
  113902. /** Reinhard */
  113903. Reinhard = 1,
  113904. /** HejiDawson */
  113905. HejiDawson = 2,
  113906. /** Photographic */
  113907. Photographic = 3
  113908. }
  113909. /**
  113910. * Defines a post process to apply tone mapping
  113911. */
  113912. export class TonemapPostProcess extends PostProcess {
  113913. private _operator;
  113914. /** Defines the required exposure adjustement */
  113915. exposureAdjustment: number;
  113916. /**
  113917. * Creates a new TonemapPostProcess
  113918. * @param name defines the name of the postprocess
  113919. * @param _operator defines the operator to use
  113920. * @param exposureAdjustment defines the required exposure adjustement
  113921. * @param camera defines the camera to use (can be null)
  113922. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  113923. * @param engine defines the hosting engine (can be ignore if camera is set)
  113924. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113925. */
  113926. constructor(name: string, _operator: TonemappingOperator,
  113927. /** Defines the required exposure adjustement */
  113928. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  113929. }
  113930. }
  113931. declare module BABYLON {
  113932. /** @hidden */
  113933. export var depthVertexShader: {
  113934. name: string;
  113935. shader: string;
  113936. };
  113937. }
  113938. declare module BABYLON {
  113939. /** @hidden */
  113940. export var volumetricLightScatteringPixelShader: {
  113941. name: string;
  113942. shader: string;
  113943. };
  113944. }
  113945. declare module BABYLON {
  113946. /** @hidden */
  113947. export var volumetricLightScatteringPassPixelShader: {
  113948. name: string;
  113949. shader: string;
  113950. };
  113951. }
  113952. declare module BABYLON {
  113953. /**
  113954. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  113955. */
  113956. export class VolumetricLightScatteringPostProcess extends PostProcess {
  113957. private _volumetricLightScatteringPass;
  113958. private _volumetricLightScatteringRTT;
  113959. private _viewPort;
  113960. private _screenCoordinates;
  113961. private _cachedDefines;
  113962. /**
  113963. * If not undefined, the mesh position is computed from the attached node position
  113964. */
  113965. attachedNode: {
  113966. position: Vector3;
  113967. };
  113968. /**
  113969. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  113970. */
  113971. customMeshPosition: Vector3;
  113972. /**
  113973. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  113974. */
  113975. useCustomMeshPosition: boolean;
  113976. /**
  113977. * If the post-process should inverse the light scattering direction
  113978. */
  113979. invert: boolean;
  113980. /**
  113981. * The internal mesh used by the post-process
  113982. */
  113983. mesh: Mesh;
  113984. /**
  113985. * @hidden
  113986. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  113987. */
  113988. useDiffuseColor: boolean;
  113989. /**
  113990. * Array containing the excluded meshes not rendered in the internal pass
  113991. */
  113992. excludedMeshes: AbstractMesh[];
  113993. /**
  113994. * Controls the overall intensity of the post-process
  113995. */
  113996. exposure: number;
  113997. /**
  113998. * Dissipates each sample's contribution in range [0, 1]
  113999. */
  114000. decay: number;
  114001. /**
  114002. * Controls the overall intensity of each sample
  114003. */
  114004. weight: number;
  114005. /**
  114006. * Controls the density of each sample
  114007. */
  114008. density: number;
  114009. /**
  114010. * @constructor
  114011. * @param name The post-process name
  114012. * @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)
  114013. * @param camera The camera that the post-process will be attached to
  114014. * @param mesh The mesh used to create the light scattering
  114015. * @param samples The post-process quality, default 100
  114016. * @param samplingModeThe post-process filtering mode
  114017. * @param engine The babylon engine
  114018. * @param reusable If the post-process is reusable
  114019. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114020. */
  114021. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114022. /**
  114023. * Returns the string "VolumetricLightScatteringPostProcess"
  114024. * @returns "VolumetricLightScatteringPostProcess"
  114025. */
  114026. getClassName(): string;
  114027. private _isReady;
  114028. /**
  114029. * Sets the new light position for light scattering effect
  114030. * @param position The new custom light position
  114031. */
  114032. setCustomMeshPosition(position: Vector3): void;
  114033. /**
  114034. * Returns the light position for light scattering effect
  114035. * @return Vector3 The custom light position
  114036. */
  114037. getCustomMeshPosition(): Vector3;
  114038. /**
  114039. * Disposes the internal assets and detaches the post-process from the camera
  114040. */
  114041. dispose(camera: Camera): void;
  114042. /**
  114043. * Returns the render target texture used by the post-process
  114044. * @return the render target texture used by the post-process
  114045. */
  114046. getPass(): RenderTargetTexture;
  114047. private _meshExcluded;
  114048. private _createPass;
  114049. private _updateMeshScreenCoordinates;
  114050. /**
  114051. * Creates a default mesh for the Volumeric Light Scattering post-process
  114052. * @param name The mesh name
  114053. * @param scene The scene where to create the mesh
  114054. * @return the default mesh
  114055. */
  114056. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114057. }
  114058. }
  114059. declare module BABYLON {
  114060. interface Scene {
  114061. /** @hidden (Backing field) */
  114062. _boundingBoxRenderer: BoundingBoxRenderer;
  114063. /** @hidden (Backing field) */
  114064. _forceShowBoundingBoxes: boolean;
  114065. /**
  114066. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114067. */
  114068. forceShowBoundingBoxes: boolean;
  114069. /**
  114070. * Gets the bounding box renderer associated with the scene
  114071. * @returns a BoundingBoxRenderer
  114072. */
  114073. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114074. }
  114075. interface AbstractMesh {
  114076. /** @hidden (Backing field) */
  114077. _showBoundingBox: boolean;
  114078. /**
  114079. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114080. */
  114081. showBoundingBox: boolean;
  114082. }
  114083. /**
  114084. * Component responsible of rendering the bounding box of the meshes in a scene.
  114085. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114086. */
  114087. export class BoundingBoxRenderer implements ISceneComponent {
  114088. /**
  114089. * The component name helpfull to identify the component in the list of scene components.
  114090. */
  114091. readonly name: string;
  114092. /**
  114093. * The scene the component belongs to.
  114094. */
  114095. scene: Scene;
  114096. /**
  114097. * Color of the bounding box lines placed in front of an object
  114098. */
  114099. frontColor: Color3;
  114100. /**
  114101. * Color of the bounding box lines placed behind an object
  114102. */
  114103. backColor: Color3;
  114104. /**
  114105. * Defines if the renderer should show the back lines or not
  114106. */
  114107. showBackLines: boolean;
  114108. /**
  114109. * @hidden
  114110. */
  114111. renderList: SmartArray<BoundingBox>;
  114112. private _colorShader;
  114113. private _vertexBuffers;
  114114. private _indexBuffer;
  114115. /**
  114116. * Instantiates a new bounding box renderer in a scene.
  114117. * @param scene the scene the renderer renders in
  114118. */
  114119. constructor(scene: Scene);
  114120. /**
  114121. * Registers the component in a given scene
  114122. */
  114123. register(): void;
  114124. private _evaluateSubMesh;
  114125. private _activeMesh;
  114126. private _prepareRessources;
  114127. private _createIndexBuffer;
  114128. /**
  114129. * Rebuilds the elements related to this component in case of
  114130. * context lost for instance.
  114131. */
  114132. rebuild(): void;
  114133. /**
  114134. * @hidden
  114135. */
  114136. reset(): void;
  114137. /**
  114138. * Render the bounding boxes of a specific rendering group
  114139. * @param renderingGroupId defines the rendering group to render
  114140. */
  114141. render(renderingGroupId: number): void;
  114142. /**
  114143. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114144. * @param mesh Define the mesh to render the occlusion bounding box for
  114145. */
  114146. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114147. /**
  114148. * Dispose and release the resources attached to this renderer.
  114149. */
  114150. dispose(): void;
  114151. }
  114152. }
  114153. declare module BABYLON {
  114154. /** @hidden */
  114155. export var depthPixelShader: {
  114156. name: string;
  114157. shader: string;
  114158. };
  114159. }
  114160. declare module BABYLON {
  114161. /**
  114162. * This represents a depth renderer in Babylon.
  114163. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114164. */
  114165. export class DepthRenderer {
  114166. private _scene;
  114167. private _depthMap;
  114168. private _effect;
  114169. private _cachedDefines;
  114170. private _camera;
  114171. /**
  114172. * Specifiess that the depth renderer will only be used within
  114173. * the camera it is created for.
  114174. * This can help forcing its rendering during the camera processing.
  114175. */
  114176. useOnlyInActiveCamera: boolean;
  114177. /** @hidden */
  114178. static _SceneComponentInitialization: (scene: Scene) => void;
  114179. /**
  114180. * Instantiates a depth renderer
  114181. * @param scene The scene the renderer belongs to
  114182. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114183. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114184. */
  114185. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114186. /**
  114187. * Creates the depth rendering effect and checks if the effect is ready.
  114188. * @param subMesh The submesh to be used to render the depth map of
  114189. * @param useInstances If multiple world instances should be used
  114190. * @returns if the depth renderer is ready to render the depth map
  114191. */
  114192. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114193. /**
  114194. * Gets the texture which the depth map will be written to.
  114195. * @returns The depth map texture
  114196. */
  114197. getDepthMap(): RenderTargetTexture;
  114198. /**
  114199. * Disposes of the depth renderer.
  114200. */
  114201. dispose(): void;
  114202. }
  114203. }
  114204. declare module BABYLON {
  114205. interface Scene {
  114206. /** @hidden (Backing field) */
  114207. _depthRenderer: {
  114208. [id: string]: DepthRenderer;
  114209. };
  114210. /**
  114211. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114212. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114213. * @returns the created depth renderer
  114214. */
  114215. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114216. /**
  114217. * Disables a depth renderer for a given camera
  114218. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114219. */
  114220. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114221. }
  114222. /**
  114223. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114224. * in several rendering techniques.
  114225. */
  114226. export class DepthRendererSceneComponent implements ISceneComponent {
  114227. /**
  114228. * The component name helpfull to identify the component in the list of scene components.
  114229. */
  114230. readonly name: string;
  114231. /**
  114232. * The scene the component belongs to.
  114233. */
  114234. scene: Scene;
  114235. /**
  114236. * Creates a new instance of the component for the given scene
  114237. * @param scene Defines the scene to register the component in
  114238. */
  114239. constructor(scene: Scene);
  114240. /**
  114241. * Registers the component in a given scene
  114242. */
  114243. register(): void;
  114244. /**
  114245. * Rebuilds the elements related to this component in case of
  114246. * context lost for instance.
  114247. */
  114248. rebuild(): void;
  114249. /**
  114250. * Disposes the component and the associated ressources
  114251. */
  114252. dispose(): void;
  114253. private _gatherRenderTargets;
  114254. private _gatherActiveCameraRenderTargets;
  114255. }
  114256. }
  114257. declare module BABYLON {
  114258. /** @hidden */
  114259. export var outlinePixelShader: {
  114260. name: string;
  114261. shader: string;
  114262. };
  114263. }
  114264. declare module BABYLON {
  114265. /** @hidden */
  114266. export var outlineVertexShader: {
  114267. name: string;
  114268. shader: string;
  114269. };
  114270. }
  114271. declare module BABYLON {
  114272. interface Scene {
  114273. /** @hidden */
  114274. _outlineRenderer: OutlineRenderer;
  114275. /**
  114276. * Gets the outline renderer associated with the scene
  114277. * @returns a OutlineRenderer
  114278. */
  114279. getOutlineRenderer(): OutlineRenderer;
  114280. }
  114281. interface AbstractMesh {
  114282. /** @hidden (Backing field) */
  114283. _renderOutline: boolean;
  114284. /**
  114285. * Gets or sets a boolean indicating if the outline must be rendered as well
  114286. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114287. */
  114288. renderOutline: boolean;
  114289. /** @hidden (Backing field) */
  114290. _renderOverlay: boolean;
  114291. /**
  114292. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114293. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114294. */
  114295. renderOverlay: boolean;
  114296. }
  114297. /**
  114298. * This class is responsible to draw bothe outline/overlay of meshes.
  114299. * It should not be used directly but through the available method on mesh.
  114300. */
  114301. export class OutlineRenderer implements ISceneComponent {
  114302. /**
  114303. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114304. */
  114305. private static _StencilReference;
  114306. /**
  114307. * The name of the component. Each component must have a unique name.
  114308. */
  114309. name: string;
  114310. /**
  114311. * The scene the component belongs to.
  114312. */
  114313. scene: Scene;
  114314. /**
  114315. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114316. */
  114317. zOffset: number;
  114318. private _engine;
  114319. private _effect;
  114320. private _cachedDefines;
  114321. private _savedDepthWrite;
  114322. /**
  114323. * Instantiates a new outline renderer. (There could be only one per scene).
  114324. * @param scene Defines the scene it belongs to
  114325. */
  114326. constructor(scene: Scene);
  114327. /**
  114328. * Register the component to one instance of a scene.
  114329. */
  114330. register(): void;
  114331. /**
  114332. * Rebuilds the elements related to this component in case of
  114333. * context lost for instance.
  114334. */
  114335. rebuild(): void;
  114336. /**
  114337. * Disposes the component and the associated ressources.
  114338. */
  114339. dispose(): void;
  114340. /**
  114341. * Renders the outline in the canvas.
  114342. * @param subMesh Defines the sumesh to render
  114343. * @param batch Defines the batch of meshes in case of instances
  114344. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114345. */
  114346. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114347. /**
  114348. * Returns whether or not the outline renderer is ready for a given submesh.
  114349. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114350. * @param subMesh Defines the submesh to check readyness for
  114351. * @param useInstances Defines wheter wee are trying to render instances or not
  114352. * @returns true if ready otherwise false
  114353. */
  114354. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114355. private _beforeRenderingMesh;
  114356. private _afterRenderingMesh;
  114357. }
  114358. }
  114359. declare module BABYLON {
  114360. /**
  114361. * Defines the list of states available for a task inside a AssetsManager
  114362. */
  114363. export enum AssetTaskState {
  114364. /**
  114365. * Initialization
  114366. */
  114367. INIT = 0,
  114368. /**
  114369. * Running
  114370. */
  114371. RUNNING = 1,
  114372. /**
  114373. * Done
  114374. */
  114375. DONE = 2,
  114376. /**
  114377. * Error
  114378. */
  114379. ERROR = 3
  114380. }
  114381. /**
  114382. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  114383. */
  114384. export abstract class AbstractAssetTask {
  114385. /**
  114386. * Task name
  114387. */ name: string;
  114388. /**
  114389. * Callback called when the task is successful
  114390. */
  114391. onSuccess: (task: any) => void;
  114392. /**
  114393. * Callback called when the task is not successful
  114394. */
  114395. onError: (task: any, message?: string, exception?: any) => void;
  114396. /**
  114397. * Creates a new AssetsManager
  114398. * @param name defines the name of the task
  114399. */
  114400. constructor(
  114401. /**
  114402. * Task name
  114403. */ name: string);
  114404. private _isCompleted;
  114405. private _taskState;
  114406. private _errorObject;
  114407. /**
  114408. * Get if the task is completed
  114409. */
  114410. readonly isCompleted: boolean;
  114411. /**
  114412. * Gets the current state of the task
  114413. */
  114414. readonly taskState: AssetTaskState;
  114415. /**
  114416. * Gets the current error object (if task is in error)
  114417. */
  114418. readonly errorObject: {
  114419. message?: string;
  114420. exception?: any;
  114421. };
  114422. /**
  114423. * Internal only
  114424. * @hidden
  114425. */
  114426. _setErrorObject(message?: string, exception?: any): void;
  114427. /**
  114428. * Execute the current task
  114429. * @param scene defines the scene where you want your assets to be loaded
  114430. * @param onSuccess is a callback called when the task is successfully executed
  114431. * @param onError is a callback called if an error occurs
  114432. */
  114433. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114434. /**
  114435. * Execute the current task
  114436. * @param scene defines the scene where you want your assets to be loaded
  114437. * @param onSuccess is a callback called when the task is successfully executed
  114438. * @param onError is a callback called if an error occurs
  114439. */
  114440. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114441. /**
  114442. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114443. * This can be used with failed tasks that have the reason for failure fixed.
  114444. */
  114445. reset(): void;
  114446. private onErrorCallback;
  114447. private onDoneCallback;
  114448. }
  114449. /**
  114450. * Define the interface used by progress events raised during assets loading
  114451. */
  114452. export interface IAssetsProgressEvent {
  114453. /**
  114454. * Defines the number of remaining tasks to process
  114455. */
  114456. remainingCount: number;
  114457. /**
  114458. * Defines the total number of tasks
  114459. */
  114460. totalCount: number;
  114461. /**
  114462. * Defines the task that was just processed
  114463. */
  114464. task: AbstractAssetTask;
  114465. }
  114466. /**
  114467. * Class used to share progress information about assets loading
  114468. */
  114469. export class AssetsProgressEvent implements IAssetsProgressEvent {
  114470. /**
  114471. * Defines the number of remaining tasks to process
  114472. */
  114473. remainingCount: number;
  114474. /**
  114475. * Defines the total number of tasks
  114476. */
  114477. totalCount: number;
  114478. /**
  114479. * Defines the task that was just processed
  114480. */
  114481. task: AbstractAssetTask;
  114482. /**
  114483. * Creates a AssetsProgressEvent
  114484. * @param remainingCount defines the number of remaining tasks to process
  114485. * @param totalCount defines the total number of tasks
  114486. * @param task defines the task that was just processed
  114487. */
  114488. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  114489. }
  114490. /**
  114491. * Define a task used by AssetsManager to load meshes
  114492. */
  114493. export class MeshAssetTask extends AbstractAssetTask {
  114494. /**
  114495. * Defines the name of the task
  114496. */
  114497. name: string;
  114498. /**
  114499. * Defines the list of mesh's names you want to load
  114500. */
  114501. meshesNames: any;
  114502. /**
  114503. * Defines the root url to use as a base to load your meshes and associated resources
  114504. */
  114505. rootUrl: string;
  114506. /**
  114507. * Defines the filename of the scene to load from
  114508. */
  114509. sceneFilename: string;
  114510. /**
  114511. * Gets the list of loaded meshes
  114512. */
  114513. loadedMeshes: Array<AbstractMesh>;
  114514. /**
  114515. * Gets the list of loaded particle systems
  114516. */
  114517. loadedParticleSystems: Array<IParticleSystem>;
  114518. /**
  114519. * Gets the list of loaded skeletons
  114520. */
  114521. loadedSkeletons: Array<Skeleton>;
  114522. /**
  114523. * Gets the list of loaded animation groups
  114524. */
  114525. loadedAnimationGroups: Array<AnimationGroup>;
  114526. /**
  114527. * Callback called when the task is successful
  114528. */
  114529. onSuccess: (task: MeshAssetTask) => void;
  114530. /**
  114531. * Callback called when the task is successful
  114532. */
  114533. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  114534. /**
  114535. * Creates a new MeshAssetTask
  114536. * @param name defines the name of the task
  114537. * @param meshesNames defines the list of mesh's names you want to load
  114538. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  114539. * @param sceneFilename defines the filename of the scene to load from
  114540. */
  114541. constructor(
  114542. /**
  114543. * Defines the name of the task
  114544. */
  114545. name: string,
  114546. /**
  114547. * Defines the list of mesh's names you want to load
  114548. */
  114549. meshesNames: any,
  114550. /**
  114551. * Defines the root url to use as a base to load your meshes and associated resources
  114552. */
  114553. rootUrl: string,
  114554. /**
  114555. * Defines the filename of the scene to load from
  114556. */
  114557. sceneFilename: string);
  114558. /**
  114559. * Execute the current task
  114560. * @param scene defines the scene where you want your assets to be loaded
  114561. * @param onSuccess is a callback called when the task is successfully executed
  114562. * @param onError is a callback called if an error occurs
  114563. */
  114564. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114565. }
  114566. /**
  114567. * Define a task used by AssetsManager to load text content
  114568. */
  114569. export class TextFileAssetTask extends AbstractAssetTask {
  114570. /**
  114571. * Defines the name of the task
  114572. */
  114573. name: string;
  114574. /**
  114575. * Defines the location of the file to load
  114576. */
  114577. url: string;
  114578. /**
  114579. * Gets the loaded text string
  114580. */
  114581. text: string;
  114582. /**
  114583. * Callback called when the task is successful
  114584. */
  114585. onSuccess: (task: TextFileAssetTask) => void;
  114586. /**
  114587. * Callback called when the task is successful
  114588. */
  114589. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  114590. /**
  114591. * Creates a new TextFileAssetTask object
  114592. * @param name defines the name of the task
  114593. * @param url defines the location of the file to load
  114594. */
  114595. constructor(
  114596. /**
  114597. * Defines the name of the task
  114598. */
  114599. name: string,
  114600. /**
  114601. * Defines the location of the file to load
  114602. */
  114603. url: string);
  114604. /**
  114605. * Execute the current task
  114606. * @param scene defines the scene where you want your assets to be loaded
  114607. * @param onSuccess is a callback called when the task is successfully executed
  114608. * @param onError is a callback called if an error occurs
  114609. */
  114610. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114611. }
  114612. /**
  114613. * Define a task used by AssetsManager to load binary data
  114614. */
  114615. export class BinaryFileAssetTask extends AbstractAssetTask {
  114616. /**
  114617. * Defines the name of the task
  114618. */
  114619. name: string;
  114620. /**
  114621. * Defines the location of the file to load
  114622. */
  114623. url: string;
  114624. /**
  114625. * Gets the lodaded data (as an array buffer)
  114626. */
  114627. data: ArrayBuffer;
  114628. /**
  114629. * Callback called when the task is successful
  114630. */
  114631. onSuccess: (task: BinaryFileAssetTask) => void;
  114632. /**
  114633. * Callback called when the task is successful
  114634. */
  114635. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  114636. /**
  114637. * Creates a new BinaryFileAssetTask object
  114638. * @param name defines the name of the new task
  114639. * @param url defines the location of the file to load
  114640. */
  114641. constructor(
  114642. /**
  114643. * Defines the name of the task
  114644. */
  114645. name: string,
  114646. /**
  114647. * Defines the location of the file to load
  114648. */
  114649. url: string);
  114650. /**
  114651. * Execute the current task
  114652. * @param scene defines the scene where you want your assets to be loaded
  114653. * @param onSuccess is a callback called when the task is successfully executed
  114654. * @param onError is a callback called if an error occurs
  114655. */
  114656. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114657. }
  114658. /**
  114659. * Define a task used by AssetsManager to load images
  114660. */
  114661. export class ImageAssetTask extends AbstractAssetTask {
  114662. /**
  114663. * Defines the name of the task
  114664. */
  114665. name: string;
  114666. /**
  114667. * Defines the location of the image to load
  114668. */
  114669. url: string;
  114670. /**
  114671. * Gets the loaded images
  114672. */
  114673. image: HTMLImageElement;
  114674. /**
  114675. * Callback called when the task is successful
  114676. */
  114677. onSuccess: (task: ImageAssetTask) => void;
  114678. /**
  114679. * Callback called when the task is successful
  114680. */
  114681. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  114682. /**
  114683. * Creates a new ImageAssetTask
  114684. * @param name defines the name of the task
  114685. * @param url defines the location of the image to load
  114686. */
  114687. constructor(
  114688. /**
  114689. * Defines the name of the task
  114690. */
  114691. name: string,
  114692. /**
  114693. * Defines the location of the image to load
  114694. */
  114695. url: string);
  114696. /**
  114697. * Execute the current task
  114698. * @param scene defines the scene where you want your assets to be loaded
  114699. * @param onSuccess is a callback called when the task is successfully executed
  114700. * @param onError is a callback called if an error occurs
  114701. */
  114702. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114703. }
  114704. /**
  114705. * Defines the interface used by texture loading tasks
  114706. */
  114707. export interface ITextureAssetTask<TEX extends BaseTexture> {
  114708. /**
  114709. * Gets the loaded texture
  114710. */
  114711. texture: TEX;
  114712. }
  114713. /**
  114714. * Define a task used by AssetsManager to load 2D textures
  114715. */
  114716. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  114717. /**
  114718. * Defines the name of the task
  114719. */
  114720. name: string;
  114721. /**
  114722. * Defines the location of the file to load
  114723. */
  114724. url: string;
  114725. /**
  114726. * Defines if mipmap should not be generated (default is false)
  114727. */
  114728. noMipmap?: boolean | undefined;
  114729. /**
  114730. * Defines if texture must be inverted on Y axis (default is false)
  114731. */
  114732. invertY?: boolean | undefined;
  114733. /**
  114734. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114735. */
  114736. samplingMode: number;
  114737. /**
  114738. * Gets the loaded texture
  114739. */
  114740. texture: Texture;
  114741. /**
  114742. * Callback called when the task is successful
  114743. */
  114744. onSuccess: (task: TextureAssetTask) => void;
  114745. /**
  114746. * Callback called when the task is successful
  114747. */
  114748. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  114749. /**
  114750. * Creates a new TextureAssetTask object
  114751. * @param name defines the name of the task
  114752. * @param url defines the location of the file to load
  114753. * @param noMipmap defines if mipmap should not be generated (default is false)
  114754. * @param invertY defines if texture must be inverted on Y axis (default is false)
  114755. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114756. */
  114757. constructor(
  114758. /**
  114759. * Defines the name of the task
  114760. */
  114761. name: string,
  114762. /**
  114763. * Defines the location of the file to load
  114764. */
  114765. url: string,
  114766. /**
  114767. * Defines if mipmap should not be generated (default is false)
  114768. */
  114769. noMipmap?: boolean | undefined,
  114770. /**
  114771. * Defines if texture must be inverted on Y axis (default is false)
  114772. */
  114773. invertY?: boolean | undefined,
  114774. /**
  114775. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114776. */
  114777. samplingMode?: number);
  114778. /**
  114779. * Execute the current task
  114780. * @param scene defines the scene where you want your assets to be loaded
  114781. * @param onSuccess is a callback called when the task is successfully executed
  114782. * @param onError is a callback called if an error occurs
  114783. */
  114784. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114785. }
  114786. /**
  114787. * Define a task used by AssetsManager to load cube textures
  114788. */
  114789. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  114790. /**
  114791. * Defines the name of the task
  114792. */
  114793. name: string;
  114794. /**
  114795. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114796. */
  114797. url: string;
  114798. /**
  114799. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114800. */
  114801. extensions?: string[] | undefined;
  114802. /**
  114803. * Defines if mipmaps should not be generated (default is false)
  114804. */
  114805. noMipmap?: boolean | undefined;
  114806. /**
  114807. * Defines the explicit list of files (undefined by default)
  114808. */
  114809. files?: string[] | undefined;
  114810. /**
  114811. * Gets the loaded texture
  114812. */
  114813. texture: CubeTexture;
  114814. /**
  114815. * Callback called when the task is successful
  114816. */
  114817. onSuccess: (task: CubeTextureAssetTask) => void;
  114818. /**
  114819. * Callback called when the task is successful
  114820. */
  114821. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  114822. /**
  114823. * Creates a new CubeTextureAssetTask
  114824. * @param name defines the name of the task
  114825. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114826. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114827. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114828. * @param files defines the explicit list of files (undefined by default)
  114829. */
  114830. constructor(
  114831. /**
  114832. * Defines the name of the task
  114833. */
  114834. name: string,
  114835. /**
  114836. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114837. */
  114838. url: string,
  114839. /**
  114840. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114841. */
  114842. extensions?: string[] | undefined,
  114843. /**
  114844. * Defines if mipmaps should not be generated (default is false)
  114845. */
  114846. noMipmap?: boolean | undefined,
  114847. /**
  114848. * Defines the explicit list of files (undefined by default)
  114849. */
  114850. files?: string[] | undefined);
  114851. /**
  114852. * Execute the current task
  114853. * @param scene defines the scene where you want your assets to be loaded
  114854. * @param onSuccess is a callback called when the task is successfully executed
  114855. * @param onError is a callback called if an error occurs
  114856. */
  114857. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114858. }
  114859. /**
  114860. * Define a task used by AssetsManager to load HDR cube textures
  114861. */
  114862. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  114863. /**
  114864. * Defines the name of the task
  114865. */
  114866. name: string;
  114867. /**
  114868. * Defines the location of the file to load
  114869. */
  114870. url: string;
  114871. /**
  114872. * Defines the desired size (the more it increases the longer the generation will be)
  114873. */
  114874. size: number;
  114875. /**
  114876. * Defines if mipmaps should not be generated (default is false)
  114877. */
  114878. noMipmap: boolean;
  114879. /**
  114880. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114881. */
  114882. generateHarmonics: boolean;
  114883. /**
  114884. * 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)
  114885. */
  114886. gammaSpace: boolean;
  114887. /**
  114888. * Internal Use Only
  114889. */
  114890. reserved: boolean;
  114891. /**
  114892. * Gets the loaded texture
  114893. */
  114894. texture: HDRCubeTexture;
  114895. /**
  114896. * Callback called when the task is successful
  114897. */
  114898. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  114899. /**
  114900. * Callback called when the task is successful
  114901. */
  114902. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  114903. /**
  114904. * Creates a new HDRCubeTextureAssetTask object
  114905. * @param name defines the name of the task
  114906. * @param url defines the location of the file to load
  114907. * @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.
  114908. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114909. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114910. * @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)
  114911. * @param reserved Internal use only
  114912. */
  114913. constructor(
  114914. /**
  114915. * Defines the name of the task
  114916. */
  114917. name: string,
  114918. /**
  114919. * Defines the location of the file to load
  114920. */
  114921. url: string,
  114922. /**
  114923. * Defines the desired size (the more it increases the longer the generation will be)
  114924. */
  114925. size: number,
  114926. /**
  114927. * Defines if mipmaps should not be generated (default is false)
  114928. */
  114929. noMipmap?: boolean,
  114930. /**
  114931. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114932. */
  114933. generateHarmonics?: boolean,
  114934. /**
  114935. * 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)
  114936. */
  114937. gammaSpace?: boolean,
  114938. /**
  114939. * Internal Use Only
  114940. */
  114941. reserved?: boolean);
  114942. /**
  114943. * Execute the current task
  114944. * @param scene defines the scene where you want your assets to be loaded
  114945. * @param onSuccess is a callback called when the task is successfully executed
  114946. * @param onError is a callback called if an error occurs
  114947. */
  114948. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114949. }
  114950. /**
  114951. * Define a task used by AssetsManager to load Equirectangular cube textures
  114952. */
  114953. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  114954. /**
  114955. * Defines the name of the task
  114956. */
  114957. name: string;
  114958. /**
  114959. * Defines the location of the file to load
  114960. */
  114961. url: string;
  114962. /**
  114963. * Defines the desired size (the more it increases the longer the generation will be)
  114964. */
  114965. size: number;
  114966. /**
  114967. * Defines if mipmaps should not be generated (default is false)
  114968. */
  114969. noMipmap: boolean;
  114970. /**
  114971. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114972. * but the standard material would require them in Gamma space) (default is true)
  114973. */
  114974. gammaSpace: boolean;
  114975. /**
  114976. * Gets the loaded texture
  114977. */
  114978. texture: EquiRectangularCubeTexture;
  114979. /**
  114980. * Callback called when the task is successful
  114981. */
  114982. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  114983. /**
  114984. * Callback called when the task is successful
  114985. */
  114986. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  114987. /**
  114988. * Creates a new EquiRectangularCubeTextureAssetTask object
  114989. * @param name defines the name of the task
  114990. * @param url defines the location of the file to load
  114991. * @param size defines the desired size (the more it increases the longer the generation will be)
  114992. * If the size is omitted this implies you are using a preprocessed cubemap.
  114993. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114994. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  114995. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  114996. * (default is true)
  114997. */
  114998. constructor(
  114999. /**
  115000. * Defines the name of the task
  115001. */
  115002. name: string,
  115003. /**
  115004. * Defines the location of the file to load
  115005. */
  115006. url: string,
  115007. /**
  115008. * Defines the desired size (the more it increases the longer the generation will be)
  115009. */
  115010. size: number,
  115011. /**
  115012. * Defines if mipmaps should not be generated (default is false)
  115013. */
  115014. noMipmap?: boolean,
  115015. /**
  115016. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115017. * but the standard material would require them in Gamma space) (default is true)
  115018. */
  115019. gammaSpace?: boolean);
  115020. /**
  115021. * Execute the current task
  115022. * @param scene defines the scene where you want your assets to be loaded
  115023. * @param onSuccess is a callback called when the task is successfully executed
  115024. * @param onError is a callback called if an error occurs
  115025. */
  115026. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115027. }
  115028. /**
  115029. * This class can be used to easily import assets into a scene
  115030. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115031. */
  115032. export class AssetsManager {
  115033. private _scene;
  115034. private _isLoading;
  115035. protected _tasks: AbstractAssetTask[];
  115036. protected _waitingTasksCount: number;
  115037. protected _totalTasksCount: number;
  115038. /**
  115039. * Callback called when all tasks are processed
  115040. */
  115041. onFinish: (tasks: AbstractAssetTask[]) => void;
  115042. /**
  115043. * Callback called when a task is successful
  115044. */
  115045. onTaskSuccess: (task: AbstractAssetTask) => void;
  115046. /**
  115047. * Callback called when a task had an error
  115048. */
  115049. onTaskError: (task: AbstractAssetTask) => void;
  115050. /**
  115051. * Callback called when a task is done (whatever the result is)
  115052. */
  115053. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115054. /**
  115055. * Observable called when all tasks are processed
  115056. */
  115057. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115058. /**
  115059. * Observable called when a task had an error
  115060. */
  115061. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115062. /**
  115063. * Observable called when all tasks were executed
  115064. */
  115065. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115066. /**
  115067. * Observable called when a task is done (whatever the result is)
  115068. */
  115069. onProgressObservable: Observable<IAssetsProgressEvent>;
  115070. /**
  115071. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115072. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115073. */
  115074. useDefaultLoadingScreen: boolean;
  115075. /**
  115076. * Creates a new AssetsManager
  115077. * @param scene defines the scene to work on
  115078. */
  115079. constructor(scene: Scene);
  115080. /**
  115081. * Add a MeshAssetTask to the list of active tasks
  115082. * @param taskName defines the name of the new task
  115083. * @param meshesNames defines the name of meshes to load
  115084. * @param rootUrl defines the root url to use to locate files
  115085. * @param sceneFilename defines the filename of the scene file
  115086. * @returns a new MeshAssetTask object
  115087. */
  115088. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115089. /**
  115090. * Add a TextFileAssetTask to the list of active tasks
  115091. * @param taskName defines the name of the new task
  115092. * @param url defines the url of the file to load
  115093. * @returns a new TextFileAssetTask object
  115094. */
  115095. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115096. /**
  115097. * Add a BinaryFileAssetTask to the list of active tasks
  115098. * @param taskName defines the name of the new task
  115099. * @param url defines the url of the file to load
  115100. * @returns a new BinaryFileAssetTask object
  115101. */
  115102. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115103. /**
  115104. * Add a ImageAssetTask to the list of active tasks
  115105. * @param taskName defines the name of the new task
  115106. * @param url defines the url of the file to load
  115107. * @returns a new ImageAssetTask object
  115108. */
  115109. addImageTask(taskName: string, url: string): ImageAssetTask;
  115110. /**
  115111. * Add a TextureAssetTask to the list of active tasks
  115112. * @param taskName defines the name of the new task
  115113. * @param url defines the url of the file to load
  115114. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115115. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115116. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115117. * @returns a new TextureAssetTask object
  115118. */
  115119. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115120. /**
  115121. * Add a CubeTextureAssetTask to the list of active tasks
  115122. * @param taskName defines the name of the new task
  115123. * @param url defines the url of the file to load
  115124. * @param extensions defines the extension to use to load the cube map (can be null)
  115125. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115126. * @param files defines the list of files to load (can be null)
  115127. * @returns a new CubeTextureAssetTask object
  115128. */
  115129. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115130. /**
  115131. *
  115132. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115133. * @param taskName defines the name of the new task
  115134. * @param url defines the url of the file to load
  115135. * @param size defines the size you want for the cubemap (can be null)
  115136. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115137. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115138. * @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)
  115139. * @param reserved Internal use only
  115140. * @returns a new HDRCubeTextureAssetTask object
  115141. */
  115142. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115143. /**
  115144. *
  115145. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115146. * @param taskName defines the name of the new task
  115147. * @param url defines the url of the file to load
  115148. * @param size defines the size you want for the cubemap (can be null)
  115149. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115150. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115151. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115152. * @returns a new EquiRectangularCubeTextureAssetTask object
  115153. */
  115154. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115155. /**
  115156. * Remove a task from the assets manager.
  115157. * @param task the task to remove
  115158. */
  115159. removeTask(task: AbstractAssetTask): void;
  115160. private _decreaseWaitingTasksCount;
  115161. private _runTask;
  115162. /**
  115163. * Reset the AssetsManager and remove all tasks
  115164. * @return the current instance of the AssetsManager
  115165. */
  115166. reset(): AssetsManager;
  115167. /**
  115168. * Start the loading process
  115169. * @return the current instance of the AssetsManager
  115170. */
  115171. load(): AssetsManager;
  115172. /**
  115173. * Start the loading process as an async operation
  115174. * @return a promise returning the list of failed tasks
  115175. */
  115176. loadAsync(): Promise<void>;
  115177. }
  115178. }
  115179. declare module BABYLON {
  115180. /**
  115181. * Wrapper class for promise with external resolve and reject.
  115182. */
  115183. export class Deferred<T> {
  115184. /**
  115185. * The promise associated with this deferred object.
  115186. */
  115187. readonly promise: Promise<T>;
  115188. private _resolve;
  115189. private _reject;
  115190. /**
  115191. * The resolve method of the promise associated with this deferred object.
  115192. */
  115193. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115194. /**
  115195. * The reject method of the promise associated with this deferred object.
  115196. */
  115197. readonly reject: (reason?: any) => void;
  115198. /**
  115199. * Constructor for this deferred object.
  115200. */
  115201. constructor();
  115202. }
  115203. }
  115204. declare module BABYLON {
  115205. /**
  115206. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115207. */
  115208. export class MeshExploder {
  115209. private _centerMesh;
  115210. private _meshes;
  115211. private _meshesOrigins;
  115212. private _toCenterVectors;
  115213. private _scaledDirection;
  115214. private _newPosition;
  115215. private _centerPosition;
  115216. /**
  115217. * Explodes meshes from a center mesh.
  115218. * @param meshes The meshes to explode.
  115219. * @param centerMesh The mesh to be center of explosion.
  115220. */
  115221. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115222. private _setCenterMesh;
  115223. /**
  115224. * Get class name
  115225. * @returns "MeshExploder"
  115226. */
  115227. getClassName(): string;
  115228. /**
  115229. * "Exploded meshes"
  115230. * @returns Array of meshes with the centerMesh at index 0.
  115231. */
  115232. getMeshes(): Array<Mesh>;
  115233. /**
  115234. * Explodes meshes giving a specific direction
  115235. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115236. */
  115237. explode(direction?: number): void;
  115238. }
  115239. }
  115240. declare module BABYLON {
  115241. /**
  115242. * Class used to help managing file picking and drag'n'drop
  115243. */
  115244. export class FilesInput {
  115245. /**
  115246. * List of files ready to be loaded
  115247. */
  115248. static readonly FilesToLoad: {
  115249. [key: string]: File;
  115250. };
  115251. /**
  115252. * Callback called when a file is processed
  115253. */
  115254. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115255. private _engine;
  115256. private _currentScene;
  115257. private _sceneLoadedCallback;
  115258. private _progressCallback;
  115259. private _additionalRenderLoopLogicCallback;
  115260. private _textureLoadingCallback;
  115261. private _startingProcessingFilesCallback;
  115262. private _onReloadCallback;
  115263. private _errorCallback;
  115264. private _elementToMonitor;
  115265. private _sceneFileToLoad;
  115266. private _filesToLoad;
  115267. /**
  115268. * Creates a new FilesInput
  115269. * @param engine defines the rendering engine
  115270. * @param scene defines the hosting scene
  115271. * @param sceneLoadedCallback callback called when scene is loaded
  115272. * @param progressCallback callback called to track progress
  115273. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115274. * @param textureLoadingCallback callback called when a texture is loading
  115275. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115276. * @param onReloadCallback callback called when a reload is requested
  115277. * @param errorCallback callback call if an error occurs
  115278. */
  115279. 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);
  115280. private _dragEnterHandler;
  115281. private _dragOverHandler;
  115282. private _dropHandler;
  115283. /**
  115284. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115285. * @param elementToMonitor defines the DOM element to track
  115286. */
  115287. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115288. /**
  115289. * Release all associated resources
  115290. */
  115291. dispose(): void;
  115292. private renderFunction;
  115293. private drag;
  115294. private drop;
  115295. private _traverseFolder;
  115296. private _processFiles;
  115297. /**
  115298. * Load files from a drop event
  115299. * @param event defines the drop event to use as source
  115300. */
  115301. loadFiles(event: any): void;
  115302. private _processReload;
  115303. /**
  115304. * Reload the current scene from the loaded files
  115305. */
  115306. reload(): void;
  115307. }
  115308. }
  115309. declare module BABYLON {
  115310. /**
  115311. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115312. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115313. */
  115314. export class SceneOptimization {
  115315. /**
  115316. * Defines the priority of this optimization (0 by default which means first in the list)
  115317. */
  115318. priority: number;
  115319. /**
  115320. * Gets a string describing the action executed by the current optimization
  115321. * @returns description string
  115322. */
  115323. getDescription(): string;
  115324. /**
  115325. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115326. * @param scene defines the current scene where to apply this optimization
  115327. * @param optimizer defines the current optimizer
  115328. * @returns true if everything that can be done was applied
  115329. */
  115330. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115331. /**
  115332. * Creates the SceneOptimization object
  115333. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115334. * @param desc defines the description associated with the optimization
  115335. */
  115336. constructor(
  115337. /**
  115338. * Defines the priority of this optimization (0 by default which means first in the list)
  115339. */
  115340. priority?: number);
  115341. }
  115342. /**
  115343. * Defines an optimization used to reduce the size of render target textures
  115344. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115345. */
  115346. export class TextureOptimization extends SceneOptimization {
  115347. /**
  115348. * Defines the priority of this optimization (0 by default which means first in the list)
  115349. */
  115350. priority: number;
  115351. /**
  115352. * 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
  115353. */
  115354. maximumSize: number;
  115355. /**
  115356. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115357. */
  115358. step: number;
  115359. /**
  115360. * Gets a string describing the action executed by the current optimization
  115361. * @returns description string
  115362. */
  115363. getDescription(): string;
  115364. /**
  115365. * Creates the TextureOptimization object
  115366. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115367. * @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
  115368. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115369. */
  115370. constructor(
  115371. /**
  115372. * Defines the priority of this optimization (0 by default which means first in the list)
  115373. */
  115374. priority?: number,
  115375. /**
  115376. * 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
  115377. */
  115378. maximumSize?: number,
  115379. /**
  115380. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115381. */
  115382. step?: number);
  115383. /**
  115384. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115385. * @param scene defines the current scene where to apply this optimization
  115386. * @param optimizer defines the current optimizer
  115387. * @returns true if everything that can be done was applied
  115388. */
  115389. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115390. }
  115391. /**
  115392. * Defines an optimization used to increase or decrease the rendering resolution
  115393. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115394. */
  115395. export class HardwareScalingOptimization extends SceneOptimization {
  115396. /**
  115397. * Defines the priority of this optimization (0 by default which means first in the list)
  115398. */
  115399. priority: number;
  115400. /**
  115401. * Defines the maximum scale to use (2 by default)
  115402. */
  115403. maximumScale: number;
  115404. /**
  115405. * Defines the step to use between two passes (0.5 by default)
  115406. */
  115407. step: number;
  115408. private _currentScale;
  115409. private _directionOffset;
  115410. /**
  115411. * Gets a string describing the action executed by the current optimization
  115412. * @return description string
  115413. */
  115414. getDescription(): string;
  115415. /**
  115416. * Creates the HardwareScalingOptimization object
  115417. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115418. * @param maximumScale defines the maximum scale to use (2 by default)
  115419. * @param step defines the step to use between two passes (0.5 by default)
  115420. */
  115421. constructor(
  115422. /**
  115423. * Defines the priority of this optimization (0 by default which means first in the list)
  115424. */
  115425. priority?: number,
  115426. /**
  115427. * Defines the maximum scale to use (2 by default)
  115428. */
  115429. maximumScale?: number,
  115430. /**
  115431. * Defines the step to use between two passes (0.5 by default)
  115432. */
  115433. step?: number);
  115434. /**
  115435. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115436. * @param scene defines the current scene where to apply this optimization
  115437. * @param optimizer defines the current optimizer
  115438. * @returns true if everything that can be done was applied
  115439. */
  115440. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115441. }
  115442. /**
  115443. * Defines an optimization used to remove shadows
  115444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115445. */
  115446. export class ShadowsOptimization extends SceneOptimization {
  115447. /**
  115448. * Gets a string describing the action executed by the current optimization
  115449. * @return description string
  115450. */
  115451. getDescription(): string;
  115452. /**
  115453. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115454. * @param scene defines the current scene where to apply this optimization
  115455. * @param optimizer defines the current optimizer
  115456. * @returns true if everything that can be done was applied
  115457. */
  115458. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115459. }
  115460. /**
  115461. * Defines an optimization used to turn post-processes off
  115462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115463. */
  115464. export class PostProcessesOptimization extends SceneOptimization {
  115465. /**
  115466. * Gets a string describing the action executed by the current optimization
  115467. * @return description string
  115468. */
  115469. getDescription(): string;
  115470. /**
  115471. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115472. * @param scene defines the current scene where to apply this optimization
  115473. * @param optimizer defines the current optimizer
  115474. * @returns true if everything that can be done was applied
  115475. */
  115476. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115477. }
  115478. /**
  115479. * Defines an optimization used to turn lens flares off
  115480. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115481. */
  115482. export class LensFlaresOptimization extends SceneOptimization {
  115483. /**
  115484. * Gets a string describing the action executed by the current optimization
  115485. * @return description string
  115486. */
  115487. getDescription(): string;
  115488. /**
  115489. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115490. * @param scene defines the current scene where to apply this optimization
  115491. * @param optimizer defines the current optimizer
  115492. * @returns true if everything that can be done was applied
  115493. */
  115494. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115495. }
  115496. /**
  115497. * Defines an optimization based on user defined callback.
  115498. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115499. */
  115500. export class CustomOptimization extends SceneOptimization {
  115501. /**
  115502. * Callback called to apply the custom optimization.
  115503. */
  115504. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  115505. /**
  115506. * Callback called to get custom description
  115507. */
  115508. onGetDescription: () => string;
  115509. /**
  115510. * Gets a string describing the action executed by the current optimization
  115511. * @returns description string
  115512. */
  115513. getDescription(): string;
  115514. /**
  115515. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115516. * @param scene defines the current scene where to apply this optimization
  115517. * @param optimizer defines the current optimizer
  115518. * @returns true if everything that can be done was applied
  115519. */
  115520. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115521. }
  115522. /**
  115523. * Defines an optimization used to turn particles off
  115524. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115525. */
  115526. export class ParticlesOptimization extends SceneOptimization {
  115527. /**
  115528. * Gets a string describing the action executed by the current optimization
  115529. * @return description string
  115530. */
  115531. getDescription(): string;
  115532. /**
  115533. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115534. * @param scene defines the current scene where to apply this optimization
  115535. * @param optimizer defines the current optimizer
  115536. * @returns true if everything that can be done was applied
  115537. */
  115538. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115539. }
  115540. /**
  115541. * Defines an optimization used to turn render targets off
  115542. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115543. */
  115544. export class RenderTargetsOptimization extends SceneOptimization {
  115545. /**
  115546. * Gets a string describing the action executed by the current optimization
  115547. * @return description string
  115548. */
  115549. getDescription(): string;
  115550. /**
  115551. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115552. * @param scene defines the current scene where to apply this optimization
  115553. * @param optimizer defines the current optimizer
  115554. * @returns true if everything that can be done was applied
  115555. */
  115556. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115557. }
  115558. /**
  115559. * Defines an optimization used to merge meshes with compatible materials
  115560. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115561. */
  115562. export class MergeMeshesOptimization extends SceneOptimization {
  115563. private static _UpdateSelectionTree;
  115564. /**
  115565. * Gets or sets a boolean which defines if optimization octree has to be updated
  115566. */
  115567. /**
  115568. * Gets or sets a boolean which defines if optimization octree has to be updated
  115569. */
  115570. static UpdateSelectionTree: boolean;
  115571. /**
  115572. * Gets a string describing the action executed by the current optimization
  115573. * @return description string
  115574. */
  115575. getDescription(): string;
  115576. private _canBeMerged;
  115577. /**
  115578. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115579. * @param scene defines the current scene where to apply this optimization
  115580. * @param optimizer defines the current optimizer
  115581. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  115582. * @returns true if everything that can be done was applied
  115583. */
  115584. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  115585. }
  115586. /**
  115587. * Defines a list of options used by SceneOptimizer
  115588. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115589. */
  115590. export class SceneOptimizerOptions {
  115591. /**
  115592. * Defines the target frame rate to reach (60 by default)
  115593. */
  115594. targetFrameRate: number;
  115595. /**
  115596. * Defines the interval between two checkes (2000ms by default)
  115597. */
  115598. trackerDuration: number;
  115599. /**
  115600. * Gets the list of optimizations to apply
  115601. */
  115602. optimizations: SceneOptimization[];
  115603. /**
  115604. * Creates a new list of options used by SceneOptimizer
  115605. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  115606. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  115607. */
  115608. constructor(
  115609. /**
  115610. * Defines the target frame rate to reach (60 by default)
  115611. */
  115612. targetFrameRate?: number,
  115613. /**
  115614. * Defines the interval between two checkes (2000ms by default)
  115615. */
  115616. trackerDuration?: number);
  115617. /**
  115618. * Add a new optimization
  115619. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  115620. * @returns the current SceneOptimizerOptions
  115621. */
  115622. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  115623. /**
  115624. * Add a new custom optimization
  115625. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  115626. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  115627. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115628. * @returns the current SceneOptimizerOptions
  115629. */
  115630. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  115631. /**
  115632. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  115633. * @param targetFrameRate defines the target frame rate (60 by default)
  115634. * @returns a SceneOptimizerOptions object
  115635. */
  115636. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115637. /**
  115638. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  115639. * @param targetFrameRate defines the target frame rate (60 by default)
  115640. * @returns a SceneOptimizerOptions object
  115641. */
  115642. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115643. /**
  115644. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  115645. * @param targetFrameRate defines the target frame rate (60 by default)
  115646. * @returns a SceneOptimizerOptions object
  115647. */
  115648. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115649. }
  115650. /**
  115651. * Class used to run optimizations in order to reach a target frame rate
  115652. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115653. */
  115654. export class SceneOptimizer implements IDisposable {
  115655. private _isRunning;
  115656. private _options;
  115657. private _scene;
  115658. private _currentPriorityLevel;
  115659. private _targetFrameRate;
  115660. private _trackerDuration;
  115661. private _currentFrameRate;
  115662. private _sceneDisposeObserver;
  115663. private _improvementMode;
  115664. /**
  115665. * Defines an observable called when the optimizer reaches the target frame rate
  115666. */
  115667. onSuccessObservable: Observable<SceneOptimizer>;
  115668. /**
  115669. * Defines an observable called when the optimizer enables an optimization
  115670. */
  115671. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  115672. /**
  115673. * Defines an observable called when the optimizer is not able to reach the target frame rate
  115674. */
  115675. onFailureObservable: Observable<SceneOptimizer>;
  115676. /**
  115677. * Gets a boolean indicating if the optimizer is in improvement mode
  115678. */
  115679. readonly isInImprovementMode: boolean;
  115680. /**
  115681. * Gets the current priority level (0 at start)
  115682. */
  115683. readonly currentPriorityLevel: number;
  115684. /**
  115685. * Gets the current frame rate checked by the SceneOptimizer
  115686. */
  115687. readonly currentFrameRate: number;
  115688. /**
  115689. * Gets or sets the current target frame rate (60 by default)
  115690. */
  115691. /**
  115692. * Gets or sets the current target frame rate (60 by default)
  115693. */
  115694. targetFrameRate: number;
  115695. /**
  115696. * Gets or sets the current interval between two checks (every 2000ms by default)
  115697. */
  115698. /**
  115699. * Gets or sets the current interval between two checks (every 2000ms by default)
  115700. */
  115701. trackerDuration: number;
  115702. /**
  115703. * Gets the list of active optimizations
  115704. */
  115705. readonly optimizations: SceneOptimization[];
  115706. /**
  115707. * Creates a new SceneOptimizer
  115708. * @param scene defines the scene to work on
  115709. * @param options defines the options to use with the SceneOptimizer
  115710. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  115711. * @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)
  115712. */
  115713. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  115714. /**
  115715. * Stops the current optimizer
  115716. */
  115717. stop(): void;
  115718. /**
  115719. * Reset the optimizer to initial step (current priority level = 0)
  115720. */
  115721. reset(): void;
  115722. /**
  115723. * Start the optimizer. By default it will try to reach a specific framerate
  115724. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  115725. */
  115726. start(): void;
  115727. private _checkCurrentState;
  115728. /**
  115729. * Release all resources
  115730. */
  115731. dispose(): void;
  115732. /**
  115733. * Helper function to create a SceneOptimizer with one single line of code
  115734. * @param scene defines the scene to work on
  115735. * @param options defines the options to use with the SceneOptimizer
  115736. * @param onSuccess defines a callback to call on success
  115737. * @param onFailure defines a callback to call on failure
  115738. * @returns the new SceneOptimizer object
  115739. */
  115740. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  115741. }
  115742. }
  115743. declare module BABYLON {
  115744. /**
  115745. * Class used to serialize a scene into a string
  115746. */
  115747. export class SceneSerializer {
  115748. /**
  115749. * Clear cache used by a previous serialization
  115750. */
  115751. static ClearCache(): void;
  115752. /**
  115753. * Serialize a scene into a JSON compatible object
  115754. * @param scene defines the scene to serialize
  115755. * @returns a JSON compatible object
  115756. */
  115757. static Serialize(scene: Scene): any;
  115758. /**
  115759. * Serialize a mesh into a JSON compatible object
  115760. * @param toSerialize defines the mesh to serialize
  115761. * @param withParents defines if parents must be serialized as well
  115762. * @param withChildren defines if children must be serialized as well
  115763. * @returns a JSON compatible object
  115764. */
  115765. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  115766. }
  115767. }
  115768. declare module BABYLON {
  115769. /**
  115770. * Class used to host texture specific utilities
  115771. */
  115772. export class TextureTools {
  115773. /**
  115774. * Uses the GPU to create a copy texture rescaled at a given size
  115775. * @param texture Texture to copy from
  115776. * @param width defines the desired width
  115777. * @param height defines the desired height
  115778. * @param useBilinearMode defines if bilinear mode has to be used
  115779. * @return the generated texture
  115780. */
  115781. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  115782. }
  115783. }
  115784. declare module BABYLON {
  115785. /**
  115786. * This represents the different options avilable for the video capture.
  115787. */
  115788. export interface VideoRecorderOptions {
  115789. /** Defines the mime type of the video */
  115790. mimeType: string;
  115791. /** Defines the video the video should be recorded at */
  115792. fps: number;
  115793. /** Defines the chunk size for the recording data */
  115794. recordChunckSize: number;
  115795. /** The audio tracks to attach to the record */
  115796. audioTracks?: MediaStreamTrack[];
  115797. }
  115798. /**
  115799. * This can helps recording videos from BabylonJS.
  115800. * This is based on the available WebRTC functionalities of the browser.
  115801. *
  115802. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  115803. */
  115804. export class VideoRecorder {
  115805. private static readonly _defaultOptions;
  115806. /**
  115807. * Returns wehther or not the VideoRecorder is available in your browser.
  115808. * @param engine Defines the Babylon Engine to check the support for
  115809. * @returns true if supported otherwise false
  115810. */
  115811. static IsSupported(engine: Engine): boolean;
  115812. private readonly _options;
  115813. private _canvas;
  115814. private _mediaRecorder;
  115815. private _recordedChunks;
  115816. private _fileName;
  115817. private _resolve;
  115818. private _reject;
  115819. /**
  115820. * True wether a recording is already in progress.
  115821. */
  115822. readonly isRecording: boolean;
  115823. /**
  115824. * Create a new VideoCapture object which can help converting what you see in Babylon to
  115825. * a video file.
  115826. * @param engine Defines the BabylonJS Engine you wish to record
  115827. * @param options Defines options that can be used to customized the capture
  115828. */
  115829. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  115830. /**
  115831. * Stops the current recording before the default capture timeout passed in the startRecording
  115832. * functions.
  115833. */
  115834. stopRecording(): void;
  115835. /**
  115836. * Starts recording the canvas for a max duration specified in parameters.
  115837. * @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.
  115838. * @param maxDuration Defines the maximum recording time in seconds.
  115839. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  115840. * @return a promise callback at the end of the recording with the video data in Blob.
  115841. */
  115842. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  115843. /**
  115844. * Releases internal resources used during the recording.
  115845. */
  115846. dispose(): void;
  115847. private _handleDataAvailable;
  115848. private _handleError;
  115849. private _handleStop;
  115850. }
  115851. }
  115852. declare module BABYLON {
  115853. /**
  115854. * Class containing a set of static utilities functions for screenshots
  115855. */
  115856. export class ScreenshotTools {
  115857. /**
  115858. * Captures a screenshot of the current rendering
  115859. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115860. * @param engine defines the rendering engine
  115861. * @param camera defines the source camera
  115862. * @param size This parameter can be set to a single number or to an object with the
  115863. * following (optional) properties: precision, width, height. If a single number is passed,
  115864. * it will be used for both width and height. If an object is passed, the screenshot size
  115865. * will be derived from the parameters. The precision property is a multiplier allowing
  115866. * rendering at a higher or lower resolution
  115867. * @param successCallback defines the callback receives a single parameter which contains the
  115868. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115869. * src parameter of an <img> to display it
  115870. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115871. * Check your browser for supported MIME types
  115872. */
  115873. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  115874. /**
  115875. * Generates an image screenshot from the specified camera.
  115876. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115877. * @param engine The engine to use for rendering
  115878. * @param camera The camera to use for rendering
  115879. * @param size This parameter can be set to a single number or to an object with the
  115880. * following (optional) properties: precision, width, height. If a single number is passed,
  115881. * it will be used for both width and height. If an object is passed, the screenshot size
  115882. * will be derived from the parameters. The precision property is a multiplier allowing
  115883. * rendering at a higher or lower resolution
  115884. * @param successCallback The callback receives a single parameter which contains the
  115885. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115886. * src parameter of an <img> to display it
  115887. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115888. * Check your browser for supported MIME types
  115889. * @param samples Texture samples (default: 1)
  115890. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115891. * @param fileName A name for for the downloaded file.
  115892. */
  115893. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115894. }
  115895. }
  115896. declare module BABYLON {
  115897. /**
  115898. * A cursor which tracks a point on a path
  115899. */
  115900. export class PathCursor {
  115901. private path;
  115902. /**
  115903. * Stores path cursor callbacks for when an onchange event is triggered
  115904. */
  115905. private _onchange;
  115906. /**
  115907. * The value of the path cursor
  115908. */
  115909. value: number;
  115910. /**
  115911. * The animation array of the path cursor
  115912. */
  115913. animations: Animation[];
  115914. /**
  115915. * Initializes the path cursor
  115916. * @param path The path to track
  115917. */
  115918. constructor(path: Path2);
  115919. /**
  115920. * Gets the cursor point on the path
  115921. * @returns A point on the path cursor at the cursor location
  115922. */
  115923. getPoint(): Vector3;
  115924. /**
  115925. * Moves the cursor ahead by the step amount
  115926. * @param step The amount to move the cursor forward
  115927. * @returns This path cursor
  115928. */
  115929. moveAhead(step?: number): PathCursor;
  115930. /**
  115931. * Moves the cursor behind by the step amount
  115932. * @param step The amount to move the cursor back
  115933. * @returns This path cursor
  115934. */
  115935. moveBack(step?: number): PathCursor;
  115936. /**
  115937. * Moves the cursor by the step amount
  115938. * If the step amount is greater than one, an exception is thrown
  115939. * @param step The amount to move the cursor
  115940. * @returns This path cursor
  115941. */
  115942. move(step: number): PathCursor;
  115943. /**
  115944. * Ensures that the value is limited between zero and one
  115945. * @returns This path cursor
  115946. */
  115947. private ensureLimits;
  115948. /**
  115949. * Runs onchange callbacks on change (used by the animation engine)
  115950. * @returns This path cursor
  115951. */
  115952. private raiseOnChange;
  115953. /**
  115954. * Executes a function on change
  115955. * @param f A path cursor onchange callback
  115956. * @returns This path cursor
  115957. */
  115958. onchange(f: (cursor: PathCursor) => void): PathCursor;
  115959. }
  115960. }
  115961. declare module BABYLON {
  115962. /** @hidden */
  115963. export var blurPixelShader: {
  115964. name: string;
  115965. shader: string;
  115966. };
  115967. }
  115968. declare module BABYLON {
  115969. /** @hidden */
  115970. export var bones300Declaration: {
  115971. name: string;
  115972. shader: string;
  115973. };
  115974. }
  115975. declare module BABYLON {
  115976. /** @hidden */
  115977. export var instances300Declaration: {
  115978. name: string;
  115979. shader: string;
  115980. };
  115981. }
  115982. declare module BABYLON {
  115983. /** @hidden */
  115984. export var pointCloudVertexDeclaration: {
  115985. name: string;
  115986. shader: string;
  115987. };
  115988. }
  115989. // Mixins
  115990. interface Window {
  115991. mozIndexedDB: IDBFactory;
  115992. webkitIndexedDB: IDBFactory;
  115993. msIndexedDB: IDBFactory;
  115994. webkitURL: typeof URL;
  115995. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  115996. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  115997. WebGLRenderingContext: WebGLRenderingContext;
  115998. MSGesture: MSGesture;
  115999. CANNON: any;
  116000. AudioContext: AudioContext;
  116001. webkitAudioContext: AudioContext;
  116002. PointerEvent: any;
  116003. Math: Math;
  116004. Uint8Array: Uint8ArrayConstructor;
  116005. Float32Array: Float32ArrayConstructor;
  116006. mozURL: typeof URL;
  116007. msURL: typeof URL;
  116008. VRFrameData: any; // WebVR, from specs 1.1
  116009. DracoDecoderModule: any;
  116010. setImmediate(handler: (...args: any[]) => void): number;
  116011. }
  116012. interface HTMLCanvasElement {
  116013. requestPointerLock(): void;
  116014. msRequestPointerLock?(): void;
  116015. mozRequestPointerLock?(): void;
  116016. webkitRequestPointerLock?(): void;
  116017. /** Track wether a record is in progress */
  116018. isRecording: boolean;
  116019. /** Capture Stream method defined by some browsers */
  116020. captureStream(fps?: number): MediaStream;
  116021. }
  116022. interface CanvasRenderingContext2D {
  116023. msImageSmoothingEnabled: boolean;
  116024. }
  116025. interface MouseEvent {
  116026. mozMovementX: number;
  116027. mozMovementY: number;
  116028. webkitMovementX: number;
  116029. webkitMovementY: number;
  116030. msMovementX: number;
  116031. msMovementY: number;
  116032. }
  116033. interface Navigator {
  116034. mozGetVRDevices: (any: any) => any;
  116035. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116036. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116037. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116038. webkitGetGamepads(): Gamepad[];
  116039. msGetGamepads(): Gamepad[];
  116040. webkitGamepads(): Gamepad[];
  116041. }
  116042. interface HTMLVideoElement {
  116043. mozSrcObject: any;
  116044. }
  116045. interface Math {
  116046. fround(x: number): number;
  116047. imul(a: number, b: number): number;
  116048. }
  116049. interface WebGLProgram {
  116050. context?: WebGLRenderingContext;
  116051. vertexShader?: WebGLShader;
  116052. fragmentShader?: WebGLShader;
  116053. isParallelCompiled: boolean;
  116054. onCompiled?: () => void;
  116055. }
  116056. interface WebGLRenderingContext {
  116057. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116058. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116059. vertexAttribDivisor(index: number, divisor: number): void;
  116060. createVertexArray(): any;
  116061. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116062. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116063. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116064. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116065. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116066. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116067. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116068. // Queries
  116069. createQuery(): WebGLQuery;
  116070. deleteQuery(query: WebGLQuery): void;
  116071. beginQuery(target: number, query: WebGLQuery): void;
  116072. endQuery(target: number): void;
  116073. getQueryParameter(query: WebGLQuery, pname: number): any;
  116074. getQuery(target: number, pname: number): any;
  116075. MAX_SAMPLES: number;
  116076. RGBA8: number;
  116077. READ_FRAMEBUFFER: number;
  116078. DRAW_FRAMEBUFFER: number;
  116079. UNIFORM_BUFFER: number;
  116080. HALF_FLOAT_OES: number;
  116081. RGBA16F: number;
  116082. RGBA32F: number;
  116083. R32F: number;
  116084. RG32F: number;
  116085. RGB32F: number;
  116086. R16F: number;
  116087. RG16F: number;
  116088. RGB16F: number;
  116089. RED: number;
  116090. RG: number;
  116091. R8: number;
  116092. RG8: number;
  116093. UNSIGNED_INT_24_8: number;
  116094. DEPTH24_STENCIL8: number;
  116095. /* Multiple Render Targets */
  116096. drawBuffers(buffers: number[]): void;
  116097. readBuffer(src: number): void;
  116098. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116099. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116100. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116101. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116102. // Occlusion Query
  116103. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116104. ANY_SAMPLES_PASSED: number;
  116105. QUERY_RESULT_AVAILABLE: number;
  116106. QUERY_RESULT: number;
  116107. }
  116108. interface WebGLBuffer {
  116109. references: number;
  116110. capacity: number;
  116111. is32Bits: boolean;
  116112. }
  116113. interface WebGLProgram {
  116114. transformFeedback?: WebGLTransformFeedback | null;
  116115. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116116. }
  116117. interface EXT_disjoint_timer_query {
  116118. QUERY_COUNTER_BITS_EXT: number;
  116119. TIME_ELAPSED_EXT: number;
  116120. TIMESTAMP_EXT: number;
  116121. GPU_DISJOINT_EXT: number;
  116122. QUERY_RESULT_EXT: number;
  116123. QUERY_RESULT_AVAILABLE_EXT: number;
  116124. queryCounterEXT(query: WebGLQuery, target: number): void;
  116125. createQueryEXT(): WebGLQuery;
  116126. beginQueryEXT(target: number, query: WebGLQuery): void;
  116127. endQueryEXT(target: number): void;
  116128. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116129. deleteQueryEXT(query: WebGLQuery): void;
  116130. }
  116131. interface WebGLUniformLocation {
  116132. _currentState: any;
  116133. }
  116134. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116135. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116136. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116137. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116138. interface WebGLRenderingContext {
  116139. readonly RASTERIZER_DISCARD: number;
  116140. readonly DEPTH_COMPONENT24: number;
  116141. readonly TEXTURE_3D: number;
  116142. readonly TEXTURE_2D_ARRAY: number;
  116143. readonly TEXTURE_COMPARE_FUNC: number;
  116144. readonly TEXTURE_COMPARE_MODE: number;
  116145. readonly COMPARE_REF_TO_TEXTURE: number;
  116146. readonly TEXTURE_WRAP_R: number;
  116147. readonly HALF_FLOAT: number;
  116148. readonly RGB8: number;
  116149. readonly RED_INTEGER: number;
  116150. readonly RG_INTEGER: number;
  116151. readonly RGB_INTEGER: number;
  116152. readonly RGBA_INTEGER: number;
  116153. readonly R8_SNORM: number;
  116154. readonly RG8_SNORM: number;
  116155. readonly RGB8_SNORM: number;
  116156. readonly RGBA8_SNORM: number;
  116157. readonly R8I: number;
  116158. readonly RG8I: number;
  116159. readonly RGB8I: number;
  116160. readonly RGBA8I: number;
  116161. readonly R8UI: number;
  116162. readonly RG8UI: number;
  116163. readonly RGB8UI: number;
  116164. readonly RGBA8UI: number;
  116165. readonly R16I: number;
  116166. readonly RG16I: number;
  116167. readonly RGB16I: number;
  116168. readonly RGBA16I: number;
  116169. readonly R16UI: number;
  116170. readonly RG16UI: number;
  116171. readonly RGB16UI: number;
  116172. readonly RGBA16UI: number;
  116173. readonly R32I: number;
  116174. readonly RG32I: number;
  116175. readonly RGB32I: number;
  116176. readonly RGBA32I: number;
  116177. readonly R32UI: number;
  116178. readonly RG32UI: number;
  116179. readonly RGB32UI: number;
  116180. readonly RGBA32UI: number;
  116181. readonly RGB10_A2UI: number;
  116182. readonly R11F_G11F_B10F: number;
  116183. readonly RGB9_E5: number;
  116184. readonly RGB10_A2: number;
  116185. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116186. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116187. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116188. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116189. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116190. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116191. 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;
  116192. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116193. readonly TRANSFORM_FEEDBACK: number;
  116194. readonly INTERLEAVED_ATTRIBS: number;
  116195. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116196. createTransformFeedback(): WebGLTransformFeedback;
  116197. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116198. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116199. beginTransformFeedback(primitiveMode: number): void;
  116200. endTransformFeedback(): void;
  116201. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116202. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116203. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116204. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116205. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116206. }
  116207. interface ImageBitmap {
  116208. readonly width: number;
  116209. readonly height: number;
  116210. close(): void;
  116211. }
  116212. interface WebGLQuery extends WebGLObject {
  116213. }
  116214. declare var WebGLQuery: {
  116215. prototype: WebGLQuery;
  116216. new(): WebGLQuery;
  116217. };
  116218. interface WebGLSampler extends WebGLObject {
  116219. }
  116220. declare var WebGLSampler: {
  116221. prototype: WebGLSampler;
  116222. new(): WebGLSampler;
  116223. };
  116224. interface WebGLSync extends WebGLObject {
  116225. }
  116226. declare var WebGLSync: {
  116227. prototype: WebGLSync;
  116228. new(): WebGLSync;
  116229. };
  116230. interface WebGLTransformFeedback extends WebGLObject {
  116231. }
  116232. declare var WebGLTransformFeedback: {
  116233. prototype: WebGLTransformFeedback;
  116234. new(): WebGLTransformFeedback;
  116235. };
  116236. interface WebGLVertexArrayObject extends WebGLObject {
  116237. }
  116238. declare var WebGLVertexArrayObject: {
  116239. prototype: WebGLVertexArrayObject;
  116240. new(): WebGLVertexArrayObject;
  116241. };
  116242. // Type definitions for WebVR API
  116243. // Project: https://w3c.github.io/webvr/
  116244. // Definitions by: six a <https://github.com/lostfictions>
  116245. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116246. interface VRDisplay extends EventTarget {
  116247. /**
  116248. * Dictionary of capabilities describing the VRDisplay.
  116249. */
  116250. readonly capabilities: VRDisplayCapabilities;
  116251. /**
  116252. * z-depth defining the far plane of the eye view frustum
  116253. * enables mapping of values in the render target depth
  116254. * attachment to scene coordinates. Initially set to 10000.0.
  116255. */
  116256. depthFar: number;
  116257. /**
  116258. * z-depth defining the near plane of the eye view frustum
  116259. * enables mapping of values in the render target depth
  116260. * attachment to scene coordinates. Initially set to 0.01.
  116261. */
  116262. depthNear: number;
  116263. /**
  116264. * An identifier for this distinct VRDisplay. Used as an
  116265. * association point in the Gamepad API.
  116266. */
  116267. readonly displayId: number;
  116268. /**
  116269. * A display name, a user-readable name identifying it.
  116270. */
  116271. readonly displayName: string;
  116272. readonly isConnected: boolean;
  116273. readonly isPresenting: boolean;
  116274. /**
  116275. * If this VRDisplay supports room-scale experiences, the optional
  116276. * stage attribute contains details on the room-scale parameters.
  116277. */
  116278. readonly stageParameters: VRStageParameters | null;
  116279. /**
  116280. * Passing the value returned by `requestAnimationFrame` to
  116281. * `cancelAnimationFrame` will unregister the callback.
  116282. * @param handle Define the hanle of the request to cancel
  116283. */
  116284. cancelAnimationFrame(handle: number): void;
  116285. /**
  116286. * Stops presenting to the VRDisplay.
  116287. * @returns a promise to know when it stopped
  116288. */
  116289. exitPresent(): Promise<void>;
  116290. /**
  116291. * Return the current VREyeParameters for the given eye.
  116292. * @param whichEye Define the eye we want the parameter for
  116293. * @returns the eye parameters
  116294. */
  116295. getEyeParameters(whichEye: string): VREyeParameters;
  116296. /**
  116297. * Populates the passed VRFrameData with the information required to render
  116298. * the current frame.
  116299. * @param frameData Define the data structure to populate
  116300. * @returns true if ok otherwise false
  116301. */
  116302. getFrameData(frameData: VRFrameData): boolean;
  116303. /**
  116304. * Get the layers currently being presented.
  116305. * @returns the list of VR layers
  116306. */
  116307. getLayers(): VRLayer[];
  116308. /**
  116309. * Return a VRPose containing the future predicted pose of the VRDisplay
  116310. * when the current frame will be presented. The value returned will not
  116311. * change until JavaScript has returned control to the browser.
  116312. *
  116313. * The VRPose will contain the position, orientation, velocity,
  116314. * and acceleration of each of these properties.
  116315. * @returns the pose object
  116316. */
  116317. getPose(): VRPose;
  116318. /**
  116319. * Return the current instantaneous pose of the VRDisplay, with no
  116320. * prediction applied.
  116321. * @returns the current instantaneous pose
  116322. */
  116323. getImmediatePose(): VRPose;
  116324. /**
  116325. * The callback passed to `requestAnimationFrame` will be called
  116326. * any time a new frame should be rendered. When the VRDisplay is
  116327. * presenting the callback will be called at the native refresh
  116328. * rate of the HMD. When not presenting this function acts
  116329. * identically to how window.requestAnimationFrame acts. Content should
  116330. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116331. * asynchronously from other displays and at differing refresh rates.
  116332. * @param callback Define the eaction to run next frame
  116333. * @returns the request handle it
  116334. */
  116335. requestAnimationFrame(callback: FrameRequestCallback): number;
  116336. /**
  116337. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116338. * Repeat calls while already presenting will update the VRLayers being displayed.
  116339. * @param layers Define the list of layer to present
  116340. * @returns a promise to know when the request has been fulfilled
  116341. */
  116342. requestPresent(layers: VRLayer[]): Promise<void>;
  116343. /**
  116344. * Reset the pose for this display, treating its current position and
  116345. * orientation as the "origin/zero" values. VRPose.position,
  116346. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116347. * updated when calling resetPose(). This should be called in only
  116348. * sitting-space experiences.
  116349. */
  116350. resetPose(): void;
  116351. /**
  116352. * The VRLayer provided to the VRDisplay will be captured and presented
  116353. * in the HMD. Calling this function has the same effect on the source
  116354. * canvas as any other operation that uses its source image, and canvases
  116355. * created without preserveDrawingBuffer set to true will be cleared.
  116356. * @param pose Define the pose to submit
  116357. */
  116358. submitFrame(pose?: VRPose): void;
  116359. }
  116360. declare var VRDisplay: {
  116361. prototype: VRDisplay;
  116362. new(): VRDisplay;
  116363. };
  116364. interface VRLayer {
  116365. leftBounds?: number[] | Float32Array | null;
  116366. rightBounds?: number[] | Float32Array | null;
  116367. source?: HTMLCanvasElement | null;
  116368. }
  116369. interface VRDisplayCapabilities {
  116370. readonly canPresent: boolean;
  116371. readonly hasExternalDisplay: boolean;
  116372. readonly hasOrientation: boolean;
  116373. readonly hasPosition: boolean;
  116374. readonly maxLayers: number;
  116375. }
  116376. interface VREyeParameters {
  116377. /** @deprecated */
  116378. readonly fieldOfView: VRFieldOfView;
  116379. readonly offset: Float32Array;
  116380. readonly renderHeight: number;
  116381. readonly renderWidth: number;
  116382. }
  116383. interface VRFieldOfView {
  116384. readonly downDegrees: number;
  116385. readonly leftDegrees: number;
  116386. readonly rightDegrees: number;
  116387. readonly upDegrees: number;
  116388. }
  116389. interface VRFrameData {
  116390. readonly leftProjectionMatrix: Float32Array;
  116391. readonly leftViewMatrix: Float32Array;
  116392. readonly pose: VRPose;
  116393. readonly rightProjectionMatrix: Float32Array;
  116394. readonly rightViewMatrix: Float32Array;
  116395. readonly timestamp: number;
  116396. }
  116397. interface VRPose {
  116398. readonly angularAcceleration: Float32Array | null;
  116399. readonly angularVelocity: Float32Array | null;
  116400. readonly linearAcceleration: Float32Array | null;
  116401. readonly linearVelocity: Float32Array | null;
  116402. readonly orientation: Float32Array | null;
  116403. readonly position: Float32Array | null;
  116404. readonly timestamp: number;
  116405. }
  116406. interface VRStageParameters {
  116407. sittingToStandingTransform?: Float32Array;
  116408. sizeX?: number;
  116409. sizeY?: number;
  116410. }
  116411. interface Navigator {
  116412. getVRDisplays(): Promise<VRDisplay[]>;
  116413. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116414. }
  116415. interface Window {
  116416. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116417. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116418. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116419. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116420. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116421. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116422. }
  116423. interface Gamepad {
  116424. readonly displayId: number;
  116425. }
  116426. interface XRDevice {
  116427. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116428. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116429. }
  116430. interface XRSession {
  116431. getInputSources(): Array<any>;
  116432. baseLayer: XRWebGLLayer;
  116433. requestFrameOfReference(type: string): Promise<void>;
  116434. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116435. end(): Promise<void>;
  116436. requestAnimationFrame: Function;
  116437. addEventListener: Function;
  116438. }
  116439. interface XRSessionCreationOptions {
  116440. outputContext?: WebGLRenderingContext | null;
  116441. immersive?: boolean;
  116442. environmentIntegration?: boolean;
  116443. }
  116444. interface XRLayer {
  116445. getViewport: Function;
  116446. framebufferWidth: number;
  116447. framebufferHeight: number;
  116448. }
  116449. interface XRView {
  116450. projectionMatrix: Float32Array;
  116451. }
  116452. interface XRFrame {
  116453. getDevicePose: Function;
  116454. getInputPose: Function;
  116455. views: Array<XRView>;
  116456. baseLayer: XRLayer;
  116457. }
  116458. interface XRFrameOfReference {
  116459. }
  116460. interface XRWebGLLayer extends XRLayer {
  116461. framebuffer: WebGLFramebuffer;
  116462. }
  116463. declare var XRWebGLLayer: {
  116464. prototype: XRWebGLLayer;
  116465. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  116466. };